]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
ld: bfd: sframe: KEEP .sframe sections and support gc-sections
authorClaudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
Fri, 30 Jan 2026 07:27:47 +0000 (23:27 -0800)
committerIndu Bhagat <indu.bhagat@oracle.com>
Fri, 30 Jan 2026 07:27:47 +0000 (23:27 -0800)
commit4b5ff658b4993fae1f347793bddd5c14b76167cd
tree59ee638067c3bdc1c0cd64484c1b07510c3eae66
parent4edeb9be08afae397e6c0dd1a57399b18ca29e35
ld: bfd: sframe: KEEP .sframe sections and support gc-sections

Fix PR ld/32769

Currently, specifying --gc-sections causes the linker to discard all
input .sframe sections.  Fix this behaviour by adding KEEP for .sframe
sections, like it is being done for .eh_frame sections, in the default
ELF linker script.

Additionally, add logic in the linker to gc mark .sframe sections.
_bfd_elf_gc_mark () now is aware of SFrame sections. It relies on
elf_section_sframe () to get the SFrame section associated with the
text section.

Also, the _bfd_elf_parse_sframe is changed to return TRUE when the
input sframe section is already parsed. It fixes calling
_bfd_elf_discard_section_sframe function in bfd_elf_discard_info,
enabling correct behavior for discarding unneeded sframe sections.

ld/
PR ld/32769
* scripttempl/elf.sc: KEEP .sframe sections.
bfd/
* elf-bfd.h (struct elf_obj_tdata): Add sframe section pointer.
(elf_sframe_section): New macro.
* elflink.c (_bfd_elf_gc_mark): Handle SFrame sections.
(bfd_elf_gc_sections): Likewise.
(bfd_elf_discard_info): Update for handling gc operations.
* elf-sframe.c (_bfd_elf_parse_sframe): Return TRUE for already
parsed sframe sections.

Co-authored-by: Indu Bhagat <indu.bhagat@oracle.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
bfd/elf-bfd.h
bfd/elf-sframe.c
bfd/elflink.c
ld/scripttempl/elf.sc