[PATCH, V3 5/9] objdump, readelf: sframe: apply relocations before textual dump

Jan Beulich jbeulich@suse.com
Fri Jun 13 12:20:48 GMT 2025


On 13.06.2025 09:32, Indu Bhagat wrote:
> PR libsframe/32589 - function start address is zero in SFrame section dump
> 
> Currently, readelf and objdump display the SFrame sections in ET_REL
> object files with function start addresses of each function as 0.  This
> makes it difficult to correlate SFrame stack trace information with the
> individual functions in the object file.
> 
> For objdump, use the dump_dwarf () interface to dump SFrame section.
> Similarly, for readelf, use the display_debug_section () interface to
> dump SFrame section.  These existing interfaces (for DWARF debug
> sections) already support relocating the section contents before
> dumping, so lets use them for SFrame sections as well.
> 
> When adding a new entry for SFrame in debug_option_table[], use char
> 'nil' and the option name of "sframe-internal-only".  This is done so
> that there is no additional (unnecessary) user-exposed ways of dumping
> SFrame sections.  Additionally, we explicitly disallow the
> "sframe-internal-only" from external/user input in --dwarf (objdump).
> Similarly, "sframe-internal-only" is explicitly matched and disallowed
> from --debug-dump (readelf).
> 
> For objdump and readelf, we continue to keep the same error messaging as
> earlier:
> 
>   $ objdump --sframe=sframe bubble_sort.o
>   ...
>   No sframe section present
> 
>   $ objdump --sframe=.sfram bubble_sort.o
>   ...
>   No .sfram section present
> 
>   $ objdump --sframe=sframe-internal-only sort
>   ...
>   No sframe-internal-only section present
> 
> Similarly for readelf:
> 
>   $ readelf --sframe= bubble_sort.o
>   readelf: Error: Section name must be provided
>   $ readelf --sframe=.sfram bubble_sort.o
>   readelf: Warning: Section '.sfram' was not dumped because it does not exist
>   $ readelf --sframe=sframe bubble_sort.o
>   readelf: Warning: Section 'sframe' was not dumped because it does not exist
> 
> PS: Note how this patch adds a new entry to debug_displays[] with a
>     relocate value set to FALSE.  This will be set to TRUE in a subsequent
>     patch ("bfd: gas: ld: libsframe: emit func start addr field as an offset
>     from FDE") when fixes are made to emit the value of the
>     'sfde_func_start_address' field in the new encoding
>     SFRAME_F_FDE_FUNC_START_ADDR_PCREL across gas and ld.
> 
> binutils/
> 	* dwarf.c (display_sframe): New definition.
> 	(dwarf_select_sections_all): Enable SFrame section too.
> 	(struct dwarf_section_display): Add entry for SFrame section.
> 	* dwarf.h (enum dwarf_section_display_enum): Add enumerator for
> 	SFrame.
> 	* objdump.c (dump_section_sframe): Remove.
> 	(dump_sframe_section): Add new definition.
> 	(dump_bfd): Use dump_sframe_section.
> 	* binutils/readelf.c (dump_section_as_sframe): Remove.
> ---
> This patch was previously reviewed at part of other series previously:
> https://inbox.sourceware.org/binutils/20250308073853.78738-3-indu.bhagat@oracle.com/
> 
> The review comments have been addressed in this patch.  The setting of
> relocate to FALSE for the new record is the new diff.
> 
>  { { ".sframe",            "",                      "",         NO_ABBREVS },      display_sframe,         &do_sframe,         false },
> 
> This is necessary to keep each patch in the series bisectable and reviewable.
> 
> [No changes in V3]
> [No changes in V2]
> ---
>  binutils/dwarf.c   | 35 +++++++++++++++++++++++++++
>  binutils/dwarf.h   |  1 +
>  binutils/objdump.c | 59 +++++++++++++++++-----------------------------
>  binutils/readelf.c | 50 ++++++++-------------------------------
>  4 files changed, 68 insertions(+), 77 deletions(-)

Okay.

Jan


More information about the Binutils mailing list