From: Roland McGrath Date: Thu, 9 Apr 2009 00:05:43 +0000 (-0700) Subject: dwfl_module_getsym should not adjust symbols from non-SHF_ALLOC sections. X-Git-Tag: elfutils-0.141~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=243fa26f307a43b30fbfb01cadffec1002c3889e;p=thirdparty%2Felfutils.git dwfl_module_getsym should not adjust symbols from non-SHF_ALLOC sections. --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index d420e3c9d..91c2f3150 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,10 @@ +2009-04-08 Roland McGrath + + * relocate.c (__libdwfl_relocate_value): Don't adjust a value from + a non-SHF_ALLOC section. + (relocate_getsym): Test st_shndx for SHN_* values, not *SHNDX. + * dwfl_module_getsym.c (dwfl_module_getsym): Likewise. + 2009-03-09 Roland McGrath * dwfl_module_build_id.c (__libdwfl_find_build_id): Move SHSTRNDX diff --git a/libdwfl/dwfl_module_getsym.c b/libdwfl/dwfl_module_getsym.c index 5f289ccb1..a4ce28446 100644 --- a/libdwfl/dwfl_module_getsym.c +++ b/libdwfl/dwfl_module_getsym.c @@ -1,5 +1,5 @@ /* Find debugging and symbol information for a module in libdwfl. - Copyright (C) 2006,2007 Red Hat, Inc. + Copyright (C) 2006,2007,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 @@ -77,7 +77,7 @@ dwfl_module_getsym (Dwfl_Module *mod, int ndx, if (shndxp != NULL) *shndxp = shndx; - switch (shndx) + switch (sym->st_shndx) { case SHN_ABS: case SHN_UNDEF: diff --git a/libdwfl/relocate.c b/libdwfl/relocate.c index ef1daeee9..e809a979d 100644 --- a/libdwfl/relocate.c +++ b/libdwfl/relocate.c @@ -95,8 +95,10 @@ __libdwfl_relocate_value (Dwfl_Module *mod, Elf *elf, size_t *shstrndx, return DWFL_E_LIBELF; } - /* Apply the adjustment. */ - *value += refshdr->sh_addr + mod->main.bias; + if (refshdr->sh_flags & SHF_ALLOC) + /* Apply the adjustment. */ + *value += refshdr->sh_addr + mod->main.bias; + return DWFL_E_NOERROR; } @@ -183,7 +185,7 @@ relocate_getsym (Dwfl_Module *mod, if (sym->st_shndx != SHN_XINDEX) *shndx = sym->st_shndx; - switch (*shndx) + switch (sym->st_shndx) { case SHN_ABS: case SHN_UNDEF: