svn commit: r183739 - head/libexec/rtld-elf/mips
Warner Losh
imp at FreeBSD.org
Fri Oct 10 05:10:11 UTC 2008
Author: imp
Date: Fri Oct 10 05:10:10 2008
New Revision: 183739
URL: http://svn.freebsd.org/changeset/base/183739
Log:
MFp4: Fix a bug in the mips relocation code that prevents shared images
from working.
From p4 filelog of the upstream file in p4
//depot/projects/mips2-jnpr/src/libexec/rtld-elf/mips/reloc.c
... #6 change 140737 edit on 2008/04/27 by gonzo at gonzo_jeeves (text+ko)
o Looks like handler for R_MIPS_REL32 brought by CS 137942
is broken for tradmips. Code from NetBSD's
libexec/ld.elf_so/arch/mips/mips_reloc.c works just fine.
... #3 change 137942 edit on 2008/03/17 by rrs at rrs-mips2-jnpr (text+ko)
Any relocation symbol lookup if its 0. It looks like
this is the way the compiler indicates you need to
look in another shared library. When we hit these
as we relocate a object we will do the symbol
lookups and setup the relocation table with the
right value.
Submitted by: rrs@, gonzo@
Modified:
head/libexec/rtld-elf/mips/reloc.c
Modified: head/libexec/rtld-elf/mips/reloc.c
==============================================================================
--- head/libexec/rtld-elf/mips/reloc.c Fri Oct 10 04:23:40 2008 (r183738)
+++ head/libexec/rtld-elf/mips/reloc.c Fri Oct 10 05:10:10 2008 (r183739)
@@ -258,31 +258,23 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry
case R_TYPE(REL32):
/* 32-bit PC-relative reference */
def = obj->symtab + symnum;
- tmp = load_ptr(where);
- if (tmp == 0) {
- def = find_symdef(symnum, obj, &defobj, false, NULL);
- if (def == NULL) {
- dbg("Warning5, cant find symbole %d:%s", (int)symnum,
- obj->strtab + obj->symtab[symnum].st_name);
- } else {
- tmp = def->st_value + (Elf_Addr)defobj->relocbase;
- dbg("Correctiong symnum:%d:%s to addr:%x", (int)symnum,
- obj->strtab + obj->symtab[symnum].st_name,
- (u_int32_t)tmp
- );
- }
+ if (symnum >= obj->gotsym) {
+ tmp = load_ptr(where);
+ tmp += got[obj->local_gotno + symnum - obj->gotsym];
+ store_ptr(where, tmp);
+ break;
} else {
- tmp += (Elf_Addr)obj->relocbase;
- }
- store_ptr(where, tmp);
- if (tmp == (Elf_Addr)obj->relocbase) {
- dbg("rel sym %p falls on relocbase symidx:%x symbol:%s", rel,
- (uint32_t)ELF_R_SYM(rel->r_info),
- obj->strtab + obj->symtab[symnum].st_name
- );
+ tmp = load_ptr(where);
+
+ if (def->st_info ==
+ ELF_ST_INFO(STB_LOCAL, STT_SECTION)
+ )
+ tmp += (Elf_Addr)def->st_value;
+
+ tmp += (Elf_Addr)obj->relocbase;
+ store_ptr(where, tmp);
}
break;
-
default:
dbg("sym = %lu, type = %lu, offset = %p, "
"contents = %p, symbol = %s",
More information about the svn-src-all
mailing list