diff --git a/ape/ape-m1.c b/ape/ape-m1.c index 4eadb2eaa..9912adefc 100644 --- a/ape/ape-m1.c +++ b/ape/ape-m1.c @@ -821,7 +821,7 @@ static const char *TryElf(struct ApeLoader *M, union ElfEhdrBuf *ebuf, if (e->e_machine != EM_AARCH64) { return "couldn't find ELF header with ARM64 machine type"; } - if (!(e->e_flags & EF_APE_MODERN)) { + if (!(e->e_flags & EF_APE_MODERN) && sp[0]) { /* change argv[0] to resolved path for older binaries */ ((char **)(sp + 1))[0] = exe; } diff --git a/ape/loader.c b/ape/loader.c index 26ce3f94e..912db4ca2 100644 --- a/ape/loader.c +++ b/ape/loader.c @@ -835,7 +835,7 @@ static const char *TryElf(struct ApeLoader *M, union ElfEhdrBuf *ebuf, return "couldn't find ELF header with x86-64 machine type"; } #endif - if (!(e->e_flags & EF_APE_MODERN)) { + if (!(e->e_flags & EF_APE_MODERN) && sp[0]) { /* change argv[0] to resolved path for older binaries */ ((char **)(sp + 1))[0] = exe; }