mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-09 19:30:29 +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 rdi is passed through as-is
|
||||||
// @param rsi is address of entrypoint (becomes zero)
|
// @param rsi is address of entrypoint (becomes zero)
|
||||||
// @param rdx is stack pointer (becomes zero)
|
// @param rdx is passed through as-is
|
||||||
// @param rcx is passed through as-is
|
// @param rcx is stack pointer (becomes r8)
|
||||||
// @noreturn
|
// @noreturn
|
||||||
Launch:
|
Launch:
|
||||||
#ifdef __aarch64__
|
#ifdef __aarch64__
|
||||||
|
|
||||||
mov x16,x1
|
mov x16,x1
|
||||||
mov sp,x2
|
mov sp,x3
|
||||||
mov x1,0
|
mov x1,0
|
||||||
mov x2,0
|
mov x3,x4
|
||||||
mov x3,0
|
|
||||||
mov x4,0
|
mov x4,0
|
||||||
mov x5,0
|
mov x5,0
|
||||||
mov x6,0
|
mov x6,0
|
||||||
|
@ -71,6 +70,8 @@ Launch:
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
mov %rcx,%rsp
|
||||||
|
mov %r8,%rcx
|
||||||
xor %r8d,%r8d
|
xor %r8d,%r8d
|
||||||
xor %r9d,%r9d
|
xor %r9d,%r9d
|
||||||
xor %r10d,%r10d
|
xor %r10d,%r10d
|
||||||
|
@ -79,8 +80,6 @@ Launch:
|
||||||
xor %r13d,%r13d
|
xor %r13d,%r13d
|
||||||
xor %r14d,%r14d
|
xor %r14d,%r14d
|
||||||
xor %r15d,%r15d
|
xor %r15d,%r15d
|
||||||
mov %rdx,%rsp
|
|
||||||
xor %edx,%edx
|
|
||||||
push %rsi
|
push %rsi
|
||||||
xor %esi,%esi
|
xor %esi,%esi
|
||||||
xor %ebp,%ebp
|
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,
|
__attribute__((__noreturn__)) static void Spawn(int os, const char *exe,
|
||||||
const char *path, int fd,
|
char *path, int fd, long *sp,
|
||||||
long *sp, unsigned long pagesz,
|
unsigned long pagesz,
|
||||||
struct ElfEhdr *e,
|
struct ElfEhdr *e,
|
||||||
struct ElfPhdr *p) {
|
struct ElfPhdr *p) {
|
||||||
long rc;
|
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,
|
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 *auxv, unsigned long pagesz, int os) {
|
||||||
long i, rc;
|
long i, rc;
|
||||||
unsigned size;
|
unsigned size;
|
||||||
|
|
|
@ -62,6 +62,8 @@ _start:
|
||||||
// set operating system when already detected
|
// set operating system when already detected
|
||||||
1: mov %cl,__hostos(%rip)
|
1: mov %cl,__hostos(%rip)
|
||||||
|
|
||||||
|
mov %rdx,__program_executable_name(%rip)
|
||||||
|
|
||||||
// get startup timestamp as early as possible
|
// get startup timestamp as early as possible
|
||||||
// its used by --strace flag and kprintf() %T
|
// its used by --strace flag and kprintf() %T
|
||||||
rdtsc
|
rdtsc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue