public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] readelf: Actually dump hex or strings when -p or -x get section number.
@ 2019-08-27 14:12 Mark Wielaard
  2019-08-29 16:09 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2019-08-27 14:12 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Ben Woodard, Mark Wielaard

The readelf code did parse section numbers, but then failed to actually
dump the section found. Fixed by actually calling the dump function
(either the hex or string variant). Add testcase for readelf -x num.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 src/ChangeLog              | 5 +++++
 src/readelf.c              | 1 +
 tests/ChangeLog            | 4 ++++
 tests/run-readelf-test2.sh | 7 +++++++
 4 files changed, 17 insertions(+)

diff --git a/src/ChangeLog b/src/ChangeLog
index ad673c11..78a63e48 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2019-08-27  Mark Wielaard  <mark@klomp.org>
+
+	* readelf.c (for_each_section_argument): Call (*dump) also for
+	section numbers.
+
 2019-08-26  Mark Wielaard  <mark@klomp.org>
 
 	* readelf (options): Add OPTION_ARG_OPTIONAL "SECTION" for notes.
diff --git a/src/readelf.c b/src/readelf.c
index 24be7a9a..77f9c3a3 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -12634,6 +12634,7 @@ for_each_section_argument (Elf *elf, const struct section_argument *list,
 	    error (EXIT_FAILURE, 0, gettext ("cannot get section header: %s"),
 		   elf_errmsg (-1));
 	  name = elf_strptr (elf, shstrndx, shdr_mem.sh_name);
+	  (*dump) (scn, &shdr_mem, name);
 	}
       else
 	{
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 2900bd82..cb336d68 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2019-08-27  Mark Wielaard  <mark@klomp.org>
+
+	* run-readelf-test2.sh: Add -x num testcase.
+
 2019-07-26  Florian Weimer  <fweimer@redhat.com>
 	    Mark Wielaard  <mark@klomp.org>
 
diff --git a/tests/run-readelf-test2.sh b/tests/run-readelf-test2.sh
index 90306247..e03ee8d7 100755
--- a/tests/run-readelf-test2.sh
+++ b/tests/run-readelf-test2.sh
@@ -25,4 +25,11 @@ Hex dump of section [6] '.strtab', 1 bytes at offset 0x290:
   0x00000000 00                                  .
 EOF
 
+testrun_compare ${abs_top_builddir}/src/readelf -x 6 testfile28 <<\EOF
+
+Hex dump of section [6] '.strtab', 1 bytes at offset 0x290:
+  0x00000000 00                                  .
+EOF
+
+
 exit 0
-- 
2.18.1

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

* Re: [PATCH] readelf: Actually dump hex or strings when -p or -x get section number.
  2019-08-27 14:12 [PATCH] readelf: Actually dump hex or strings when -p or -x get section number Mark Wielaard
@ 2019-08-29 16:09 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2019-08-29 16:09 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Ben Woodard

On Tue, Aug 27, 2019 at 04:12:35PM +0200, Mark Wielaard wrote:
> The readelf code did parse section numbers, but then failed to actually
> dump the section found. Fixed by actually calling the dump function
> (either the hex or string variant). Add testcase for readelf -x num.

Pushed to master.

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

end of thread, other threads:[~2019-08-29 16:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27 14:12 [PATCH] readelf: Actually dump hex or strings when -p or -x get section number Mark Wielaard
2019-08-29 16:09 ` 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).