mirror of git://git.musl-libc.org/musl
dynamic linker support for PIE binaries (position-independent main program)
even with this change, PIE will not work yet due to deficiencies in the crt1.o startup code.
This commit is contained in:
parent
c82f4a32ec
commit
e12fe65c92
|
@ -511,10 +511,13 @@ void *__dynlink(int argc, char **argv)
|
||||||
ehdr->e_phnum, ehdr->e_phentsize));
|
ehdr->e_phnum, ehdr->e_phentsize));
|
||||||
decode_dyn(lib);
|
decode_dyn(lib);
|
||||||
|
|
||||||
/* Assume base address of 0 for the main program. This is not
|
/* Find load address of the main program, via AT_PHDR vs PT_PHDR. */
|
||||||
* valid for PIE code; we will have to search the PHDR to get
|
|
||||||
* the correct load address in the PIE case (not yet supported). */
|
|
||||||
app->base = 0;
|
app->base = 0;
|
||||||
|
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);
|
||||||
|
}
|
||||||
app->name = argv[0];
|
app->name = argv[0];
|
||||||
app->global = 1;
|
app->global = 1;
|
||||||
app->dynv = (void *)(app->base + find_dyn(
|
app->dynv = (void *)(app->base + find_dyn(
|
||||||
|
|
Loading…
Reference in New Issue