diff options
author | Rich Felker <dalias@aerifal.cx> | 2013-07-26 14:25:51 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2013-07-26 14:25:51 -0400 |
commit | 876748ead3de7798623c09af835a4b56dcc28e0f (patch) | |
tree | d15d30c3b088e55ded494a437923448072df46ca | |
parent | 16ac00ac46a14a568ce836db09ffc3f21799690d (diff) | |
download | musl-876748ead3de7798623c09af835a4b56dcc28e0f.tar.gz musl-876748ead3de7798623c09af835a4b56dcc28e0f.tar.xz musl-876748ead3de7798623c09af835a4b56dcc28e0f.zip |
fix computation of entry point and main app phdrs when invoking via ldso
entry point was wrong for PIE. e_entry was being treated as an absolute value, whereas it's actually relative to the load address (which is zero for non-PIE). phdr pointer was wrong for non-PIE. e_phoff was being treated as load-address-relative, whereas it's actually a file offset in the ELF file. in any case, map_library was already computing it correctly, and the incorrect code in __dynlink was overwriting it with junk.
-rw-r--r-- | src/ldso/dynlink.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c index f4c32ffe..ff416838 100644 --- a/src/ldso/dynlink.c +++ b/src/ldso/dynlink.c @@ -940,9 +940,7 @@ void *__dynlink(int argc, char **argv) close(fd); lib->name = ldname; app->name = argv[0]; - app->phnum = ehdr->e_phnum; - app->phdr = (void *)(app->base + ehdr->e_phoff); - aux[AT_ENTRY] = ehdr->e_entry; + aux[AT_ENTRY] = (size_t)app->base + ehdr->e_entry; } if (app->tls_size) { app->tls_id = tls_cnt = 1; |