[RFC, SCHEME_B 1/7] ld: sframe: emit function start addr as offset from FDE
Indu Bhagat
indu.bhagat@oracle.com
Tue Apr 8 02:38:05 GMT 2025
On 4/7/25 9:10 AM, Jens Remus wrote:
> On 07.04.2025 02:25, Indu Bhagat wrote:
>> Adopt the new semantics of sfde_func_start_address consistently. For
>> ld, this means even the in-memory contents of the FDE function start
>> address (buffer passed to libsframe sframe_encoder_write () for writing
>> out) are encoded in the new semantics.
>
>> diff --git a/bfd/elf-sframe.c b/bfd/elf-sframe.c
>
>> @@ -481,6 +481,13 @@ _bfd_elf_merge_section_sframe (bfd *abfd,
>> address += sframe_read_value (abfd, contents,
>> pltn_r_offset, 4);
>> address += (sec->output_offset + r_offset);
>
> It took me a while to understand why above does not get canceled out
> by below and does not naturally fall into place if both were removed.
> After all the SFrame FDE function start address field value should
> now already be an offset to the function from the field itself.
> IIUC address is an offset relative to the FDE in the "imaginary"
> output .sframe section, as the linker assumes it to be, that is the
> sections simply concatenated together, with alignment padding added
> between concatenated input sections if needed. Above makes address
> an offset relative to the output .sframe section, which effectively
> "removes" this "imaginary" linker view from the value. Below then
> makes it relative to the FDE of the planned output .sframe section,
> as SFrame assumes it to be (prior to sorting of the FDEs), that is
> one single header followed by all FDEs, followed by all FREs.
>
> Is that correct?
>
Yes.
I will update some code comments in this function to help understand
some of this.
Thanks
>> + /* SFrame FDE function start address is an offset from the
>> + sfde_func_start_address field to the start PC. The
>> + calculation below is the distance of sfde_func_start_address
>> + field from the start of the output SFrame section. */
>> + address -= (sframe_encoder_get_hdr_size (sfe_ctx)
>> + + ((cur_fidx + num_enc_fidx) /* FDE index. */
>> + * sizeof (sframe_func_desc_entry)));
>
> Thanks and regards,
> Jens
More information about the Binutils
mailing list