mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-23 02:50:29 +00:00
Rosetta doesn't correctly respect the startup registers as defined in LC_UNIXTHREAD which makes platform detection go awry. But at least Rosetta appears to consistently set rbx to 0x00000000ffffffff and rdx to 0x0000000000000001 at startup for every x64 executable I could get my hands on. So we use that to detect Rosetta's presence and set up the correct registers for XNU.
This commit is contained in:
parent
5297897ba1
commit
9f8e6c10dd
4 changed files with 38 additions and 4 deletions
|
@ -113,7 +113,18 @@ macho: .long 0xFEEDFACE+1
|
|||
.endobj macho,globl
|
||||
|
||||
.align 64
|
||||
_start: mov %rsp,%rsi
|
||||
_start:
|
||||
|
||||
// Hack for detecting M1 Rosetta environment.
|
||||
// https://github.com/jart/cosmopolitan/issues/429#issuecomment-1166704377
|
||||
cmp $-1,%ebx
|
||||
jne 0f
|
||||
cmp $+1,%edx
|
||||
jne 0f
|
||||
mov $XNU,%dl
|
||||
xor %ecx,%ecx
|
||||
|
||||
0: mov %rsp,%rsi
|
||||
jmp ApeLoader
|
||||
.endfn _start,globl
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue