mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 02:38:31 +00:00
Increase stack size to 128k and guard size to 16k
This improves our compatibility with Apple M1.
This commit is contained in:
parent
57c0dcdc29
commit
dd04aeba1c
36 changed files with 109 additions and 125 deletions
|
@ -44,9 +44,14 @@ sys_clone_linux:
|
|||
ret
|
||||
2: xor %ebp,%ebp # child thread
|
||||
mov %rbx,%rdi # arg
|
||||
mov %r10,%r15 # experiment
|
||||
mov (%r10),%esi # tid
|
||||
call *%r9 # func(arg,tid)
|
||||
xchg %eax,%edi # func(arg,tid) → exitcode
|
||||
mov (%r15),%eax # experiment
|
||||
test %eax,%eax # experiment
|
||||
jz 1f # experiment
|
||||
mov $60,%eax # __NR_exit(exitcode)
|
||||
syscall
|
||||
1: hlt # ctid was corrupted by program!
|
||||
.endfn sys_clone_linux,globl,hidden
|
||||
|
|
|
@ -446,6 +446,7 @@ static int CloneLinux(int (*func)(void *arg, int rc), char *stk, size_t stksz,
|
|||
sp -= sizeof(int);
|
||||
sp = sp & -alignof(int);
|
||||
ctid = (int *)sp;
|
||||
sp -= 8; // experiment
|
||||
}
|
||||
sp = sp & -16; // align the stack
|
||||
if ((rc = sys_clone_linux(flags, sp, ptid, ctid, tls, func, arg)) >= 0) {
|
||||
|
|
|
@ -381,10 +381,10 @@ static noasan inline void *Mmap(void *addr, size_t size, int prot, int flags,
|
|||
// however this 1mb behavior oddly enough is smart enough to not
|
||||
// apply if the mapping is a manually-created guard page.
|
||||
int e = errno;
|
||||
if ((dm = sys_mmap(p + size - PAGESIZE, PAGESIZE, prot,
|
||||
if ((dm = sys_mmap(p + size - GUARDSIZE, GUARDSIZE, prot,
|
||||
f | MAP_GROWSDOWN_linux, fd, off))
|
||||
.addr != MAP_FAILED) {
|
||||
_npassert(sys_mmap(p, PAGESIZE, PROT_NONE,
|
||||
_npassert(sys_mmap(p, GUARDSIZE, PROT_NONE,
|
||||
MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)
|
||||
.addr == p);
|
||||
dm.addr = p;
|
||||
|
@ -412,11 +412,11 @@ static noasan inline void *Mmap(void *addr, size_t size, int prot, int flags,
|
|||
if (needguard) {
|
||||
if (!IsWindows()) {
|
||||
// make windows fork() code simpler
|
||||
mprotect(p, PAGESIZE, PROT_NONE);
|
||||
mprotect(p, GUARDSIZE, PROT_NONE);
|
||||
}
|
||||
if (IsAsan()) {
|
||||
__repstosb((void *)(((intptr_t)p >> 3) + 0x7fff8000),
|
||||
kAsanStackOverflow, PAGESIZE / 8);
|
||||
kAsanStackOverflow, GUARDSIZE / 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ extern char ape_stack_align[] __attribute__((__weak__));
|
|||
*/
|
||||
#define HaveStackMemory(n) \
|
||||
(IsTiny() || \
|
||||
(intptr_t)__builtin_frame_address(0) >= GetStackAddr() + PAGESIZE + (n))
|
||||
(intptr_t)__builtin_frame_address(0) >= GetStackAddr() + GUARDSIZE + (n))
|
||||
|
||||
forceinline void CheckLargeStackAllocation(void *p, ssize_t n) {
|
||||
for (; n > 0; n -= 4096) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue