[RFC, SCHEME_B 3/7] libsframe: process FDE function start addr before dumping

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


(This commit will be merged with a previous commit in the series:
 "objdump, readelf: sframe: apply relocations before textual dump".  It
remains a separate patch only to aid reviewing in this RFC series).

As SFrame sections on-disk and in-memory use the new semantics of
sfde_func_start_address encoding (i.e., function start address is the
offset from the sfde_func_start_address field to the start PC), the
calculation to make it human readable (i.e., relatable to the addresses
in .text sections) needs adjustment.

ChangeLog:

        * libsframe/sframe-dump.c (dump_sframe_func_with_fres): Adjust
	the function start address for dumping.
---
 libsframe/sframe-dump.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libsframe/sframe-dump.c b/libsframe/sframe-dump.c
index 1fa508d9bad..9f411a67a4a 100644
--- a/libsframe/sframe-dump.c
+++ b/libsframe/sframe-dump.c
@@ -130,7 +130,9 @@ dump_sframe_func_with_fres (sframe_decoder_ctx *sfd_ctx,
   sframe_decoder_get_funcdesc (sfd_ctx, funcidx, &num_fres,
 			       &func_size, &func_start_address, &func_info);
   /* Calculate the virtual memory address for function start pc.  */
-  func_start_pc_vma = func_start_address + sec_addr;
+  func_start_pc_vma = (func_start_address + sec_addr
+		       + sframe_decoder_get_hdr_size (sfd_ctx)
+		       + funcidx * sizeof (sframe_func_desc_entry));
 
   /* Mark FDEs with [m] where the FRE start address is interpreted as a
      mask.  */
-- 
2.43.0



More information about the Binutils mailing list