mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 08:18:30 +00:00
Improve signals and memory protection
- Document sigaction() - Simplify New Technology fork() code - Testing and many bug fixes for mprotect() - Distribute Intel Xed ILD in the amalgamation - Turn Xed enums into defines to avoid DWARF bloat - Improve polyfilling of SA_SIGINFO on BSDs and fix bugs - setpgid(getpid(), getpid()) on Windows will ignore CTRL-C - Work around issues relating to NT mappings being executable - Permit automatic executable stack override via `ape_stack_pf`
This commit is contained in:
parent
c95c9d9508
commit
f684e348d4
76 changed files with 1844 additions and 1121 deletions
34
ape/ape.S
34
ape/ape.S
|
@ -660,6 +660,7 @@ apesh: .ascii "'\n#'\"\n" # sixth edition shebang
|
|||
|
||||
#if SupportsSystemv() || SupportsMetal()
|
||||
.section .elf.phdrs,"a",@progbits
|
||||
|
||||
.long PT_LOAD
|
||||
.long PF_R|PF_X
|
||||
.stub ape_rom_offset,quad
|
||||
|
@ -668,6 +669,7 @@ apesh: .ascii "'\n#'\"\n" # sixth edition shebang
|
|||
.stub ape_rom_filesz,quad
|
||||
.stub ape_rom_memsz,quad
|
||||
.stub ape_rom_align,quad
|
||||
|
||||
.long PT_LOAD
|
||||
.long PF_R|PF_W
|
||||
.stub ape_ram_offset,quad
|
||||
|
@ -676,14 +678,32 @@ apesh: .ascii "'\n#'\"\n" # sixth edition shebang
|
|||
.stub ape_ram_filesz,quad
|
||||
.stub ape_ram_memsz,quad
|
||||
.stub ape_ram_align,quad
|
||||
|
||||
// APE Stack Configuration
|
||||
//
|
||||
// We actually respect this when allocating a deterministically
|
||||
// addressed stack on Windows and other operating systems. However
|
||||
// there's a few caveats:
|
||||
//
|
||||
// - If ape_stack_pf has PF_X then OpenBSD probably won't work
|
||||
// - We don't bother creating a deterministic stack in MODE=tiny
|
||||
//
|
||||
// With that said, here's some examples of configuration:
|
||||
//
|
||||
// STATIC_SYMBOL("ape_stack_pf", "7"); // RWX
|
||||
// STATIC_STACK_ADDR(0x6fffffff0000);
|
||||
// STATIC_STACK_SIZE(65536);
|
||||
//
|
||||
// @see ape.lds for defaults
|
||||
.long PT_GNU_STACK
|
||||
.long PF_R|PF_W
|
||||
.stub ape_stack_offset,quad
|
||||
.stub ape_stack_vaddr,quad
|
||||
.stub ape_stack_paddr,quad
|
||||
.stub ape_stack_filesz,quad
|
||||
.stub ape_stack_memsz,quad
|
||||
.stub ape_stack_align,quad
|
||||
.stub ape_stack_pf,long # override w/ PF_X for execstack
|
||||
.stub ape_stack_offset,quad # ignored
|
||||
.stub ape_stack_vaddr,quad # is mmap()'d with MAP_FIXED
|
||||
.stub ape_stack_paddr,quad # ignored
|
||||
.stub ape_stack_filesz,quad # ignored
|
||||
.stub ape_stack_memsz,quad # is mmap(size) argument
|
||||
.stub ape_stack_align,quad # must be 16+
|
||||
|
||||
#if SupportsOpenbsd() || SupportsNetbsd()
|
||||
.long PT_NOTE
|
||||
.long PF_R
|
||||
|
|
|
@ -177,6 +177,8 @@
|
|||
#include "ape/macros.internal.h"
|
||||
#include "ape/relocations.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/elf/def.h"
|
||||
#include "libc/elf/pf2prot.internal.h"
|
||||
#include "libc/nt/pedef.internal.h"
|
||||
#include "libc/zip.h"
|
||||
|
||||
|
@ -505,6 +507,8 @@ HIDDEN(ape_ram_memsz = ADDR(.bss) + SIZEOF(.bss) - ape_ram_vaddr);
|
|||
HIDDEN(ape_ram_align = PAGESIZE);
|
||||
HIDDEN(ape_ram_rva = RVA(ape_ram_vaddr));
|
||||
|
||||
HIDDEN(ape_stack_pf = DEFINED(ape_stack_pf) ? ape_stack_pf : PF_R | PF_W);
|
||||
HIDDEN(ape_stack_prot = _PF2PROT(ape_stack_pf));
|
||||
HIDDEN(ape_stack_offset = ape_ram_offset + ape_ram_filesz);
|
||||
HIDDEN(ape_stack_vaddr = DEFINED(ape_stack_vaddr) ? ape_stack_vaddr : 0x700000000000 - STACKSIZE);
|
||||
HIDDEN(ape_stack_paddr = ape_ram_paddr + ape_ram_filesz);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue