]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
readelf/objdump: Dump SFrame CFA fixed FP and RA offsets
authorJens Remus <jremus@linux.ibm.com>
Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)
committerJens Remus <jremus@linux.ibm.com>
Thu, 4 Jul 2024 08:34:12 +0000 (10:34 +0200)
The SFrame format allows architectures to specify fixed offsets from the
CFA, if any, from which the frame pointer (FP) and/or return address
(RA) may be recovered. These offsets are stored in the SFrame header.

For instance the SFrame generation in the assembler for x86 AMD64
specifies a fixed offset from the CFA, from which the return address
(RA) may be recovered.

When dumping the SFrame header, for instance in readelf/objdump with
option --sframe, do also dump the specified fixed offsets from the CFA,
if any, from which the frame pointer (FP) and return address (RA) may
be recovered.

Update the common SFrame test case verification patterns to allow for
the optional dumping of the CFA fixed FP/RA offsets. Update the x86-
specific SFrame and SCFI test case verification patterns to require a
CFA fixed RA offset of -8.

libsframe/
* sframe-dump.c: Dump CFA fixed FP and RA offsets.

gas/testsuite/
* gas/cfi-sframe/cfi-sframe-common-1.d: Test for optional fixed
FP and RA offsets.
* gas/cfi-sframe/cfi-sframe-common-2.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-3.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-4.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-5.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-6.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-7.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-8.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-1.d: Test for fixed
RA offset.
* gas/cfi-sframe/common-empty-1.d: Test for optional fixed
FP and RA offsets.
* gas/cfi-sframe/common-empty-2.d: Likewise.
* gas/cfi-sframe/common-empty-3.d: Likewise.
* gas/scfi/x86_64/scfi-cfi-sections-1.d: Test for SFrame fixed
RA offset.
* gas/scfi/x86_64/scfi-dyn-stack-1.d: Likewise.

ld/testsuite/
* ld-x86-64/sframe-plt-1.d: Test for SFrame fixed RA offset.
* ld-x86-64/sframe-simple-1.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
17 files changed:
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-1.d
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-2.d
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-3.d
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-4.d
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-5.d
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-6.d
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-7.d
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-8.d
gas/testsuite/gas/cfi-sframe/cfi-sframe-x86_64-1.d
gas/testsuite/gas/cfi-sframe/common-empty-1.d
gas/testsuite/gas/cfi-sframe/common-empty-2.d
gas/testsuite/gas/cfi-sframe/common-empty-3.d
gas/testsuite/gas/scfi/x86_64/scfi-cfi-sections-1.d
gas/testsuite/gas/scfi/x86_64/scfi-dyn-stack-1.d
ld/testsuite/ld-x86-64/sframe-plt-1.d
ld/testsuite/ld-x86-64/sframe-simple-1.d
libsframe/sframe-dump.c

index 32577f31860eef52eb8f5f63c91a85332755eb8f..5f4ae00747deefdce2f69490e9672fc3275ef1be 100644 (file)
@@ -8,6 +8,8 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+#?    CFA fixed FP offset: \-?\d+
+#?    CFA fixed RA offset: \-?\d+
     Num FDEs: 1
     Num FREs: 1
 
index 3e3f74dbe4240b30fec372c2e40975622845b352..ded8c450a94281d9a5638256be8d4187510cef06 100644 (file)
@@ -8,6 +8,8 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+#?    CFA fixed FP offset: \-?\d+
+#?    CFA fixed RA offset: \-?\d+
     Num FDEs: 1
     Num FREs: 1
 
index 6430d463a891bf841b27a221b897c29df7e99882..d23fd9790f631197ea2c2c9af86bef922b2e5172 100644 (file)
@@ -8,6 +8,8 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+#?    CFA fixed FP offset: \-?\d+
+#?    CFA fixed RA offset: \-?\d+
     Num FDEs: 1
     Num FREs: 1
 
index 319ff96cce2a67aac0859891f8c2a3878a530216..ca559bd0a029179ed20b50c8fd76041e0147ca4e 100644 (file)
@@ -8,6 +8,8 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+#?    CFA fixed FP offset: \-?\d+
+#?    CFA fixed RA offset: \-?\d+
     Num FDEs: 1
     Num FREs: 3
 
index 82d34973dddecb42892deea9ee0b8a6b5b62c2de..ee82053e13db9ab4f3d03135e6db6008e1b646c8 100644 (file)
@@ -8,6 +8,8 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+#?    CFA fixed FP offset: \-?\d+
+#?    CFA fixed RA offset: \-?\d+
     Num FDEs: 1
     Num FREs: 3
 
index fe6917c70800a89a7f7ccbfb4edb18e250a43d32..9d54b98552bfac4067d52f494caf645ca558ea64 100644 (file)
@@ -8,6 +8,8 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+#?    CFA fixed FP offset: \-?\d+
+#?    CFA fixed RA offset: \-?\d+
     Num FDEs: 1
     Num FREs: 3
 
