[RFC, SCHEME_B 1/7] ld: sframe: emit function start addr as offset from FDE

Indu Bhagat indu.bhagat@oracle.com
Mon Apr 7 00:25:53 GMT 2025


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.

ChangeLog:

        * bfd/elf-sframe.c (_bfd_elf_merge_section_sframe): Adopt new
	semantics of function start address encoding.
---
 bfd/elf-sframe.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/bfd/elf-sframe.c b/bfd/elf-sframe.c
index 97e00734515..e5e4c09b72c 100644
--- 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);
+	      /* 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)));
 
 	      /* FIXME For testing only. Cleanup later.  */
 	      // address += (sec->output_section->vma);
-- 
2.43.0



More information about the Binutils mailing list