Polyfill auxiliary values on XNU

This commit is contained in:
Justine Tunney 2021-02-03 20:37:52 -08:00
parent a37960a3af
commit d934f38c99
6 changed files with 27 additions and 32 deletions

View file

@ -52,11 +52,23 @@ _start: test %rdi,%rdi
mov %rdx,%rdi
repnz scasq
mov %rdi,%rcx # auxv
mov %ebx,%edi
#if SupportsXnu()
testb IsXnu()
jz 1f # polyfill xnu auxv
push $0 # auxv[1][1]=0
push $0 # auxv[1][0]=0
mov (%rcx),%rax # executable_path=BIN
lea 16(%rax),%rax # BIN
push %rax # auxv[0][0]=BIN
push $31 # auxv[0][0]=AT_EXECFN
mov %rsp,%rcx # auxv
#endif
1: mov %ebx,%edi
call cosmo
9: ud2
.endfn _start,weak,hidden
#if SupportsXnu()
/ Macintosh userspace program entrypoint.
/
/ @param rsp is [n,argv₀..argvₙ₋₁,0,envp₀..,0,auxv₀..,0,..]
@ -65,3 +77,4 @@ _start: test %rdi,%rdi
_xnu: movb $XNU,__hostos(%rip)
jmp 0b
.endfn _xnu,weak,hidden
#endif