[PATCH 3/3] bfd: x86: sframe: additonal check in _bfd_x86_elf_link_setup_gnu_properties
Jens Remus
jremus@linux.ibm.com
Mon Jan 12 15:43:26 GMT 2026
On 1/12/2026 11:53 AM, claudiu.zissulescu-ianculescu--- via Binutils wrote:
> From: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
>
> GNU ld creates SFrame stack trace info for the .plt* sections. These
> linker created sections are created in
> _bfd_x86_elf_link_setup_gnu_properties (), but data is emitted into
> them a bit later in _bfd_x86_elf_late_size_sections ().
What is the plan regarding s390x (AArch64 AFAIK does not emit .sframe
for PLT)?
>
> With SFrame sections now marked KEEP in scripttempl/elf.sc, and the
> presence of these linker created SFrame sections cause emission of an
> empty .sframe for all ELF targets (IIUC), even when all input bfd's
> have no .sframe section. This patch is avoiding creation of empty
> .sframe in linked objects on x86_64, when none of the inputs had
> SFrame sections.
>
> bfd/
>
> * elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Emit
> sframe section only when required.
>
> Co-authored-by: Indu Bhagat <indu.bhagat@oracle.com>
> Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
> diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
> @@ -4834,8 +4834,30 @@ _bfd_x86_elf_link_setup_gnu_properties
> }
> }
>
> + bool gen_plt_sframe_p = false;
> /* .sframe sections are emitted for AMD64 ABI only. */
> if (ABI_64_P (info->output_bfd) && !info->no_ld_generated_unwind_info)
> + {
> + /* Find in any input file has an .sframe section. */
> + for (pbfd = info->input_bfds; pbfd != NULL; pbfd = pbfd->link.next)
> + if (bfd_get_flavour (pbfd) == bfd_target_elf_flavour
> + && bfd_count_sections (pbfd) != 0)
> + {
> + asection *sfsec = bfd_get_section_by_name (pbfd, ".sframe");
This tests for the existence of a section with name ".sframe". Would it
make sense to test for any section of type SHT_GNU_SFRAME instead?
> + if (sfsec != NULL)
> + {
> + gen_plt_sframe_p = true;
> + break;
> + }
> + }
> + }
> +
> + /* Do not make SFrame sections for dynobj unconditionally. If there
> + are no SFrame sections for any input files, skip creating the linker
> + created SFrame sections too. Since SFrame sections are marked KEEP,
> + prohibiting these linker-created SFrame sections when unnecessary,
> + helps avoid creating of empty SFrame sections in the output. */
> + if (gen_plt_sframe_p)
> {
> flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
> | SEC_HAS_CONTENTS | SEC_IN_MEMORY
Thanks and regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
jremus@de.ibm.com / jremus@linux.ibm.com
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Ehningen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
More information about the Binutils
mailing list