[PATCH v2 2/3] sframe: additonal check in _bfd_x86_elf_link_setup_gnu_properties

Claudiu Zissulescu-Ianculescu claudiu.zissulescu-ianculescu@oracle.com
Wed Jan 14 10:57:35 GMT 2026


Hi Jens,

Please also test this patch series in your setup.

>> This patch is an attempt to avoid creation of empty .sframe in linked
>> objects on x86_64 and s390x, when none of the inputs had SFrame sections.
> 
> Thanks for taking care of s390x!  _bfd_elf_sframe_present_input_bfds is
> also a neat improvement.
> 
> Nit: Reword the commit subject to e.g.:
> 
> ld: sframe: do not generate .sframe for PLT if no .sframe in input BFDs

Will do.

>> +      bool gen_plt_sframe_p = false;
>>        /* Create .sframe section for .plt section.  */
>>        if (!info->no_ld_generated_unwind_info)
>> +	gen_plt_sframe_p = _bfd_elf_sframe_present_input_bfds (info);
>> +
>> +      /* 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)
>>  	{
> 
> I am not familiar with coding style, but that looks kind of odd to me.
> What about the following?  Maybe with the comment right before the
> gen_plt_sframe_p definition?
> 
>       bool gen_plt_sframe_p = !info->no_ld_generated_unwind_info
>                               && _bfd_elf_sframe_present_input_bfds (info);
>       if (gen_plt_sframe_p)
> 	{
> 
>

AFAIK, both are accepted. I'll add this in the next round.

>>  	  flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
>>  			    | SEC_HAS_CONTENTS | SEC_IN_MEMORY
>> diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
>> index 36ba7919f47..13a2f3bc10f 100644
>> --- a/bfd/elfxx-x86.c
>> +++ b/bfd/elfxx-x86.c
>> @@ -4834,8 +4834,17 @@ _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)
>> +	gen_plt_sframe_p = _bfd_elf_sframe_present_input_bfds (info);
>> +
>> +      /* 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 creation of empty SFrame sections in the output.  */
>> +      if (gen_plt_sframe_p)
>>  	{
> 
> Likewise:
> 
>       bool gen_plt_sframe_p = ABI_64_P (info->output_bfd)
>                               && !info->no_ld_generated_unwind_info
>                               && _bfd_elf_sframe_present_input_bfds (info);
>       if (gen_plt_sframe_p)
> 	{
> 
>>  	  flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
>>  			    | SEC_HAS_CONTENTS | SEC_IN_MEMORY


Best,
Claudiu


More information about the Binutils mailing list