[PATCH,V4 7/9] ld: bfd: sframe: fix incorrect r_offset in RELA entries

Indu Bhagat indu.bhagat@oracle.com
Mon Jun 30 07:13:19 GMT 2025


On 6/27/25 12:56 AM, Jan Beulich wrote:
> On 19.06.2025 08:24, Indu Bhagat wrote:
>> +/* Adjust an address in the .sframe section.  Given OFFSET within
>> +   SEC, this returns the new offset in the merged .sframe section,
>> +   or -1 if the address refers to an FDE which has been removed.
>> +
>> +   PS: This function assumes that _bfd_elf_merge_section_sframe has
>> +   not been called on the input section SEC yet.  Note how it uses
>> +   sframe_encoder_get_num_fidx () to figure out the offset of FDE
>> +   in the output section.  */
>> +
>> +bfd_vma
>> +_bfd_elf_sframe_section_offset (bfd *output_bfd ATTRIBUTE_UNUSED,
>> +				struct bfd_link_info *info,
>> +				asection *sec,
>> +				bfd_vma offset)
>> +{
>> +  struct sframe_dec_info *sfd_info;
>> +  struct sframe_enc_info *sfe_info;
>> +  sframe_decoder_ctx *sfd_ctx;
>> +  sframe_encoder_ctx *sfe_ctx;
>> +  struct elf_link_hash_table *htab;
>> +
>> +  unsigned int sec_fde_idx, out_num_fdes;
>> +  unsigned int sfd_num_fdes, sfe_num_fdes;
>> +  uint32_t sfd_fde_offset;
>> +  bfd_vma new_offset;
>> +
>> +  if (sec->sec_info_type != SEC_INFO_TYPE_SFRAME)
>> +    return offset;
>> +
>> +  sfd_info = (struct sframe_dec_info *) elf_section_data (sec)->sec_info;
> 
> Oh, actually, one cosmetic thing: Looks like this cast isn't really needed.
> Please generally omit casts when they're not needed. Yes, there are still
> very many of them in the code base, but quite often they're simply leftovers
> from long gone K&R days.
> 

Okay.



More information about the Binutils mailing list