From: Rich Felker Date: Fri, 23 Aug 2013 18:14:47 +0000 (-0400) Subject: use AT_EXECFN, if available, for dynamic linker to identify main program X-Git-Tag: v0.9.13~19 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cc51505a32930754d2cf281c15caa1829b8436e9;p=oweals%2Fmusl.git use AT_EXECFN, if available, for dynamic linker to identify main program fallback to argv[0] as before. unlike argv[0], AT_EXECFN was a valid (but possibly relative) pathname for the new program image at the time the execve syscall was made. as a special case, ignore AT_EXECFN if it begins with "/proc/", in order not to give bogus (and possibly harmful) results when fexecve was used. --- diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c index 6f23fa54..cbddeba7 100644 --- a/src/ldso/dynlink.c +++ b/src/ldso/dynlink.c @@ -1016,7 +1016,11 @@ void *__dynlink(int argc, char **argv) } if (app->tls_size) app->tls_image = (char *)app->base + tls_image; if (interp_off) lib->name = (char *)app->base + interp_off; - app->name = argv[0]; + if ((aux[0] & (1UL<name = (char *)aux[AT_EXECFN]; + else + app->name = argv[0]; app->kernel_mapped = 1; app->dynv = (void *)(app->base + find_dyn( (void *)aux[AT_PHDR], aux[AT_PHNUM], aux[AT_PHENT]));