readelf: Actually dump hex or strings when -p or -x get section number.
authorMark Wielaard <mark@klomp.org>
Tue, 27 Aug 2019 14:09:39 +0000 (16:09 +0200)
committerMark Wielaard <mark@klomp.org>
Thu, 29 Aug 2019 16:05:34 +0000 (18:05 +0200)
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
src/readelf.c
tests/ChangeLog
tests/run-readelf-test2.sh

index cb64f7d..a945c42 100644 (file)
@@ -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>
 
        * nm.c (show_symbols): Remember nentries_orig and check before
index 24be7a9..77f9c3a 100644 (file)
@@ -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
        {
index 69e43ca..87c2310 100644 (file)
@@ -1,3 +1,7 @@
+2019-08-27  Mark Wielaard  <mark@klomp.org>
+
+       * run-readelf-test2.sh: Add -x num testcase.
+
 2019-08-29  Mark Wielaard  <mark@klomp.org>
 
        * test-subr.sh (self_test_files_exe): replace elfcmp, objdump and
index 9030624..e03ee8d 100755 (executable)
@@ -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