public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] addr2line: Use elf_getshdrstrndx not Ehdr field to print section name.
@ 2018-10-24 14:18 Mark Wielaard
  2018-10-26 22:16 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2018-10-24 14:18 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

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   | 5 +++++
 src/addr2line.c | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index bd6751a..5061cc1 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 b7eb893..69d8d99 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));
 		}
 	    }
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] addr2line: Use elf_getshdrstrndx not Ehdr field to print section name.
  2018-10-24 14:18 [PATCH] addr2line: Use elf_getshdrstrndx not Ehdr field to print section name Mark Wielaard
@ 2018-10-26 22:16 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2018-10-26 22:16 UTC (permalink / raw)
  To: elfutils-devel

On Wed, 2018-10-24 at 16:18 +0200, Mark Wielaard wrote:
> Using the Ehdr field directly doesn't work when there are a large
> number of sections.

Pushed to master.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-26 22:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-24 14:18 [PATCH] addr2line: Use elf_getshdrstrndx not Ehdr field to print section name Mark Wielaard
2018-10-26 22:16 ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).