[PATCH 3/3] bfd: x86: sframe: additonal check in _bfd_x86_elf_link_setup_gnu_properties

Claudiu Zissulescu claudiu.zissulescu-ianculescu@oracle.com
Tue Jan 13 10:11:10 GMT 2026


Hi,

On 1/12/26 5:43 PM, Jens Remus wrote:
> 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)?

I see Indu has a patch regarding that. I can include it in the next 
iteration. However, I need to ask you for proper testing and final 
touches as I do not have the means to do so for s390x.

> 
>>
>> 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?

It makes sense, I'll come back to you with the above fixes.

Best regards,
Claudiu


More information about the Binutils mailing list