This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH] readelf: Actually dump hex or strings when -p or -x get section number.
- From: Mark Wielaard <mark at klomp dot org>
- To: elfutils-devel at sourceware dot org
- Cc: Ben Woodard <woodard at redhat dot com>, Mark Wielaard <mark at klomp dot org>
- Date: Tue, 27 Aug 2019 16:12:35 +0200
- Subject: [PATCH] readelf: Actually dump hex or strings when -p or -x get section number.
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