summaryrefslogtreecommitdiff
path: root/ldso/ldso/dl-startup.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-06-27 01:16:10 +0000
committerEric Andersen <andersen@codepoet.org>2004-06-27 01:16:10 +0000
commitc5a41a767d3bd57fa91339b017a55a860d2a05b9 (patch)
treeb98832c059365f280ad727d16f9cfda4f2cdb059 /ldso/ldso/dl-startup.c
parent998f870a192c165c53ebf62d896006824e073d60 (diff)
Joakim Tjernlund writes:
Hi yet again :) in dl-startup.c when performing boot strap relocation the following test exists to make sure that only "_dl_" symbols are relocated: /* We only do a partial dynamic linking right now. The user is not supposed to define any symbols that start with a '_dl', so we can do this with confidence. */ if (!symname || !_dl_symbol(symname)) { continue; } However on PPC(and the other archs as well I suspect) all symbols are "_dl_" symbols so the test is never true. The test can be removed and the whole loop simplified(smaller). This also makes it possible to simplify elfinterp.c This remove the scanning of ldso.so relocs, making relocation faster. I have tested this on PPC and it works well. Do you think this optimization will work for the other arches as well? I can't see why not. Jocke * Tested on x86, arm, mipsel, and powerpc by Erik and works nicely -Erik
Diffstat (limited to 'ldso/ldso/dl-startup.c')
-rw-r--r--ldso/ldso/dl-startup.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c
index f97619af3..5d1d5a67e 100644
--- a/ldso/ldso/dl-startup.c
+++ b/ldso/ldso/dl-startup.c
@@ -490,7 +490,7 @@ found_got:
unsigned long symbol_addr;
int symtab_index;
unsigned long rel_addr, rel_size;
-
+ Elf32_Sym *sym;
rel_addr = (indx ? tpnt->dynamic_info[DT_JMPREL] : tpnt->
dynamic_info[DT_RELOC_TABLE_ADDR]);
@@ -506,43 +506,24 @@ found_got:
reloc_addr = (unsigned long *) (load_addr + (unsigned long) rpnt->r_offset);
symtab_index = ELF32_R_SYM(rpnt->r_info);
symbol_addr = 0;
+ sym = NULL;
if (symtab_index) {
char *strtab;
- char *symname;
Elf32_Sym *symtab;
symtab = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] + load_addr);
strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + load_addr);
- symname = strtab + symtab[symtab_index].st_name;
-
- /* We only do a partial dynamic linking right now. The user
- is not supposed to define any symbols that start with a
- '_dl', so we can do this with confidence. */
- if (!symname || !_dl_symbol(symname)) {
- continue;
- }
+ sym = &symtab[symtab_index];
+ symbol_addr = load_addr + sym->st_value;
- symbol_addr = load_addr + symtab[symtab_index].st_value;
-
- if (!symbol_addr) {
- /* This will segfault - you cannot call a function until
- * we have finished the relocations.
- */
- SEND_STDERR("ELF dynamic loader - unable to self-bootstrap - symbol ");
- SEND_STDERR(symname);
- SEND_STDERR(" undefined.\n");
- goof++;
- }
#ifdef __SUPPORT_LD_DEBUG_EARLY__
SEND_STDERR("relocating symbol: ");
- SEND_STDERR(symname);
+ SEND_STDERR(strtab + sym->st_name);
SEND_STDERR("\n");
#endif
- PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr, &symtab[symtab_index]);
- } else {
- /* Use this machine-specific macro to perform the actual relocation. */
- PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr, NULL);
}
+ /* Use this machine-specific macro to perform the actual relocation. */
+ PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr, sym);
}
}