From 2e3668b4304d93c02b5c90e18da2ac66de6673a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C5=8Dshin?= Date: Sun, 7 Jan 2024 02:15:00 -0500 Subject: [PATCH] Fix execfn This is good enough, and better than argv[0] in most cases. --- ape/ape-m1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ape/ape-m1.c b/ape/ape-m1.c index 03059ea81..61c072f8c 100644 --- a/ape/ape-m1.c +++ b/ape/ape-m1.c @@ -966,6 +966,9 @@ int main(int argc, char **argv, char **envp) { } } prog = GetEnv(envp + i + 1, "executable_path"); + if (!execfn) { + execfn = prog; + } /* sneak the system five abi back out of args */ sp = (long *)(argv - 1); @@ -1021,9 +1024,6 @@ int main(int argc, char **argv, char **envp) { argc = sp[1] = sp[0] - 1; argv = (char **)((sp += 1) + 1); } - if (!execfn) { - execfn = prog; - } /* allocate ephemeral memory for reading file */ n = sizeof(union ElfEhdrBuf);