Fix execfn

This is good enough, and better than argv[0] in most cases.
This commit is contained in:
Jōshin 2024-01-07 02:15:00 -05:00
parent eddebe8db5
commit 2e3668b430
No known key found for this signature in database

View file

@ -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);