summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2018-10-24 16:15:04 +0200
committerMark Wielaard <mark@klomp.org>2018-10-24 16:15:52 +0200
commitb75ff1bbd060404565fa28d72441a9b02f331bae (patch)
tree8fa89867a88f5125e37d115f92e2909147e43f65
parent35197ea4c43ef2101b06e03ef6b3c6778bd986bc (diff)
addr2line: Use elf_getshdrstrndx not Ehdr field to print section name.
Using the Ehdr field directly doesn't work when there are a large number of sections. Signed-off-by: Mark Wielaard <mark@klomp.org>
-rw-r--r--src/ChangeLog5
-rw-r--r--src/addr2line.c6
2 files changed, 8 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index bd6751ad..5061cc11 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
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.
(print_debug_abbrev_section): Don't pass ehdr.
(print_debug_addr_section): Likewise.
diff --git a/src/addr2line.c b/src/addr2line.c
index b7eb893e..69d8d995 100644
--- a/src/addr2line.c
+++ b/src/addr2line.c
@@ -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));
}
}