From: Mark Wielaard Date: Tue, 27 Aug 2019 14:09:39 +0000 (+0200) Subject: readelf: Actually dump hex or strings when -p or -x get section number. X-Git-Tag: elfutils-0.178~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b9d343a8cbe14c2b2a3adebc962b2634a2be98a;p=thirdparty%2Felfutils.git 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 --- diff --git a/src/ChangeLog b/src/ChangeLog index cb64f7d91..a945c4292 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2019-08-27 Mark Wielaard + + * readelf.c (for_each_section_argument): Call (*dump) also for + section numbers. + 2019-08-26 Mark Wielaard * nm.c (show_symbols): Remember nentries_orig and check before diff --git a/src/readelf.c b/src/readelf.c index 24be7a9ad..77f9c3a34 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 69e43ca86..87c23102e 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2019-08-27 Mark Wielaard + + * run-readelf-test2.sh: Add -x num testcase. + 2019-08-29 Mark Wielaard * test-subr.sh (self_test_files_exe): replace elfcmp, objdump and diff --git a/tests/run-readelf-test2.sh b/tests/run-readelf-test2.sh index 903062473..e03ee8d76 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