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:
Jōshin 2023-12-31 09:42:36 -05:00 committed by GitHub
parent d8ad34686a
commit 14fe83facd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 20 deletions

View file

@ -224,7 +224,7 @@ struct ApeLoader {
};
EXTERN_C long SystemCall(long, long, long, long, long, long, long, int);
EXTERN_C void Launch(void *, long, void *, void *, int)
EXTERN_C void Launch(void *, long, void *, int, void *)
__attribute__((__noreturn__));
extern char __executable_start[];
@ -768,7 +768,7 @@ __attribute__((__noreturn__)) static void Spawn(int os, char *exe, int fd,
Msyscall(dynbase + code, codesize, os);
/* call program entrypoint */
Launch(IsFreebsd() ? sp : 0, dynbase + e->e_entry, exe, sp, os);
Launch(IsFreebsd() ? sp : 0, dynbase + e->e_entry, exe, os, sp);
}
static const char *TryElf(struct ApeLoader *M, union ElfEhdrBuf *ebuf,