mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-07 10:20:29 +00:00
cosmo2 receives os from loader
FreeBSD aarch64 now traps early rather than pretending to be Linux. o/aarch64/examples/env.com still works on Linux and Xnu.
This commit is contained in:
parent
bb2602a524
commit
1163f13772
1 changed files with 20 additions and 7 deletions
|
@ -78,7 +78,8 @@ static const char *DecodeMagnum(const char *p, long *r) {
|
||||||
return *r = x, p;
|
return *r = x, p;
|
||||||
}
|
}
|
||||||
|
|
||||||
wontreturn textstartup void cosmo(long *sp, struct Syslib *m1, char *exename) {
|
wontreturn textstartup void cosmo(long *sp, struct Syslib *m1, char *exename,
|
||||||
|
int os) {
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -111,14 +112,26 @@ 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 (os) {
|
||||||
// detect apple m1 environment
|
hostos = os;
|
||||||
const char *magnums;
|
} else {
|
||||||
if (SupportsXnu() && (__syslib = m1)) {
|
/* old loader */
|
||||||
|
if (SupportsXnu() && m1) {
|
||||||
hostos = _HOSTXNU;
|
hostos = _HOSTXNU;
|
||||||
magnums = syscon_xnu;
|
|
||||||
} else if (SupportsLinux()) {
|
} else if (SupportsLinux()) {
|
||||||
hostos = _HOSTLINUX;
|
hostos = _HOSTLINUX;
|
||||||
|
} else {
|
||||||
|
notpossible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *magnums;
|
||||||
|
if (IsXnu()) {
|
||||||
|
if (!(__syslib = m1)) {
|
||||||
|
notpossible;
|
||||||
|
}
|
||||||
|
magnums = syscon_xnu;
|
||||||
|
} else if (IsLinux()) {
|
||||||
magnums = syscon_linux;
|
magnums = syscon_linux;
|
||||||
} else {
|
} else {
|
||||||
notpossible;
|
notpossible;
|
||||||
|
@ -130,7 +143,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