mirror of
git://git.musl-libc.org/musl
synced 2025-01-09 08:10:30 +00:00
__init_libc: add fallbacks for __progname setup
It is possible for argv[0] to be a null pointer, but the __progname variable is used to implement functions in src/legacy/err.c that do not expect it to be null. It is also available to the user via the program_invocation_name alias as a GNU extension, and the implementation in Glibc initializes it to a pointer to empty string rather than NULL. Since argv[0] is usually non-null and it's preferable to keep those variables in BSS, implement the fallbacks in __init_libc, which also allows to have an intermediate fallback to AT_EXECFN.
This commit is contained in:
parent
cc08669380
commit
c7f56b4d2f
8
src/env/__libc_start_main.c
vendored
8
src/env/__libc_start_main.c
vendored
@ -30,10 +30,10 @@ void __init_libc(char **envp, char *pn)
|
||||
__sysinfo = aux[AT_SYSINFO];
|
||||
libc.page_size = aux[AT_PAGESZ];
|
||||
|
||||
if (pn) {
|
||||
__progname = __progname_full = pn;
|
||||
for (i=0; pn[i]; i++) if (pn[i]=='/') __progname = pn+i+1;
|
||||
}
|
||||
if (!pn) pn = (void*)aux[AT_EXECFN];
|
||||
if (!pn) pn = "";
|
||||
__progname = __progname_full = pn;
|
||||
for (i=0; pn[i]; i++) if (pn[i]=='/') __progname = pn+i+1;
|
||||
|
||||
__init_tls(aux);
|
||||
__init_ssp((void *)aux[AT_RANDOM]);
|
||||
|
Loading…
Reference in New Issue
Block a user