Fix how underfined weak symbols are treated -- before, ld.so would do nothing
with them, rather than defaulting them to zero. This caused breakage with the drawf EH stuff and init/fini code when they weren't used by the caller (and hence the appropriate handlers were left undefined). Also fix an un- initialized variable in symbol.c that only MIPS MD code tripped over.
This commit is contained in:
parent
8d71019a14
commit
2576af45bb
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mips_reloc.c,v 1.3 1999/11/07 08:01:51 mycroft Exp $ */
|
||||
/* $NetBSD: mips_reloc.c,v 1.4 2001/10/14 23:13:22 rafal Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Michael L. Hitch <mhitch@montana.edu>
|
||||
|
@ -47,6 +47,7 @@ _rtld_relocate_mips_got(obj)
|
|||
const Elf_Sym *sym = obj->symtab;
|
||||
const Elf_Sym *def;
|
||||
const Obj_Entry *defobj;
|
||||
Elf_Word info;
|
||||
int i;
|
||||
|
||||
i = (got[1] & 0x80000000) ? 2 : 1;
|
||||
|
@ -58,42 +59,54 @@ _rtld_relocate_mips_got(obj)
|
|||
sym += obj->gotsym;
|
||||
/* Now do the global GOT entries */
|
||||
while (i--) {
|
||||
def = _rtld_find_symdef(_rtld_objlist, 0,
|
||||
sym->st_name + obj->strtab, obj, &defobj, true);
|
||||
if (def != NULL) {
|
||||
if (sym->st_shndx == SHN_UNDEF) {
|
||||
rdbg(1, (" doing got %d sym %p (%s, %x)",
|
||||
obj->symtabno - obj->gotsym - i - 1,
|
||||
sym, sym->st_name + obj->strtab, *got));
|
||||
|
||||
info = ELF32_R_INFO(obj->symtabno - i - 1, sym->st_info);
|
||||
def = _rtld_find_symdef(_rtld_objlist, info, NULL, obj,
|
||||
&defobj, true);
|
||||
|
||||
if (def == NULL)
|
||||
_rtld_error(
|
||||
"%s: Undefined PLT symbol \"%s\" (reloc type = %ld, symnum = %ld)",
|
||||
obj->path, sym->st_name + obj->strtab,
|
||||
(u_long) ELF_R_TYPE(info),
|
||||
(u_long) obj->symtabno - i - 1);
|
||||
|
||||
if (sym->st_shndx == SHN_UNDEF) {
|
||||
#if 0 /* These don't seem to work? */
|
||||
|
||||
if (ELFDEFNNAME(ST_TYPE)(sym->st_info) ==
|
||||
STT_FUNC) {
|
||||
if (sym->st_value)
|
||||
*got = sym->st_value +
|
||||
(Elf_Word)obj->relocbase;
|
||||
else
|
||||
*got = def->st_value +
|
||||
(Elf_Word)defobj->relocbase;
|
||||
} else
|
||||
#endif
|
||||
*got = def->st_value +
|
||||
(Elf_Word)defobj->relocbase;
|
||||
} else if (sym->st_shndx == SHN_COMMON) {
|
||||
*got = def->st_value +
|
||||
(Elf_Word)defobj->relocbase;
|
||||
} else if (ELFDEFNNAME(ST_TYPE)(sym->st_info) ==
|
||||
STT_FUNC &&
|
||||
*got != sym->st_value) {
|
||||
*got += (Elf_Word)obj->relocbase;
|
||||
} else if (ELFDEFNNAME(ST_TYPE)(sym->st_info) ==
|
||||
STT_SECTION && ELFDEFNNAME(ST_BIND)(sym->st_info) ==
|
||||
STB_GLOBAL) {
|
||||
if (sym->st_shndx == SHN_ABS)
|
||||
if (ELFDEFNNAME(ST_TYPE)(sym->st_info) ==
|
||||
STT_FUNC) {
|
||||
if (sym->st_value)
|
||||
*got = sym->st_value +
|
||||
(Elf_Word)obj->relocbase;
|
||||
/* else SGI stuff ignored */
|
||||
else
|
||||
*got = def->st_value +
|
||||
(Elf_Word)defobj->relocbase;
|
||||
} else
|
||||
#endif
|
||||
*got = def->st_value +
|
||||
(Elf_Word)defobj->relocbase;
|
||||
}
|
||||
} else if (sym->st_shndx == SHN_COMMON) {
|
||||
*got = def->st_value +
|
||||
(Elf_Word)defobj->relocbase;
|
||||
} else if (ELFDEFNNAME(ST_TYPE)(sym->st_info) ==
|
||||
STT_FUNC &&
|
||||
*got != sym->st_value) {
|
||||
*got += (Elf_Word)obj->relocbase;
|
||||
} else if (ELFDEFNNAME(ST_TYPE)(sym->st_info) ==
|
||||
STT_SECTION && ELFDEFNNAME(ST_BIND)(sym->st_info) ==
|
||||
STB_GLOBAL) {
|
||||
if (sym->st_shndx == SHN_ABS)
|
||||
*got = sym->st_value +
|
||||
(Elf_Word)obj->relocbase;
|
||||
/* else SGI stuff ignored */
|
||||
} else
|
||||
*got = def->st_value +
|
||||
(Elf_Word)defobj->relocbase;
|
||||
|
||||
++sym;
|
||||
++got;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: symbol.c,v 1.10 2000/10/11 20:46:08 dan Exp $ */
|
||||
/* $NetBSD: symbol.c,v 1.11 2001/10/14 23:13:21 rafal Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
|
@ -163,7 +163,7 @@ _rtld_find_symdef(obj_list, r_info, name, refobj, defobj_out, in_plt)
|
|||
bool in_plt;
|
||||
{
|
||||
Elf_Addr symnum = ELF_R_SYM(r_info);
|
||||
const Elf_Sym *ref = NULL;
|
||||
const Elf_Sym *ref;
|
||||
const Elf_Sym *def;
|
||||
const Elf_Sym *symp;
|
||||
const Obj_Entry *obj;
|
||||
|
@ -171,10 +171,10 @@ _rtld_find_symdef(obj_list, r_info, name, refobj, defobj_out, in_plt)
|
|||
const Objlist_Entry *elm;
|
||||
unsigned long hash;
|
||||
|
||||
if (name == NULL) {
|
||||
ref = refobj->symtab + symnum;
|
||||
ref = refobj->symtab + symnum;
|
||||
if (name == NULL)
|
||||
name = refobj->strtab + ref->st_name;
|
||||
}
|
||||
|
||||
hash = _rtld_elf_hash(name);
|
||||
def = NULL;
|
||||
defobj = NULL;
|
||||
|
@ -227,6 +227,7 @@ _rtld_find_symdef(obj_list, r_info, name, refobj, defobj_out, in_plt)
|
|||
* symbol as having the value zero.
|
||||
*/
|
||||
if (def == NULL && ELF_ST_BIND(ref->st_info) == STB_WEAK) {
|
||||
rdbg(1, (" returning _rtld_sym_zero@_rtld_objmain"));
|
||||
def = &_rtld_sym_zero;
|
||||
defobj = _rtld_objmain;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue