[PATCH v5 1/2] ld: bfd: sframe: KEEP .sframe sections and support gc-sections
Jan Beulich
jbeulich@suse.com
Thu Jan 29 14:14:48 GMT 2026
On 27.01.2026 21:45, claudiu.zissulescu-ianculescu@oracle.com wrote:
> From: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
>
> 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.
Much better, thanks. Okay, with one nit in addition to Indu's:
> --- a/bfd/elf-sframe.c
> +++ b/bfd/elf-sframe.c
> @@ -245,13 +245,17 @@ _bfd_elf_parse_sframe (bfd *abfd,
> }
>
> if (sec->size == 0
> - || (sec->flags & SEC_HAS_CONTENTS) == 0
> - || sec->sec_info_type != SEC_INFO_TYPE_NONE)
> + || (sec->flags & SEC_HAS_CONTENTS) == 0)
> {
> /* This file does not contain .sframe information. */
> return false;
> }
>
> + /* Check if this section is already parsed. */
> + if (sec->sec_info_type == SEC_INFO_TYPE_SFRAME)
> + return true;
In the comment, "s/ is / was /" please
Jan
More information about the Binutils
mailing list