[PATCH] readelf: objdump: sframe: fix dumping with section name
Jan Beulich
jbeulich@suse.com
Mon Jul 21 05:46:43 GMT 2025
On 20.07.2025 07:34, Indu Bhagat via Binutils wrote:
> Fix PR binutils/33186 - No SFrame dump if section name is not .sframe
>
> When no section name is given, ensure that the dumping routines are able
> to dump a section of type SHT_GNU_SFRAME and not fail if the SFrame
> section name is not ".sframe".
>
> For objdump, in dump_dwarf_section (), use the match string of ".sframe"
> to find the corresponding debug_displays[] item for SFrame section.
> Doing this ensures that any call to dump_dwarf_section () with the
> section pointing to the SFrame section (with name possibly different
> from ".sframe") will successfully dump the SFrame section.
>
> If the SFrame section is named anything but ".sframe", the desirable
> behaviour is:
>
> $ readelf -S sort | grep sframe
> [NN] .sframe2 GNU_SFRAME 0000000000NNNNNN 0000NNNN
> $ objdump --sframe sort
>
> sort: file format elf64-x86-64
>
> No .sframe section present
>
> So, set dump_sframe_section_name to ".sframe" if user specifies no
> section name. In the error checking done in dump_sframe_section, add
> the case when user specifies a valid section name but one that does not
> contain SFrame section data.
>
> Similar changes in readelf.
>
> Add a test each for objdump and readelf to dump a renamed section. Use
> gas_sframe_check to limit the execution of these tests only when a gas
> supporting SFrame format is present.
>
> binutils/
> PR binutils/33186
> * objdump.c (dump_dwarf_section): Set match to ".sframe" which
> corresponds to the name in the debug_displays[] entry for
> SFrame section.
> (dump_sframe_section): Check if the user specified section name
> contains SFrame data.
> (main): Set default section name to ".sframe".
> * readelf.c (display_debug_section): Adjust checks to find the
> debug_diplay[] item for the input SFrame section in the arg.
> binutils/testsuite/
> PR binutils/33186
> * binutils-all/x86-64/objdump-sframe-01.d: New test.
> * binutils-all/x86-64/readelf-sframe-01.d: New test.
> * binutils-all/x86-64/sframe-func.s: New test.
>
> ----
>
> After the patch:
>
> $ objcopy --rename-section .sframe=.sframe2 sort
> $ $ readelf -S sort | grep sframe
> [NN] .sframe2 GNU_SFRAME 0000000000NNNNNN 0000NNNN
>
> $ readelf --sframe=.sframe sort
> readelf: Warning: Section '.sframe' was not dumped because it does not exist
> $ readelf --sframe sort
> readelf: Warning: Section '.sframe' was not dumped because it does not exist
Is this and ...
> $ readelf --sframe=.sframe2 sort
> Contents of the SFrame section .sframe2:
> Header :
>
> Version: SFRAME_VERSION_2
> ...
> $ readelf --sframe=.ctf sort
> Unrecognized debug section: .ctf
>
> $ objdump --sframe=.sframe sort
> No .sframe section present
> $ objdump --sframe sort
> No .sframe section present
... this really what is wanted? Shouldn't plain --sframe dump any GNU_SFRAME
sections, no matter what their names? (IOW there may want to be further test
cases covering the situation with more than one GNU_SFRAME section in an
object file.)
Jan
More information about the Binutils
mailing list