]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
include: libsframe: define new flag SFRAME_F_FDE_FUNC_START_ADDR_PCREL
authorIndu Bhagat <indu.bhagat@oracle.com>
Thu, 24 Apr 2025 21:59:56 +0000 (14:59 -0700)
committerIndu Bhagat <indu.bhagat@oracle.com>
Wed, 28 May 2025 04:58:14 +0000 (21:58 -0700)
Add a new flag SFRAME_F_FDE_FUNC_START_ADDR_PCREL to SFrame stack trace
format.  If set, this flag indicates that the function start address
field (sfde_func_start_address) is the offset to the function start
address from the SFrame FDE function start address field itself.

Such an encoding is friendlier to the exisitng PC-REL relocations
available in the ABIs supported in SFrame: AMD64 (R_X86_64_PC32) and
AArch64 (R_AARCH64_PREL32).  In subsequent patches, we will make the
implementation in gas and ld to both:
  - emit the values in the same (above-mentioned) encoding uniformly.
  - set the flag SFRAME_F_FDE_FUNC_START_ADDR_PCREL in the SFrame header
    for consumers to be able to distinguish.

include/
        * sframe.h (SFRAME_F_FDE_FUNC_START_ADDR_PCREL): New definition.
libsframe/
* sframe-dump.c (MAX_NUM_FLAGS, flags_helper): Update to include
the new flag.
* sframe.c (sframe_header_sanity_check_p): Use uint8_t.

include/sframe.h
libsframe/sframe-dump.c
libsframe/sframe.c

index a965e23bdd1817e4eef513bd126de0f6f542de18..9f5d0e78e89574d5202d341b761e35061c9db15b 100644 (file)
@@ -82,9 +82,15 @@ extern "C"
 /* Various flags for SFrame.  */
 
 /* Function Descriptor Entries are sorted on PC.  */
-#define SFRAME_F_FDE_SORTED    0x1
+#define SFRAME_F_FDE_SORTED                0x1
 /* Functions preserve frame pointer.  */
-#define SFRAME_F_FRAME_POINTER 0x2
+#define SFRAME_F_FRAME_POINTER             (0x1 << 1)
+/* Function start address in SFrame FDE is encoded as the distance from the
+   location of the sfde_func_start_address to the start PC of the function.
+   If absent, the function start address in SFrame FDE is encoded as the
+   distance from the start of the SFrame FDE section to the start PC of the
+   function.  */
+#define SFRAME_F_FDE_FUNC_START_ADDR_PCREL  (0x1 << 2)
 
 #define SFRAME_CFA_FIXED_FP_INVALID 0
 #define SFRAME_CFA_FIXED_RA_INVALID 0
index d6f838d4fc099239ea1d2a199d5fed3c1d345d8b..200530ffeb96847b2c8efa8cfae7c03d77b91eb3 100644 (file)
@@ -61,10 +61,11 @@ dump_sframe_header_flags (sframe_decoder_ctx *sfd_ctx)
   /* PS: Keep SFRAME_FLAGS_STR_MAX_LEN in sync if adding more members to
      this array.  */
 #define SFRAME_FLAGS_STR_MAX_LEN 50
-#define MAX_NUM_FLAGS 2
+#define MAX_NUM_FLAGS 3
   const struct dump_flags_helper flags_helper[MAX_NUM_FLAGS] = {
       { SFRAME_F_FDE_SORTED, "SFRAME_F_FDE_SORTED"},
-      { SFRAME_F_FRAME_POINTER, "SFRAME_F_FRAME_POINTER"}
+      { SFRAME_F_FRAME_POINTER, "SFRAME_F_FRAME_POINTER"},
+      { SFRAME_F_FDE_FUNC_START_ADDR_PCREL, "SFRAME_F_FDE_FUNC_START_ADDR_PCREL"}
   };
 
   /* Prepare SFrame section flags string.  */
index 8e9990058b6b2b8f5036d2505ca5ad6c893a92ab..4de4151d0b297e3d0b581f0b81aa9ca43c913d92 100644 (file)
@@ -204,7 +204,8 @@ flip_fde (sframe_func_desc_entry *fdep)
 static bool
 sframe_header_sanity_check_p (sframe_header *hp)
 {
-  unsigned char all_flags = SFRAME_F_FDE_SORTED | SFRAME_F_FRAME_POINTER;
+  uint8_t all_flags = (SFRAME_F_FDE_SORTED | SFRAME_F_FRAME_POINTER
+                      | SFRAME_F_FDE_FUNC_START_ADDR_PCREL);
   /* Check preamble is valid.  */
   if (hp->sfh_preamble.sfp_magic != SFRAME_MAGIC
       || (hp->sfh_preamble.sfp_version != SFRAME_VERSION_1