index 39724d9cdf198f94a6d74a48e101e93fbbc05661..2b7fe3aec8f49b1f3afeb4b3ae96a2c432e0ea98 100644 (file)
@@ -8,6 +8,8 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+#?    CFA fixed FP offset: \-?\d+
+#?    CFA fixed RA offset: \-?\d+
     Num FDEs: 1
     Num FREs: 3
 
index c0a0e627fad931e2ec35afc719f9d41cf388d7ff..d654e1d0bcd4b25e713c41bba65b18f51769126f 100644 (file)
@@ -8,6 +8,8 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+#?    CFA fixed FP offset: \-?\d+
+#?    CFA fixed RA offset: \-?\d+
     Num FDEs: 1
     Num FREs: 2
 
index ae36c21b3b7c12b8680deabcef94b2fba6559151..c8b5e6adfea038ccdb532b724855b3740cf82c6e 100644 (file)
@@ -8,6 +8,7 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+    CFA fixed RA offset: \-8
     Num FDEs: 1
     Num FREs: 4
 
index b133b15b051d50ff294d374bdc335b6001f2053d..125612ff841f4b2b3c6f257589abc1b81066a409 100644 (file)
@@ -9,6 +9,8 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+#?    CFA fixed FP offset: \-?\d+
+#?    CFA fixed RA offset: \-?\d+
     Num FDEs: 0
     Num FREs: 0
 
index c5bc8594f1b7152414b6a73877b9e808053e2b4c..59328fc1033f7e97d8eaf900959532082da309ff 100644 (file)
@@ -9,6 +9,8 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+#?    CFA fixed FP offset: \-?\d+
+#?    CFA fixed RA offset: \-?\d+
     Num FDEs: 0
     Num FREs: 0
 
index df0b19ee1bd13aad299f92b46d3098c65987b003..5914c620760dc00a424e68526fe5fc5a6c658694 100644 (file)
@@ -8,6 +8,8 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+#?    CFA fixed FP offset: \-?\d+
+#?    CFA fixed RA offset: \-?\d+
     Num FDEs: 0
     Num FREs: 0
 
index 5962980256c1cef4f41c0c63e84e9cd661f95418..c45933b72edc96a5bade25837fa0d96066e0d653 100644 (file)
@@ -8,6 +8,7 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+    CFA fixed RA offset: \-8
     Num FDEs: 1
     Num FREs: 5
 
index b51546af1494a7b3af5aa59e53ebf7a90a433241..6cd0484d57934328390e23041bb39ed391362e73 100644 (file)
@@ -9,6 +9,7 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: NONE
+    CFA fixed RA offset: \-8
     Num FDEs: 1
     Num FREs: 4
 
index ca82cf20ca91eca5c30713192a57413e7a5051d5..6aea5f424690b7f21d9b6384b63b8281ec375c40 100644 (file)
@@ -12,6 +12,7 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: SFRAME_F_FDE_SORTED
+    CFA fixed RA offset: \-8
 #...
 
   Function Index :
index adc4b74193077986fc2de229f8f29e338d805baa..5ffd0ca78187fc5d98504fead90222d59e876aa2 100644 (file)
@@ -12,6 +12,7 @@ Contents of the SFrame section .sframe:
 
     Version: SFRAME_VERSION_2
     Flags: SFRAME_F_FDE_SORTED
+    CFA fixed RA offset: \-8
 #...
 
   Function Index :
index 42a086a5691fcfc32fb3754780ceaf9a24937d78..493d052ce91fe9dbf71914697b29b38514fef5ef 100644 (file)
@@ -47,6 +47,8 @@ dump_sframe_header (sframe_decoder_ctx *sfd_ctx)
   uint8_t flags;
   char *flags_str;
   const char *ver_str = NULL;
+  int8_t cfa_fixed_fp_offset;
+  int8_t cfa_fixed_ra_offset;
   const sframe_header *header = &(sfd_ctx->sfd_header);
 
   /* Prepare SFrame section version string.  */
@@ -82,12 +84,20 @@ dump_sframe_header (sframe_decoder_ctx *sfd_ctx)
   else
     strcpy (flags_str, "NONE");
 
+  /* CFA fixed FP and RA offsets.  */
+  cfa_fixed_fp_offset = header->sfh_cfa_fixed_fp_offset;
+  cfa_fixed_ra_offset = header->sfh_cfa_fixed_ra_offset;
+
   const char* subsec_name = "Header";
   printf ("\n");
   printf ("  %s :\n", subsec_name);
   printf ("\n");
   printf ("    Version: %s\n", ver_str);
   printf ("    Flags: %s\n", flags_str);
+  if (cfa_fixed_fp_offset != SFRAME_CFA_FIXED_FP_INVALID)
+    printf ("    CFA fixed FP offset: %d\n", cfa_fixed_fp_offset);
+  if (cfa_fixed_ra_offset != SFRAME_CFA_FIXED_RA_INVALID)
+    printf ("    CFA fixed RA offset: %d\n", cfa_fixed_ra_offset);
   printf ("    Num FDEs: %d\n", sframe_decoder_get_num_fidx (sfd_ctx));
   printf ("    Num FREs: %d\n", header->sfh_num_fres);