diff options
author | marcel <marcel@FreeBSD.org> | 2002-04-25 01:22:16 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2002-04-25 01:22:16 +0000 |
commit | 56d625090ed627a480bc1b8c3253e4cb4c48ec41 (patch) | |
tree | 06955b3f6ae78c92827f72737fab4a079d4113d3 /sys/amd64 | |
parent | 12a8faa64a26e5dcfde6ae295040e0fe4aa5afe1 (diff) | |
download | FreeBSD-src-56d625090ed627a480bc1b8c3253e4cb4c48ec41.zip FreeBSD-src-56d625090ed627a480bc1b8c3253e4cb4c48ec41.tar.gz |
Don't use the symbol name to lookup the symbol value when we can use
the symbol index defined by the relocation. The elf_lookup() support
function is to be used by elf_reloc() when symbol lookups need to be
done. The elf_lookup() function operates on the symbol index and
will do a symbol name based lookup when such is required, otherwise
it uses the symbol index directly. This solves the problem seen on
ia64 where the symbol hash table does not contain local symbols and
a symbol name based lookup would fail for those symbols.
Don't pass the symbol name to elf_reloc(), as it isn't used any more.
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/amd64/elf_machdep.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c index 577aeac..96d91b0 100644 --- a/sys/amd64/amd64/elf_machdep.c +++ b/sys/amd64/amd64/elf_machdep.c @@ -32,13 +32,13 @@ /* Process one elf relocation with addend. */ int -elf_reloc(linker_file_t lf, const void *data, int type, const char *sym) +elf_reloc(linker_file_t lf, const void *data, int type) { Elf_Addr relocbase = (Elf_Addr) lf->address; Elf_Addr *where; Elf_Addr addr; Elf_Addr addend; - Elf_Word rtype; + Elf_Word rtype, symidx; const Elf_Rel *rel; const Elf_Rela *rela; @@ -48,12 +48,14 @@ elf_reloc(linker_file_t lf, const void *data, int type, const char *sym) where = (Elf_Addr *) (relocbase + rel->r_offset); addend = *where; rtype = ELF_R_TYPE(rel->r_info); + symidx = ELF_R_SYM(rel->r_info); break; case ELF_RELOC_RELA: rela = (const Elf_Rela *)data; where = (Elf_Addr *) (relocbase + rela->r_offset); addend = rela->r_addend; rtype = ELF_R_TYPE(rela->r_info); + symidx = ELF_R_SYM(rela->r_info); break; default: panic("unknown reloc type %d\n", type); @@ -65,9 +67,7 @@ elf_reloc(linker_file_t lf, const void *data, int type, const char *sym) break; case R_386_32: /* S + A */ - if (sym == NULL) - return -1; - addr = (Elf_Addr)linker_file_lookup_symbol(lf, sym, 1); + addr = elf_lookup(lf, symidx, 1); if (addr == 0) return -1; addr += addend; @@ -76,9 +76,7 @@ elf_reloc(linker_file_t lf, const void *data, int type, const char *sym) break; case R_386_PC32: /* S + A - P */ - if (sym == NULL) - return -1; - addr = (Elf_Addr)linker_file_lookup_symbol(lf, sym, 1); + addr = elf_lookup(lf, symidx, 1); if (addr == 0) return -1; addr += addend - (Elf_Addr)where; @@ -96,9 +94,7 @@ elf_reloc(linker_file_t lf, const void *data, int type, const char *sym) break; case R_386_GLOB_DAT: /* S */ - if (sym == NULL) - return -1; - addr = (Elf_Addr)linker_file_lookup_symbol(lf, sym, 1); + addr = elf_lookup(lf, symidx, 1); if (addr == 0) return -1; if (*where != addr) |