mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-07 10:20:29 +00:00
aarch64 loader os detection
Merge branches 'pass-os' and 'cosmo-os' into aarch64-os
This commit is contained in:
commit
c5a05f22a2
2 changed files with 20 additions and 10 deletions
|
@ -127,7 +127,7 @@ _start:
|
||||||
|
|
||||||
#if SupportsFreebsd()
|
#if SupportsFreebsd()
|
||||||
// save first arg
|
// save first arg
|
||||||
mov x3,x0
|
mov x4,x0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// save original stack pointer
|
// save original stack pointer
|
||||||
|
|
|
@ -79,7 +79,7 @@ static const char *DecodeMagnum(const char *p, long *r) {
|
||||||
}
|
}
|
||||||
|
|
||||||
wontreturn textstartup void cosmo(long *sp, struct Syslib *m1, char *exename,
|
wontreturn textstartup void cosmo(long *sp, struct Syslib *m1, char *exename,
|
||||||
long *is_freebsd) {
|
int os, long *is_freebsd) {
|
||||||
|
|
||||||
// get startup timestamp as early as possible
|
// get startup timestamp as early as possible
|
||||||
// its used by --strace and also kprintf() %T
|
// its used by --strace and also kprintf() %T
|
||||||
|
@ -117,17 +117,27 @@ wontreturn textstartup void cosmo(long *sp, struct Syslib *m1, char *exename,
|
||||||
__program_executable_name = exename;
|
__program_executable_name = exename;
|
||||||
program_invocation_name = argv[0];
|
program_invocation_name = argv[0];
|
||||||
__oldstack = (intptr_t)sp;
|
__oldstack = (intptr_t)sp;
|
||||||
|
if (!(hostos = os)) {
|
||||||
// detect apple m1 environment
|
|
||||||
const char *magnums;
|
|
||||||
if (SupportsFreebsd() && is_freebsd) {
|
if (SupportsFreebsd() && is_freebsd) {
|
||||||
hostos = _HOSTFREEBSD;
|
hostos = _HOSTFREEBSD;
|
||||||
magnums = syscon_freebsd;
|
} else if (SupportsXnu() && m1) {
|
||||||
} else if (SupportsXnu() && (__syslib = m1)) {
|
|
||||||
hostos = _HOSTXNU;
|
hostos = _HOSTXNU;
|
||||||
magnums = syscon_xnu;
|
|
||||||
} else if (SupportsLinux()) {
|
} else if (SupportsLinux()) {
|
||||||
hostos = _HOSTLINUX;
|
hostos = _HOSTLINUX;
|
||||||
|
} else {
|
||||||
|
notpossible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *magnums;
|
||||||
|
if (IsFreebsd()) {
|
||||||
|
magnums = syscon_freebsd;
|
||||||
|
} else if (IsXnu()) {
|
||||||
|
if (!(__syslib = m1)) {
|
||||||
|
notpossible;
|
||||||
|
}
|
||||||
|
magnums = syscon_xnu;
|
||||||
|
} else if (IsLinux()) {
|
||||||
magnums = syscon_linux;
|
magnums = syscon_linux;
|
||||||
} else {
|
} else {
|
||||||
notpossible;
|
notpossible;
|
||||||
|
@ -139,7 +149,7 @@ wontreturn textstartup void cosmo(long *sp, struct Syslib *m1, char *exename,
|
||||||
}
|
}
|
||||||
|
|
||||||
// check system call abi compatibility
|
// check system call abi compatibility
|
||||||
if (SupportsXnu() && __syslib && __syslib->__version < SYSLIB_VERSION) {
|
if (IsXnu() && __syslib->__version < SYSLIB_VERSION) {
|
||||||
sys_write(2, "need newer ape loader\n", 22);
|
sys_write(2, "need newer ape loader\n", 22);
|
||||||
_Exit(127);
|
_Exit(127);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue