diff options
author | imp <imp@FreeBSD.org> | 2008-10-10 05:10:10 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2008-10-10 05:10:10 +0000 |
commit | 9cf0b7b688d372661200ed4ad35a714ff53a0b8f (patch) | |
tree | 9bbe3a6b9f5537cddf5beb242c964c81a2d63425 /libexec | |
parent | e622a643d3e4f74063025c9cc4f04c53986eeb10 (diff) | |
download | FreeBSD-src-9cf0b7b688d372661200ed4ad35a714ff53a0b8f.zip FreeBSD-src-9cf0b7b688d372661200ed4ad35a714ff53a0b8f.tar.gz |
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@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@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@
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/rtld-elf/mips/reloc.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/libexec/rtld-elf/mips/reloc.c b/libexec/rtld-elf/mips/reloc.c index ab5dff3..60003cc 100644 --- a/libexec/rtld-elf/mips/reloc.c +++ b/libexec/rtld-elf/mips/reloc.c @@ -258,31 +258,23 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld) 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", |