]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
addr2line: Use elf_getshdrstrndx not Ehdr field to print section name.
authorMark Wielaard <mark@klomp.org>
Wed, 24 Oct 2018 14:15:04 +0000 (16:15 +0200)
committerMark Wielaard <mark@klomp.org>
Wed, 24 Oct 2018 14:15:52 +0000 (16:15 +0200)
Using the Ehdr field directly doesn't work when there are a large number
of sections.

Signed-off-by: Mark Wielaard <mark@klomp.org>
src/ChangeLog
src/addr2line.c

index bd6751ad02d62b6c0b38e10ab7bc37f0accb2589..5061cc11b165edd34beaedb9bc4daa68965b5f44 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-24  Mark Wielaard  <mark@klomp.org>
+
+       * addr2line.c (print_addrsym): Use elf_getshdrstrndx instead of
+       Ehdr field.
+
 2018-10-24  Mark Wielaard  <mark@klomp.org>
 
        * readelf.c (section_name): Remove ehdr argument, lookup shstrndx.
index b7eb893edea309282456173fdde5262da7945ca2..69d8d99589b27ea500df26d873847a3caa03d0a3 100644 (file)
@@ -446,9 +446,9 @@ print_addrsym (Dwfl_Module *mod, GElf_Addr addr)
              if (shdr != NULL)
                {
                  Elf *elf = dwfl_module_getelf (mod, &ebias);
-                 GElf_Ehdr ehdr;
-                 if (gelf_getehdr (elf, &ehdr) != NULL)
-                   printf (" (%s)", elf_strptr (elf, ehdr.e_shstrndx,
+                 size_t shstrndx;
+                 if (elf_getshdrstrndx (elf, &shstrndx) >= 0)
+                   printf (" (%s)", elf_strptr (elf, shstrndx,
                                                 shdr->sh_name));
                }
            }