]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
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 cb64f7d91efcbfa1d1c0fbeff8e5f2946b8c8e21..a945c429203eeb81c9ca8eee32c9a3b71f17a1c1 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 24be7a9ad7ab74dfd865a1ed4becf9266ef717ea..77f9c3a34ffd07c97a5a427ab673b9da94543aff 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 69e43ca868b4001ea3954c429f35c430716a318f..87c23102e784e3a9535de1d1f255f2e2a18390a0 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 903062473adf9c3d440e15e2d9ad97146ee93131..e03ee8d762b0f40bcfea4ec9886ad41a890493db 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