From: Roland McGrath Date: Fri, 13 Feb 2009 01:26:39 +0000 (-0800) Subject: Fix build_id vaddr calculation for ET_REL modules. X-Git-Tag: elfutils-0.140~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=31fd654b5127ab0249a8bd7576e08f451fcab6af;p=thirdparty%2Felfutils.git Fix build_id vaddr calculation for ET_REL modules. --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 11e12a35f..9633bb5d1 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2009-02-12 Roland McGrath + + * dwfl_module_build_id.c (__libdwfl_find_build_id): Use + __libdwfl_relocate_value to find correct sh_addr value. + 2009-02-10 Roland McGrath * dwfl_report_elf.c (__libdwfl_report_elf): Take new arg SANITY. diff --git a/libdwfl/dwfl_module_build_id.c b/libdwfl/dwfl_module_build_id.c index d1e0eb057..5d196a9d9 100644 --- a/libdwfl/dwfl_module_build_id.c +++ b/libdwfl/dwfl_module_build_id.c @@ -1,5 +1,5 @@ /* Return build ID information for a module. - Copyright (C) 2007, 2008 Red Hat, Inc. + Copyright (C) 2007, 2008, 2009 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -130,9 +130,16 @@ __libdwfl_find_build_id (Dwfl_Module *mod, bool set, Elf *elf) GElf_Shdr shdr_mem; GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); if (likely (shdr != NULL) && shdr->sh_type == SHT_NOTE) - result = check_notes (mod, set, elf_getdata (scn, NULL), - (shdr->sh_flags & SHF_ALLOC) - ? shdr->sh_addr + mod->main.bias : NO_VADDR); + { + /* Determine the right sh_addr in this module. */ + size_t shstrndx = SHN_UNDEF; + GElf_Addr vaddr = 0; + if (!(shdr->sh_flags & SHF_ALLOC) + || __libdwfl_relocate_value (mod, elf, &shstrndx, + elf_ndxscn (scn), &vaddr)) + vaddr = NO_VADDR; + result = check_notes (mod, set, elf_getdata (scn, NULL), vaddr); + } } while (result == 0 && (scn = elf_nextscn (elf, scn)) != NULL);