]> git.ipfire.org Git - thirdparty/elfutils.git/commit
readelf: Fix printing of DW_FORM_strx and DW_MACRO parsing
authorMark Wielaard <mark@klomp.org>
Sat, 4 May 2024 21:34:24 +0000 (23:34 +0200)
committerMark Wielaard <mark@klomp.org>
Tue, 14 May 2024 14:54:57 +0000 (16:54 +0200)
commit935ee131cf7c87296df9412b7e3370085e7c7508
treeab1a2480995fb980fac726fa2959511032869579
parent8e1ab679d6f3822e81de13a113336d94093b00f3
readelf: Fix printing of DW_FORM_strx and DW_MACRO parsing

print_form_data didn't take the offset_len (4 or 8 bytes) into account
causing the wrong entry to be read from .debug_str_offsets.
print_debug_macro_section did sanity checking before calling
print_form_data, which does sanity checking itself. The sanity check
for DW_FORM_strx was wrong in print_debug_macro_section (but correct
in print_form_data).

Add a new testfile for run-readelf-macro.sh, this one compiled with
clang -gdwarf-5 -fdebug-macro.

      * src/readelf.c (print_form_data): Multiply by offset_len for
      strx_val.
      (print_debug_macro_section): Remove sanity checks before calling
      print_form_data.
      * tests/testfileclangmacro.bz2: New testfile.
      * tests/Makefile.am (EXTRA_DIST): Add testfileclangmacro.bz2.
      * tests/run-readelf-macro.sh: Add testfileclangmacro output.

Signed-off-by: Mark Wielaard <mark@klomp.org>
src/readelf.c
tests/Makefile.am
tests/run-readelf-macro.sh
tests/testfileclangmacro.bz2 [new file with mode: 0755]