[RFC,SCHEME_B 4/7] ld: bfd: sframe: fix incorrect r_offset in RELA entries

Jan Beulich jbeulich@suse.com
Mon Apr 7 15:02:38 GMT 2025


On 07.04.2025 02:25, Indu Bhagat wrote:
> --- a/bfd/elflink.c
> +++ b/bfd/elflink.c
> @@ -11974,7 +11974,11 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
>  		      continue;
>  		    }
>  
> -		  irela->r_offset += o->output_offset;
> +		  /* All SFrame FDEs from input sections are clubbed together
> +		     in the beginning of the output section.  RELA offsets are
> +		     already up to date.  PR ld/32666.  */
> +		  if (o->sec_info_type != SEC_INFO_TYPE_SFRAME)
> +		    irela->r_offset += o->output_offset;

I'm irritated by there still being such special casing here. You go to some
lengths in the description to explain this, but I fear I'm still not groking
it even after reading multiple times. In particular the absence of any special
casing here for SHF_MERGE sections makes we wonder why your content re-ordering
is requiring such.

To at least hide it from here, wouldn't it be possible to have
_bfd_elf_sframe_section_offset() do the "inverse" adjustment, for that to be
"undone" here? (For this it may help to remove the early return from the
function - the sole caller ensures it's the right type.)

Jan


More information about the Binutils mailing list