[PATCH 1/2] libsframe: add new dump_sframe_reloc
Jens Remus
jremus@linux.ibm.com
Mon Feb 24 14:45:20 GMT 2025
On 24.02.2025 14:51, Jens Remus wrote:
> On 23.02.2025 01:56, Indu Bhagat wrote:
>> On 2/21/25 8:21 AM, Jens Remus wrote:
...
>>> /* Start address of the function. */
>>> exp.X_op = O_subtract;
>>> exp.X_add_symbol = dw_fde_start_addrS; /* to location. */
>>> exp.X_op_symbol = symbol_temp_new_now (); /* from location. */
>>> exp.X_add_number = 0;
>>> emit_expr (&exp, addr_size);
>
> Doesn't that mean that in the object file the FDE sfde_func_start_address
> (when taking its relocation into account) is relative to the FDE and in
> an executable or shared library (after final link) it is relative to the
> .sframe section?
>
> I think this should be mentioned in the SFrame documentation for
> sfde_func_start_address, as that is unexpected given the current
> description.
>
>
> The following reduced excerpt from _bfd_elf_merge_section_sframe() seems
> to apply the respective fixup when merging the .sframe sections:
>
> /* Get the SFrame FDE function start address after relocation. */
> address = sframe_read_value (abfd, contents, r_offset, 4);
> address += (sec->output_offset + r_offset);
> func_start_addr = address;
>
> r_offset is the FDE offset within the input .sframe section and
> sec->output_offset the offset of the input .sframe section within
> the output .sframe section. So sec->output_offset + r_offset is
> equivalent to the FDE offset from (output) .sframe section.
>
> func_start_addr
> = S + A - P + offset(FDE)
> = addr(.text) + offset(function) - (addr(.sframe) + offset(FDE)) + offset(FDE)
> = addr(.text) + offset(function)
That was wrong and must be:
func_start_addr
= S + A - P + offset(FDE)
= addr(.text) + offset(function) - (addr(.sframe) + offset(FDE)) + offset(FDE)
= addr(.text) + offset(function) - addr(.sframe)
Which is the offset to the function from the .sframe section.
Regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
+49-7031-16-1128 Office
jremus@de.ibm.com
IBM
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
More information about the Binutils
mailing list