mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48:31 +00:00
aarch64 loader passes os (#1042)
* Reorder Launch arguments, pass aarch64 os Third and fourth arguments are now identical between cosmo and Launch. By passing sp as argument 4, we save a bit of register juggling. Fourth argument (os) is now always passed by the loader on aarch64. It is not yet processed by cosmo. Pushing this change separately, as the cosmo side turns out to be somewhat more involved. * 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
d8ad34686a
commit
14fe83facd
5 changed files with 30 additions and 20 deletions
|
@ -79,7 +79,7 @@ static const char *DecodeMagnum(const char *p, long *r) {
|
|||
}
|
||||
|
||||
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
|
||||
// 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_invocation_name = argv[0];
|
||||
__oldstack = (intptr_t)sp;
|
||||
if (!(hostos = os)) {
|
||||
if (SupportsFreebsd() && is_freebsd) {
|
||||
hostos = _HOSTFREEBSD;
|
||||
} else if (SupportsXnu() && m1) {
|
||||
hostos = _HOSTXNU;
|
||||
} else if (SupportsLinux()) {
|
||||
hostos = _HOSTLINUX;
|
||||
} else {
|
||||
notpossible;
|
||||
}
|
||||
}
|
||||
|
||||
// detect apple m1 environment
|
||||
const char *magnums;
|
||||
if (SupportsFreebsd() && is_freebsd) {
|
||||
hostos = _HOSTFREEBSD;
|
||||
if (IsFreebsd()) {
|
||||
magnums = syscon_freebsd;
|
||||
} else if (SupportsXnu() && (__syslib = m1)) {
|
||||
hostos = _HOSTXNU;
|
||||
} else if (IsXnu()) {
|
||||
if (!(__syslib = m1)) {
|
||||
notpossible;
|
||||
}
|
||||
magnums = syscon_xnu;
|
||||
} else if (SupportsLinux()) {
|
||||
hostos = _HOSTLINUX;
|
||||
} else if (IsLinux()) {
|
||||
magnums = syscon_linux;
|
||||
} else {
|
||||
notpossible;
|
||||
|
@ -139,7 +149,7 @@ wontreturn textstartup void cosmo(long *sp, struct Syslib *m1, char *exename,
|
|||
}
|
||||
|
||||
// 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);
|
||||
_Exit(127);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue