mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-12 01:08:00 +00:00
Fix stack alignment and auxv for macho APE loader (#931)
This commit is contained in:
parent
a12ad17291
commit
4f100d2aad
2 changed files with 7 additions and 0 deletions
|
@ -947,6 +947,11 @@ EXTERN_C __attribute__((__noreturn__)) void ApeLoader(long di, long *sp,
|
||||||
os = OPENBSD;
|
os = OPENBSD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* xnu passes auxv as an array of strings */
|
||||||
|
if (os == XNU) {
|
||||||
|
*auxv = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* detect netbsd and find end of words */
|
/* detect netbsd and find end of words */
|
||||||
pagesz = 0;
|
pagesz = 0;
|
||||||
for (ap = auxv; ap[0]; ap += 2) {
|
for (ap = auxv; ap[0]; ap += 2) {
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#ifdef __aarch64__
|
#ifdef __aarch64__
|
||||||
|
|
||||||
_start: mov x1,sp
|
_start: mov x1,sp
|
||||||
|
and sp,x1,#-16
|
||||||
mov x29,0
|
mov x29,0
|
||||||
bl ApeLoader
|
bl ApeLoader
|
||||||
.endfn _start,globl
|
.endfn _start,globl
|
||||||
|
@ -33,6 +34,7 @@ XnuEntrypoint:
|
||||||
mov $_HOSTXNU,%dl // xnu's not unix!
|
mov $_HOSTXNU,%dl // xnu's not unix!
|
||||||
ElfEntrypoint:
|
ElfEntrypoint:
|
||||||
mov %rsp,%rsi // save real stack
|
mov %rsp,%rsi // save real stack
|
||||||
|
andq $-16,%rsp // force SSE alignment
|
||||||
call ApeLoader
|
call ApeLoader
|
||||||
.endfn ElfEntrypoint,globl
|
.endfn ElfEntrypoint,globl
|
||||||
.endfn XnuEntrypoint,globl
|
.endfn XnuEntrypoint,globl
|
||||||
|
|
Loading…
Reference in a new issue