diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-07-13 01:31:02 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-07-13 01:31:02 -0400 |
commit | 649cec5f9868070b4d350b861ee7f68b03a552a8 (patch) | |
tree | 715c9beb3f8d3f7ef917db9220308ffb6d9c004f /src/ldso/dynlink.c | |
parent | 48d20136b033da456f7bd98dfc9c384b39891d5f (diff) | |
download | musl-649cec5f9868070b4d350b861ee7f68b03a552a8.tar.gz musl-649cec5f9868070b4d350b861ee7f68b03a552a8.tar.bz2 musl-649cec5f9868070b4d350b861ee7f68b03a552a8.tar.xz musl-649cec5f9868070b4d350b861ee7f68b03a552a8.zip |
make dynamic linker tell the debugger its own pathname
use the main program's PT_INTERP header if possible, since this is
sure to be a correct (and hopefully absolute) pathname.
Diffstat (limited to 'src/ldso/dynlink.c')
-rw-r--r-- | src/ldso/dynlink.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c index 76f416c1..a171df97 100644 --- a/src/ldso/dynlink.c +++ b/src/ldso/dynlink.c @@ -577,12 +577,16 @@ void *__dynlink(int argc, char **argv) decode_dyn(lib); if (aux[AT_PHDR]) { + size_t interp_off = 0; /* Find load address of the main program, via AT_PHDR vs PT_PHDR. */ phdr = (void *)aux[AT_PHDR]; for (i=aux[AT_PHNUM]; i; i--, phdr=(void *)((char *)phdr + aux[AT_PHENT])) { if (phdr->p_type == PT_PHDR) app->base = (void *)(aux[AT_PHDR] - phdr->p_vaddr); + else if (phdr->p_type == PT_INTERP) + interp_off = (size_t)phdr->p_vaddr; } + if (interp_off) lib->name = (char *)app->base + interp_off; app->name = argv[0]; app->dynv = (void *)(app->base + find_dyn( (void *)aux[AT_PHDR], aux[AT_PHNUM], aux[AT_PHENT])); @@ -612,6 +616,7 @@ void *__dynlink(int argc, char **argv) } runtime = 0; close(fd); + lib->name = ldname; app->name = argv[0]; app->dynv = (void *)(app->base + dyno); aux[AT_ENTRY] = ehdr->e_entry; |