]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwfl_module_getsym should not adjust symbols from non-SHF_ALLOC sections.
authorRoland McGrath <roland@redhat.com>
Thu, 9 Apr 2009 00:05:43 +0000 (17:05 -0700)
committerRoland McGrath <roland@redhat.com>
Thu, 9 Apr 2009 00:05:43 +0000 (17:05 -0700)
libdwfl/ChangeLog
libdwfl/dwfl_module_getsym.c
libdwfl/relocate.c

index d420e3c9ddb4a8973bfe141acb69decdf9dacdf0..91c2f3150b2e0a3b3d14fbdec6844d8e5b3d254c 100644 (file)
@@ -1,3 +1,10 @@
+2009-04-08  Roland McGrath  <roland@redhat.com>
+
+       * 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  <roland@redhat.com>
 
        * dwfl_module_build_id.c (__libdwfl_find_build_id): Move SHSTRNDX
index 5f289ccb1372716a95f8593e178a71664d2a4af4..a4ce28446c61c0b60a0f6e3f3c9addb3b1b379f3 100644 (file)
@@ -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:
index ef1daeee94df7da9b4ce5e41a515e6556fb5f96d..e809a979db9c26fc7ca9aa7bf70559c20897b87e 100644 (file)
@@ -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: