From 56e895e29fe4844fcba849a70d6b5d336f950673 Mon Sep 17 00:00:00 2001 From: christos Date: Mon, 21 Jul 2008 20:19:28 +0000 Subject: [PATCH] deal specially with sym_zero, returned by a weak symbol that was not found, by retrieving it's name instead of printing random garbage. --- libexec/ld.elf_so/arch/x86_64/mdreloc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libexec/ld.elf_so/arch/x86_64/mdreloc.c b/libexec/ld.elf_so/arch/x86_64/mdreloc.c index 356106982a7b..b640b7163265 100644 --- a/libexec/ld.elf_so/arch/x86_64/mdreloc.c +++ b/libexec/ld.elf_so/arch/x86_64/mdreloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: mdreloc.c,v 1.29 2007/02/23 01:17:11 matt Exp $ */ +/* $NetBSD: mdreloc.c,v 1.30 2008/07/21 20:19:28 christos Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -68,7 +68,7 @@ #include #ifndef lint -__RCSID("$NetBSD: mdreloc.c,v 1.29 2007/02/23 01:17:11 matt Exp $"); +__RCSID("$NetBSD: mdreloc.c,v 1.30 2008/07/21 20:19:28 christos Exp $"); #endif /* not lint */ #include @@ -260,17 +260,22 @@ _rtld_relocate_plt_object(const Obj_Entry *obj, const Elf_Rela *rela, Elf_Addr * Elf_Addr new_value; const Elf_Sym *def; const Obj_Entry *defobj; + const char *name; assert(ELF_R_TYPE(rela->r_info) == R_TYPE(JUMP_SLOT)); def = _rtld_find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, true); if (def == NULL) return -1; - + if (def == &_rtld_sym_zero) + name = obj->strtab + + obj->symtab[ELF_R_SYM(rela->r_info)].st_name; + else + name = defobj->strtab + def->st_name; new_value = (Elf_Addr)(defobj->relocbase + def->st_value + rela->r_addend); - rdbg(("bind now/fixup in %s --> old=%p new=%p", - defobj->strtab + def->st_name, (void *)*where, (void *)new_value)); + rdbg(("bind now/fixup in %s --> old=%p new=%p", name, + (void *)*where, (void *)new_value)); if (*where != new_value) *where = new_value;