From 649cec5f9868070b4d350b861ee7f68b03a552a8 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 13 Jul 2012 01:31:02 -0400 Subject: [PATCH] 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. --- src/ldso/dynlink.c | 5 +++++ 1 file changed, 5 insertions(+) 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;