[uClibc-cvs] CVS update of uClibc/ldso/ldso (ldso.c mips/elfinterp.c)
Erik Andersen
andersen at codepoet.org
Thu Aug 26 18:36:24 UTC 2004
Date: Thursday, August 26, 2004 @ 12:36:24
Author: andersen
Path: /var/cvs/uClibc/ldso/ldso
Modified: ldso.c (1.114 -> 1.115) mips/elfinterp.c (1.20 -> 1.21)
Avoid multiple passes to perform mips GOT relocations, and do
the whole lot in a single pass.
-Erik
Index: uClibc/ldso/ldso/ldso.c
diff -u uClibc/ldso/ldso/ldso.c:1.114 uClibc/ldso/ldso/ldso.c:1.115
--- uClibc/ldso/ldso/ldso.c:1.114 Thu Aug 26 08:17:08 2004
+++ uClibc/ldso/ldso/ldso.c Thu Aug 26 12:36:23 2004
@@ -275,11 +275,6 @@
INIT_GOT(lpnt, _dl_loaded_modules);
}
-#if defined(__mips__)
- /* Relocate any global GOT entries for the application */
- _dl_perform_mips_global_got_relocations(app_tpnt);
-#endif
-
/* OK, fill this in - we did not have this before */
if (ppnt->p_type == PT_INTERP) {
int readsize = 0;
@@ -667,17 +662,17 @@
#endif
+#ifdef __SUPPORT_LD_DEBUG_EARLY__
+ _dl_dprintf(_dl_debug_file, "Beginning relocation fixups\n");
+#endif
+
#ifdef __mips__
/*
* Relocation of the GOT entries for MIPS have to be done
- * after all the libraries have been loaded.
- */
+ * after all the libraries have been loaded. */
_dl_perform_mips_global_got_relocations(_dl_loaded_modules);
#endif
-#ifdef __SUPPORT_LD_DEBUG_EARLY__
- _dl_dprintf(_dl_debug_file, "Beginning relocation fixups\n");
-#endif
/*
* OK, now all of the kids are tucked into bed in their proper addresses.
* Now we go through and look for REL and RELA records that indicate fixups
Index: uClibc/ldso/ldso/mips/elfinterp.c
diff -u uClibc/ldso/ldso/mips/elfinterp.c:1.20 uClibc/ldso/ldso/mips/elfinterp.c:1.21
--- uClibc/ldso/ldso/mips/elfinterp.c:1.20 Thu Aug 26 05:30:48 2004
+++ uClibc/ldso/ldso/mips/elfinterp.c Thu Aug 26 12:36:23 2004
@@ -188,9 +188,6 @@
unsigned long old_val=0;
#endif
- /* Relocate any global GOT entries for the object */
- _dl_perform_mips_global_got_relocations(tpnt);
-
/* Now parse the relocation information */
rel_size = rel_size / sizeof(Elf32_Rel);
rpnt = (Elf32_Rel *) (rel_addr + tpnt->loadaddr);
@@ -260,47 +257,61 @@
/* Relocate the global GOT entries for the object */
void _dl_perform_mips_global_got_relocations(struct elf_resolve *tpnt)
{
- char *strtab;
Elf32_Sym *sym;
+ char *strtab;
unsigned long i;
unsigned long *got_entry;
- /* Setup the loop variables */
- got_entry = (unsigned long *) (tpnt->loadaddr +
- tpnt->dynamic_info[DT_PLTGOT]) + tpnt->mips_local_gotno;
- sym = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] +
- (unsigned long) tpnt->loadaddr) + tpnt->mips_gotsym;
- strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] +
- (unsigned long) tpnt->loadaddr);
- i = tpnt->mips_symtabno - tpnt->mips_gotsym;
-
- while(i--) {
- if (sym->st_shndx == SHN_UNDEF) {
- if (ELF32_ST_TYPE(sym->st_info) == STT_FUNC && sym->st_value) {
- *got_entry = sym->st_value + (unsigned long) tpnt->loadaddr;
+
+ for (; tpnt ; tpnt = tpnt->next) {
+
+ /* We don't touch the dynamic linker */
+ if (tpnt->libtype == program_interpreter)
+ continue;
+
+ /* Setup the loop variables */
+ got_entry = (unsigned long *) (tpnt->loadaddr +
+ tpnt->dynamic_info[DT_PLTGOT]) + tpnt->mips_local_gotno;
+ sym = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] +
+ (unsigned long) tpnt->loadaddr) + tpnt->mips_gotsym;
+ strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] +
+ (unsigned long) tpnt->loadaddr);
+ i = tpnt->mips_symtabno - tpnt->mips_gotsym;
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ _dl_dprintf(2, "_dl_perform_mips_global_got_relocations for '%s'\n", tpnt->libname);
+#endif
+
+ /* Relocate the global GOT entries for the object */
+ while(i--) {
+ if (sym->st_shndx == SHN_UNDEF) {
+ if (ELF32_ST_TYPE(sym->st_info) == STT_FUNC && sym->st_value) {
+ *got_entry = sym->st_value + (unsigned long) tpnt->loadaddr;
+ }
+ else {
+ *got_entry = (unsigned long) _dl_find_hash(strtab +
+ sym->st_name, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT);
+ }
}
- else {
+ else if (sym->st_shndx == SHN_COMMON) {
*got_entry = (unsigned long) _dl_find_hash(strtab +
- sym->st_name, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT);
+ sym->st_name, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT);
}
- }
- else if (sym->st_shndx == SHN_COMMON) {
- *got_entry = (unsigned long) _dl_find_hash(strtab +
- sym->st_name, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT);
- }
- else if (ELF32_ST_TYPE(sym->st_info) == STT_FUNC &&
- *got_entry != sym->st_value) {
- *got_entry += (unsigned long) tpnt->loadaddr;
- }
- else if (ELF32_ST_TYPE(sym->st_info) == STT_SECTION) {
- if (sym->st_other == 0)
+ else if (ELF32_ST_TYPE(sym->st_info) == STT_FUNC &&
+ *got_entry != sym->st_value) {
*got_entry += (unsigned long) tpnt->loadaddr;
- }
- else {
- *got_entry = (unsigned long) _dl_find_hash(strtab +
- sym->st_name, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT);
- }
+ }
+ else if (ELF32_ST_TYPE(sym->st_info) == STT_SECTION) {
+ if (sym->st_other == 0)
+ *got_entry += (unsigned long) tpnt->loadaddr;
+ }
+ else {
+ *got_entry = (unsigned long) _dl_find_hash(strtab +
+ sym->st_name, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT);
+ }
- got_entry++;
- sym++;
+ got_entry++;
+ sym++;
+ }
}
}
+
More information about the uClibc-cvs
mailing list