mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-07 02:10:27 +00:00
Loader passes executable name as rdx
This commit is contained in:
parent
abc5809db0
commit
9fc7438b82
4 changed files with 11 additions and 10 deletions
13
ape/launch.S
13
ape/launch.S
|
@ -31,17 +31,16 @@
|
|||
//
|
||||
// @param rdi is passed through as-is
|
||||
// @param rsi is address of entrypoint (becomes zero)
|
||||
// @param rdx is stack pointer (becomes zero)
|
||||
// @param rcx is passed through as-is
|
||||
// @param rdx is passed through as-is
|
||||
// @param rcx is stack pointer (becomes r8)
|
||||
// @noreturn
|
||||
Launch:
|
||||
#ifdef __aarch64__
|
||||
|
||||
mov x16,x1
|
||||
mov sp,x2
|
||||
mov sp,x3
|
||||
mov x1,0
|
||||
mov x2,0
|
||||
mov x3,0
|
||||
mov x3,x4
|
||||
mov x4,0
|
||||
mov x5,0
|
||||
mov x6,0
|
||||
|
@ -71,6 +70,8 @@ Launch:
|
|||
|
||||
#else
|
||||
|
||||
mov %rcx,%rsp
|
||||
mov %r8,%rcx
|
||||
xor %r8d,%r8d
|
||||
xor %r9d,%r9d
|
||||
xor %r10d,%r10d
|
||||
|
@ -79,8 +80,6 @@ Launch:
|
|||
xor %r13d,%r13d
|
||||
xor %r14d,%r14d
|
||||
xor %r15d,%r15d
|
||||
mov %rdx,%rsp
|
||||
xor %edx,%edx
|
||||
push %rsi
|
||||
xor %esi,%esi
|
||||
xor %ebp,%ebp
|
||||
|
|
|
@ -645,8 +645,8 @@ static char *Commandv(struct PathSearcher *ps, int os, const char *name,
|
|||
}
|
||||
|
||||
__attribute__((__noreturn__)) static void Spawn(int os, const char *exe,
|
||||
const char *path, int fd,
|
||||
long *sp, unsigned long pagesz,
|
||||
char *path, int fd, long *sp,
|
||||
unsigned long pagesz,
|
||||
struct ElfEhdr *e,
|
||||
struct ElfPhdr *p) {
|
||||
long rc;
|
||||
|
@ -807,7 +807,7 @@ __attribute__((__noreturn__)) static void Spawn(int os, const char *exe,
|
|||
}
|
||||
|
||||
static const char *TryElf(struct ApeLoader *M, union ElfEhdrBuf *ebuf,
|
||||
const char *exe, const char *path, int fd, long *sp,
|
||||
const char *exe, char *path, int fd, long *sp,
|
||||
long *auxv, unsigned long pagesz, int os) {
|
||||
long i, rc;
|
||||
unsigned size;
|
||||
|
|
|
@ -62,6 +62,8 @@ _start:
|
|||
// set operating system when already detected
|
||||
1: mov %cl,__hostos(%rip)
|
||||
|
||||
mov %rdx,__program_executable_name(%rip)
|
||||
|
||||
// get startup timestamp as early as possible
|
||||
// its used by --strace flag and kprintf() %T
|
||||
rdtsc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue