]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
objdump, readelf: sframe: apply relocations before textual dump
authorIndu Bhagat <indu.bhagat@oracle.com>
Mon, 26 May 2025 22:05:26 +0000 (15:05 -0700)
committerIndu Bhagat <indu.bhagat@oracle.com>
Wed, 25 Jun 2025 19:56:19 +0000 (12:56 -0700)
commit88e87ee94c83a05bf5b11010b7a9be43c3d2f81d
treee82ac84100cf5883bde5f54c9e40407663ef5094
parent8fabef0d1a7a932f1214c96ef391cb35d220049c
objdump, readelf: sframe: apply relocations before textual dump

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.

Notes:
  - V3 was OK'd https://sourceware.org/pipermail/binutils/2025-June/141796.html

[No changes in V4]
[No changes in V3]
[No changes in V2]
binutils/dwarf.c
binutils/dwarf.h
binutils/objdump.c
binutils/readelf.c