summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldso/ldso/dl-startup.c25
-rw-r--r--ldso/ldso/ldso.c14
2 files changed, 6 insertions, 33 deletions
diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c
index f40207996..e9191e8a4 100644
--- a/ldso/ldso/dl-startup.c
+++ b/ldso/ldso/dl-startup.c
@@ -304,27 +304,25 @@ found_got:
app_tpnt = LD_MALLOC(sizeof(struct elf_resolve));
_dl_memset(app_tpnt, 0, sizeof(struct elf_resolve));
-#ifdef __UCLIBC_PIE_SUPPORT__
/* Find the runtime load address of the main executable, this may be
* different from what the ELF header says for ET_DYN/PIE executables.
*/
{
- ElfW(Phdr) *ppnt;
int i;
-
- ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_ptr;
+ ElfW(Phdr) *ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_ptr;
for (i = 0; i < auxvt[AT_PHNUM].a_un.a_val; i++, ppnt++)
if (ppnt->p_type == PT_PHDR) {
app_tpnt->loadaddr = (ElfW(Addr)) (auxvt[AT_PHDR].a_un.a_val - ppnt->p_vaddr);
break;
}
- }
#ifdef __SUPPORT_LD_DEBUG_EARLY__
- SEND_STDERR("app_tpnt->loadaddr=");
- SEND_ADDRESS_STDERR(app_tpnt->loadaddr, 1);
-#endif
+ if (app_tpnt->loadaddr) {
+ SEND_STDERR("Position Independent Executable: app_tpnt->loadaddr=");
+ SEND_ADDRESS_STDERR(app_tpnt->loadaddr, 1);
+ }
#endif
+ }
/*
* This is used by gdb to locate the chain of shared libraries that are currently loaded.
@@ -362,11 +360,7 @@ found_got:
ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_ptr;
for (i = 0; i < auxvt[AT_PHNUM].a_un.a_val; i++, ppnt++)
if (ppnt->p_type == PT_DYNAMIC) {
-#ifndef __UCLIBC_PIE_SUPPORT__
- dpnt = (Elf32_Dyn *) ppnt->p_vaddr;
-#else
dpnt = (Elf32_Dyn *) (ppnt->p_vaddr + app_tpnt->loadaddr);
-#endif
while (dpnt->d_tag) {
#if defined(__mips__)
if (dpnt->d_tag == DT_MIPS_GOTSYM)
@@ -460,17 +454,10 @@ found_got:
ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_ptr;
for (i = 0; i < auxvt[AT_PHNUM].a_un.a_val; i++, ppnt++) {
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
-#ifndef __UCLIBC_PIE_SUPPORT__
- _dl_mprotect((void *) (ppnt->p_vaddr & PAGE_ALIGN),
- (ppnt->p_vaddr & ADDR_ALIGN) +
- (unsigned long) ppnt->p_filesz,
- PROT_READ | PROT_WRITE | PROT_EXEC);
-#else
_dl_mprotect((void *) ((ppnt->p_vaddr + app_tpnt->loadaddr) & PAGE_ALIGN),
((ppnt->p_vaddr + app_tpnt->loadaddr) & ADDR_ALIGN) +
(unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
-#endif
}
}
}
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 0b0cb1389..71fadd4dd 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -172,13 +172,8 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *app_tpnt
ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_ptr;
for (i = 0; i < auxvt[AT_PHNUM].a_un.a_val; i++, ppnt++) {
if (ppnt->p_type == PT_LOAD) {
-#ifndef __UCLIBC_PIE_SUPPORT__
- if (ppnt->p_vaddr + ppnt->p_memsz > brk_addr)
- brk_addr = ppnt->p_vaddr + ppnt->p_memsz;
-#else
if (ppnt->p_vaddr + app_tpnt->loadaddr + ppnt->p_memsz > brk_addr)
brk_addr = ppnt->p_vaddr + app_tpnt->loadaddr + ppnt->p_memsz;
-#endif
}
if (ppnt->p_type == PT_DYNAMIC) {
#ifndef ALLOW_ZERO_PLTGOT
@@ -187,13 +182,8 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *app_tpnt
continue;
#endif
/* OK, we have what we need - slip this one into the list. */
-#ifndef __UCLIBC_PIE_SUPPORT__
- app_tpnt = _dl_add_elf_hash_table("", 0,
- app_tpnt->dynamic_info, ppnt->p_vaddr, ppnt->p_filesz);
-#else
app_tpnt = _dl_add_elf_hash_table("", (char *)app_tpnt->loadaddr,
app_tpnt->dynamic_info, ppnt->p_vaddr + app_tpnt->loadaddr, ppnt->p_filesz);
-#endif
_dl_loaded_modules->libtype = elf_executable;
_dl_loaded_modules->ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_ptr;
_dl_loaded_modules->n_phent = auxvt[AT_PHNUM].a_un.a_val;
@@ -202,11 +192,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *app_tpnt
rpnt->dyn = _dl_loaded_modules;
app_tpnt->usage_count++;
app_tpnt->symbol_scope = _dl_symbol_tables;
-#ifndef __UCLIBC_PIE_SUPPORT__
- lpnt = (unsigned long *) (app_tpnt->dynamic_info[DT_PLTGOT]);
-#else
lpnt = (unsigned long *) (app_tpnt->dynamic_info[DT_PLTGOT] + app_tpnt->loadaddr);
-#endif
#ifdef ALLOW_ZERO_PLTGOT
if (lpnt)
#endif