public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/6] SFrame: support for .cfi_negate_ra_state in aarch64
@ 2022-12-14 19:58 Indu Bhagat
  2022-12-14 19:58 ` [PATCH 1/6] [1/6] sframe.h: add support for .cfi_negate_ra_state Indu Bhagat
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Indu Bhagat @ 2022-12-14 19:58 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

Hello,

This patchset adds support for handling .cfi_negate_ra_state assembler
directive for SFrame information generation on aarch64. Without this support,
the .cfi_negate_ra_state directive was being ignored: no SFrame unwind
information was being generated for those code regions (bounded by the
.cfi_startproc/.cfi_endproc) that contained a .cfi_negate_ra_state directive.

The support is split in small patches to hopefully ease the review.

In a follow up patch series, support for .cfi_b_key_frame will be added.

Testing notes:
- Regression tested cross build of several targets on an x86_64 host and an
aarch64 host using a regression script that checks for failures in gas, ld,
binutils, libctf and libsframe.
- Regression tested native builds on x86_64 and aarch64.
- binutils/gdb try bot showed no new regressions.

Thanks,

Indu Bhagat (6):
  [1/6] sframe.h: add support for .cfi_negate_ra_state
  [2/6] gas: sframe: add support for .cfi_negate_ra_state
  [3/6] gas: sframe: testsuite: add testcase for .cfi_negate_ra_state
  [4/6] libsframe: provide new access API for mangled RA bit
  [5/6] objdump/readelf: sframe: emit marker for FREs with mangled RA
  [6/6] sframe: doc: update spec for the mangled-RA bit in FRE

 gas/gen-sframe.c                              | 41 +++++++++++++++----
 gas/gen-sframe.h                              |  6 ++-
 .../gas/cfi-sframe/cfi-sframe-aarch64-2.d     | 20 +++++++++
 ...ommon-empty-4.s => cfi-sframe-aarch64-2.s} |  3 +-
 gas/testsuite/gas/cfi-sframe/cfi-sframe.exp   |  2 +-
 gas/testsuite/gas/cfi-sframe/common-empty-4.d | 14 -------
 include/sframe-api.h                          |  7 ++++
 include/sframe.h                              | 23 +++++++----
 libsframe/doc/sframe-spec.texi                |  4 +-
 libsframe/sframe-dump.c                       | 13 ++++--
 libsframe/sframe.c                            | 18 ++++++++
 11 files changed, 113 insertions(+), 38 deletions(-)
 create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.d
 rename gas/testsuite/gas/cfi-sframe/{common-empty-4.s => cfi-sframe-aarch64-2.s} (85%)
 delete mode 100644 gas/testsuite/gas/cfi-sframe/common-empty-4.d

-- 
2.37.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/6] [1/6] sframe.h: add support for .cfi_negate_ra_state
  2022-12-14 19:58 [PATCH 0/6] SFrame: support for .cfi_negate_ra_state in aarch64 Indu Bhagat
@ 2022-12-14 19:58 ` Indu Bhagat
  2022-12-14 19:58 ` [PATCH 2/6] [2/6] gas: sframe: " Indu Bhagat
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Indu Bhagat @ 2022-12-14 19:58 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

Use the last remaining bit in the 'SFrame FRE info' word to store whether
the RA is signed/unsigned with PAC authorization code: this bit is named
as the "mangled RA" bit.  This bit is still unused for x86-64.

The behaviour of the mangled-RA info bit in SFrame format closely
follows the behaviour of DW_CFA_AARCH64_negate_ra_state in DWARF.  During
unwinding, whenever an SFrame FRE with non-zero "mangled RA" bit is
encountered, it means the upper bits of the return address contain Pointer
Authentication code.  The unwinder, hence, must use appropriate means to
restore LR correctly in such cases.

include/ChangeLog:

	* sframe.h (SFRAME_V1_FRE_INFO_UPDATE_MANGLED_RA_P): New macro.
	(SFRAME_V1_FRE_MANGLED_RA_P): Likewise.
---
 include/sframe.h | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/include/sframe.h b/include/sframe.h
index 03a2d75dfd3..b2bd41a724e 100644
--- a/include/sframe.h
+++ b/include/sframe.h
@@ -227,11 +227,12 @@ typedef struct sframe_fre_info
      - 2 bits: information about size of the offsets (S) in bytes.
      Valid values are SFRAME_FRE_OFFSET_1B, SFRAME_FRE_OFFSET_2B,
      SFRAME_FRE_OFFSET_4B
-     - 1 bit: Unused.
-     -----------------------------------------------------------------------
-     |  Unused  |  Size of offsets   |   Number of offsets    |   base_reg |
-     -----------------------------------------------------------------------
-     8          7                    5                        1            0
+     - 1 bit: Mangled RA state bit (aarch64 only).
+     ----------------------------------------------------------------------------------
+     | Mangled-RA (aarch64) |  Size of offsets   |   Number of offsets    |   base_reg |
+     |  Unused (amd64)      |                    |                        |            |
+     ----------------------------------------------------------------------------------
+     8                     7                    5                        1            0
 
      */
   uint8_t fre_info;
@@ -239,13 +240,19 @@ typedef struct sframe_fre_info
 
 /* Macros to compose and decompose FRE info.  */
 
+/* Note: Set mangled_ra_p to zero by default.  */
 #define SFRAME_V1_FRE_INFO(base_reg_id, offset_num, offset_size) \
-  ((((offset_size) & 0x3) << 5) | (((offset_num) & 0xf) << 1) | \
-   ((base_reg_id) & 0x1))
+  (((0 & 0x1) << 7) | (((offset_size) & 0x3) << 5) | \
+   (((offset_num) & 0xf) << 1) | ((base_reg_id) & 0x1))
+
+/* Set the mangled_ra_p bit as indicated.  */
+#define SFRAME_V1_FRE_INFO_UPDATE_MANGLED_RA_P(mangled_ra_p, fre_info) \
+  ((((mangled_ra_p) & 0x1) << 7) | ((fre_info) & 0x7f))
 
 #define SFRAME_V1_FRE_CFA_BASE_REG_ID(data)	  ((data) & 0x1)
 #define SFRAME_V1_FRE_OFFSET_COUNT(data)	  (((data) >> 1) & 0xf)
-#define SFRAME_V1_FRE_OFFSET_SIZE(data)	  (((data) >> 5) & 0x3)
+#define SFRAME_V1_FRE_OFFSET_SIZE(data)		  (((data) >> 5) & 0x3)
+#define SFRAME_V1_FRE_MANGLED_RA_P(data)	  (((data) >> 7) & 0x1)
 
 /* SFrame Frame Row Entry definitions.
 
-- 
2.37.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/6] [2/6] gas: sframe: add support for .cfi_negate_ra_state
  2022-12-14 19:58 [PATCH 0/6] SFrame: support for .cfi_negate_ra_state in aarch64 Indu Bhagat
  2022-12-14 19:58 ` [PATCH 1/6] [1/6] sframe.h: add support for .cfi_negate_ra_state Indu Bhagat
@ 2022-12-14 19:58 ` Indu Bhagat
  2022-12-14 19:58 ` [PATCH 3/6] [3/6] gas: sframe: testsuite: add testcase " Indu Bhagat
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Indu Bhagat @ 2022-12-14 19:58 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

DW_CFA_AARCH64_negate_ra_state in aarch64 is multiplexed with
DW_CFA_GNU_window_save in the DWARF format.

ChangeLog:

	* gas/gen-sframe.c (sframe_v1_set_fre_info): Add new argument
	for mangled_ra_p.
	(sframe_set_fre_info): Likewise.
	(output_sframe_row_entry): Handle mangled_ra_p.
	(sframe_row_entry_new): Initialize mangled_ra_p.
	(sframe_xlate_do_gnu_window_save): New definition.
	(sframe_do_cfi_insn): Handle DW_CFA_GNU_window_save.
	* gas/gen-sframe.h (struct sframe_row_entry):
	(struct sframe_version_ops): Add a new argument for mangled_ra_p.
---
 gas/gen-sframe.c | 41 +++++++++++++++++++++++++++++++++--------
 gas/gen-sframe.h |  6 +++++-
 2 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c
index 075720facd6..f31a66da377 100644
--- a/gas/gen-sframe.c
+++ b/gas/gen-sframe.c
@@ -243,10 +243,11 @@ static struct sframe_version_ops sframe_ver_ops;
 
 static unsigned char
 sframe_v1_set_fre_info (unsigned int base_reg, unsigned int num_offsets,
-			unsigned int offset_size)
+			unsigned int offset_size, bool mangled_ra_p)
 {
   unsigned char fre_info;
   fre_info = SFRAME_V1_FRE_INFO (base_reg, num_offsets, offset_size);
+  fre_info = SFRAME_V1_FRE_INFO_UPDATE_MANGLED_RA_P (mangled_ra_p, fre_info);
   return fre_info;
 }
 
@@ -275,10 +276,10 @@ sframe_set_version (uint32_t sframe_version __attribute__((unused)))
 
 static unsigned char
 sframe_set_fre_info (unsigned int base_reg, unsigned int num_offsets,
-		     unsigned int offset_size)
+		     unsigned int offset_size, bool mangled_ra_p)
 {
   return sframe_ver_ops.set_fre_info (base_reg, num_offsets,
-					 offset_size);
+				      offset_size, mangled_ra_p);
 }
 
 /* SFrame set func info. */
@@ -507,7 +508,7 @@ output_sframe_row_entry (symbolS *fde_start_addr,
   fre_num_offsets = get_fre_num_offsets (sframe_fre);
   fre_offset_size = sframe_get_fre_offset_size (sframe_fre);
   fre_info = sframe_set_fre_info (fre_base_reg, fre_num_offsets,
-				     fre_offset_size);
+				  fre_offset_size, sframe_fre->mangled_ra_p);
   out_one (fre_info);
 
   idx = sframe_fre_offset_func_map_index (fre_offset_size);
@@ -845,6 +846,9 @@ sframe_row_entry_new (void)
      for the supported arches.  */
   fre->cfa_base_reg = -1;
   fre->merge_candidate = true;
+  /* Reset the mangled RA status bit to zero by default.  We will initialize it in
+     sframe_row_entry_initialize () with the sticky bit if set.  */
+  fre->mangled_ra_p = false;
 
   return fre;
 }
@@ -890,6 +894,9 @@ sframe_row_entry_initialize (struct sframe_row_entry *cur_fre,
   cur_fre->bp_offset = prev_fre->bp_offset;
   cur_fre->ra_loc = prev_fre->ra_loc;
   cur_fre->ra_offset = prev_fre->ra_offset;
+  /* Treat RA mangling as a sticky bit.  It retains its value until another
+     .cfi_negate_ra_state is seen.  */
+  cur_fre->mangled_ra_p = prev_fre->mangled_ra_p;
 }
 
 /* Translate DW_CFA_advance_loc into SFrame context.
@@ -1150,6 +1157,22 @@ sframe_xlate_do_restore (struct sframe_xlate_ctx *xlate_ctx,
   return SFRAME_XLATE_OK;
 }
 
+/* Translate DW_CFA_GNU_window_save into SFrame context.
+   Return SFRAME_XLATE_OK if success.  */
+
+static int
+sframe_xlate_do_gnu_window_save (struct sframe_xlate_ctx *xlate_ctx,
+				 struct cfi_insn_data *cfi_insn ATTRIBUTE_UNUSED)
+{
+  struct sframe_row_entry *cur_fre = xlate_ctx->cur_fre;
+
+  gas_assert (cur_fre);
+  /* Toggle the mangled RA status bit.  */
+  cur_fre->mangled_ra_p = !cur_fre->mangled_ra_p;
+
+  return SFRAME_XLATE_OK;
+}
+
 /* Process CFI_INSN and update the translation context with the FRE
    information.
 
@@ -1195,6 +1218,11 @@ sframe_do_cfi_insn (struct sframe_xlate_ctx *xlate_ctx,
     case DW_CFA_restore:
       err = sframe_xlate_do_restore (xlate_ctx, cfi_insn);
       break;
+    /* DW_CFA_AARCH64_negate_ra_state is multiplexed with
+       DW_CFA_GNU_window_save.  */
+    case DW_CFA_GNU_window_save:
+      err = sframe_xlate_do_gnu_window_save (xlate_ctx, cfi_insn);
+      break;
     case DW_CFA_undefined:
     case DW_CFA_same_value:
       break;
@@ -1207,10 +1235,7 @@ sframe_do_cfi_insn (struct sframe_xlate_ctx *xlate_ctx,
 	    - ...
 
 	   Following skipped operations do, however, impact the asynchronicity:
-	     - CFI_escape,
-	     - DW_CFA_GNU_window_save,
-	     - DW_CFA_AARCH64_negate_ra_state (multiplexed with
-	       DW_CFA_GNU_window_save)  */
+	     - CFI_escape  */
 
 	err = SFRAME_XLATE_ERR_NOTREPRESENTED;
 	// printf (_("SFrame Unsupported or unknown Dwarf CFI number: %#x\n"), op);
diff --git a/gas/gen-sframe.h b/gas/gen-sframe.h
index 93af499278c..aa8be5df457 100644
--- a/gas/gen-sframe.h
+++ b/gas/gen-sframe.h
@@ -50,6 +50,9 @@ struct sframe_row_entry
      on it.  */
   bool merge_candidate;
 
+  /* Toggle RA state wrt pointer authentication code.  */
+  bool mangled_ra_p;
+
   /* Track CFA base (architectural) register ID.  */
   unsigned int cfa_base_reg;
   /* Offset from the CFA base register for recovering CFA.  */
@@ -140,7 +143,8 @@ struct sframe_version_ops
 {
   unsigned char format_version;    /* SFrame format version.  */
   /* set SFrame FRE info.  */
-  unsigned char (*set_fre_info) (unsigned int, unsigned int, unsigned int);
+  unsigned char (*set_fre_info) (unsigned int, unsigned int, unsigned int,
+				 bool);
   /* set SFrame Func info.  */
   unsigned char (*set_func_info) (unsigned int, unsigned int);
 };
-- 
2.37.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/6] [3/6] gas: sframe: testsuite: add testcase for .cfi_negate_ra_state
  2022-12-14 19:58 [PATCH 0/6] SFrame: support for .cfi_negate_ra_state in aarch64 Indu Bhagat
  2022-12-14 19:58 ` [PATCH 1/6] [1/6] sframe.h: add support for .cfi_negate_ra_state Indu Bhagat
  2022-12-14 19:58 ` [PATCH 2/6] [2/6] gas: sframe: " Indu Bhagat
@ 2022-12-14 19:58 ` Indu Bhagat
  2022-12-14 19:58 ` [PATCH 4/6] [4/6] libsframe: provide new access API for mangled RA bit Indu Bhagat
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Indu Bhagat @ 2022-12-14 19:58 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

Previously, the common-empty-4 testcase ensured that
.cfi_negate_ra_state directive, if present, generates an empty SFrame
FDE.  Now that the handling of .cfi_negate_ra_state is in place,
repurpose the testcase: add it as a new test for aarch64 target such
that a non-empty SFrame section with valid SFrame FREs are expected.

ChangeLog:

	* testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.d: New test.
	* testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.s: Likewise.
	* testsuite/gas/cfi-sframe/cfi-sframe.exp: Adjust the testcases
	accordingly.
	* testsuite/gas/cfi-sframe/common-empty-4.d: Removed.
	* testsuite/gas/cfi-sframe/common-empty-4.s: Likewise.
---
 .../gas/cfi-sframe/cfi-sframe-aarch64-2.d     | 20 +++++++++++++++++++
 ...ommon-empty-4.s => cfi-sframe-aarch64-2.s} |  3 ++-
 gas/testsuite/gas/cfi-sframe/cfi-sframe.exp   |  2 +-
 gas/testsuite/gas/cfi-sframe/common-empty-4.d | 14 -------------
 4 files changed, 23 insertions(+), 16 deletions(-)
 create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.d
 rename gas/testsuite/gas/cfi-sframe/{common-empty-4.s => cfi-sframe-aarch64-2.s} (85%)
 delete mode 100644 gas/testsuite/gas/cfi-sframe/common-empty-4.d

diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.d
new file mode 100644
index 00000000000..59937c166cd
--- /dev/null
+++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.d
@@ -0,0 +1,20 @@
+#as: --gsframe
+#objdump: --sframe=.sframe
+#name: SFrame cfi_negate_ra_state test
+#...
+Contents of the SFrame section .sframe:
+
+  Header :
+
+    Version: SFRAME_VERSION_1
+    Flags: NONE
+    Num FDEs: 1
+    Num FREs: 2
+
+  Function Index :
+    func idx \[0\]: pc = 0x0, size = 8 bytes
+    STARTPC + CFA + FP + RA +
+#...
+    0+0004 +sp\+16 +u +u +
+
+#pass
diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-4.s b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.s
similarity index 85%
rename from gas/testsuite/gas/cfi-sframe/common-empty-4.s
rename to gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.s
index f97ca2f7ff9..8106c937b39 100644
--- a/gas/testsuite/gas/cfi-sframe/common-empty-4.s
+++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.s
@@ -8,7 +8,8 @@
 ##
 ## .cfi_negate_ra_state CFI directive is used to convey this information.
 ##
-## SFrame does not have any means to represent this information at this time.
+## SFrame has support for this. This testcase ensures that the directive
+## is interpreted successfully.
 	.cfi_startproc
 	.long 0
 	.cfi_def_cfa_offset 16
diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp b/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp
index eb6da614c2f..f001fad0e8e 100644
--- a/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp
+++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp
@@ -82,7 +82,6 @@ if  { ([istarget "x86_64-*-*"] || [istarget "aarch64*-*-*"]) \
     run_dump_test "common-empty-1"
     run_dump_test "common-empty-2"
     run_dump_test "common-empty-3"
-    run_dump_test "common-empty-4"
 }
 
 # x86-64 specific tests
@@ -97,4 +96,5 @@ if { [istarget "x86_64-*-*"] && [gas_sframe_check] } then {
 # aarch64 specific tests
 if { [istarget "aarch64*-*-*"] && [gas_sframe_check] } then {
     run_dump_test "cfi-sframe-aarch64-1"
+    run_dump_test "cfi-sframe-aarch64-2"
 }
diff --git a/gas/testsuite/gas/cfi-sframe/common-empty-4.d b/gas/testsuite/gas/cfi-sframe/common-empty-4.d
deleted file mode 100644
index f7a6062d392..00000000000
--- a/gas/testsuite/gas/cfi-sframe/common-empty-4.d
+++ /dev/null
@@ -1,14 +0,0 @@
-#as: --gsframe
-#objdump: --sframe=.sframe
-#name: SFrame supports only default return column
-#...
-Contents of the SFrame section .sframe:
-
-  Header :
-
-    Version: SFRAME_VERSION_1
-    Flags: NONE
-    Num FDEs: 0
-    Num FREs: 0
-
-#pass
-- 
2.37.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/6] [4/6] libsframe: provide new access API for mangled RA bit
  2022-12-14 19:58 [PATCH 0/6] SFrame: support for .cfi_negate_ra_state in aarch64 Indu Bhagat
                   ` (2 preceding siblings ...)
  2022-12-14 19:58 ` [PATCH 3/6] [3/6] gas: sframe: testsuite: add testcase " Indu Bhagat
@ 2022-12-14 19:58 ` Indu Bhagat
  2022-12-14 19:58 ` [PATCH 5/6] [5/6] objdump/readelf: sframe: emit marker for FREs with mangled RA Indu Bhagat
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Indu Bhagat @ 2022-12-14 19:58 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

include/ChangeLog:

	* sframe-api.h (sframe_fre_get_ra_mangled_p): New declaration.

ChangeLog:

	* libsframe/sframe.c (sframe_get_fre_ra_mangled_p): New
	definition.
	(sframe_fre_get_ra_mangled_p): New static function.
---
 include/sframe-api.h |  7 +++++++
 libsframe/sframe.c   | 18 ++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/include/sframe-api.h b/include/sframe-api.h
index 0a86389857c..3338a2ebd5c 100644
--- a/include/sframe-api.h
+++ b/include/sframe-api.h
@@ -21,6 +21,7 @@
 #define	_SFRAME_API_H
 
 #include <sframe.h>
+#include <stdbool.h>
 
 #ifdef	__cplusplus
 extern "C"
@@ -180,6 +181,12 @@ extern int32_t
 sframe_fre_get_ra_offset (sframe_decoder_ctx *dctx,
 			  sframe_frame_row_entry *fre, int *errp);
 
+/* Get whether the RA is mangled.  */
+
+extern bool
+sframe_fre_get_ra_mangled_p (sframe_decoder_ctx *dctx,
+			     sframe_frame_row_entry *fre, int *errp);
+
 /* The SFrame Encoder.  */
 
 /* Create an encoder context with the given SFrame format version VER, FLAGS
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index d4eaaee2297..ef821da3901 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -124,6 +124,12 @@ sframe_fre_get_offset_size (unsigned char fre_info)
   return SFRAME_V1_FRE_OFFSET_SIZE (fre_info);
 }
 
+static bool
+sframe_get_fre_ra_mangled_p (unsigned char fre_info)
+{
+  return SFRAME_V1_FRE_MANGLED_RA_P (fre_info);
+}
+
 /* Access functions for info from function descriptor entry.  */
 
 static unsigned int
@@ -640,6 +646,18 @@ sframe_fre_get_ra_offset (sframe_decoder_ctx *dctx,
   return sframe_get_fre_offset (fre, SFRAME_FRE_RA_OFFSET_IDX, errp);
 }
 
+/* Get whether the RA is mangled.  */
+
+bool
+sframe_fre_get_ra_mangled_p (sframe_decoder_ctx *dctx ATTRIBUTE_UNUSED,
+			     sframe_frame_row_entry *fre, int *errp)
+{
+  if (fre == NULL || !sframe_fre_sanity_check_p (fre))
+    return sframe_set_errno (errp, SFRAME_ERR_FRE_INVAL);
+
+  return sframe_get_fre_ra_mangled_p (fre->fre_info);
+}
+
 static int
 sframe_frame_row_entry_copy (sframe_frame_row_entry *dst, sframe_frame_row_entry *src)
 {
-- 
2.37.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 5/6] [5/6] objdump/readelf: sframe: emit marker for FREs with mangled RA
  2022-12-14 19:58 [PATCH 0/6] SFrame: support for .cfi_negate_ra_state in aarch64 Indu Bhagat
                   ` (3 preceding siblings ...)
  2022-12-14 19:58 ` [PATCH 4/6] [4/6] libsframe: provide new access API for mangled RA bit Indu Bhagat
@ 2022-12-14 19:58 ` Indu Bhagat
  2022-12-14 19:58 ` [PATCH 6/6] [6/6] sframe: doc: update spec for the mangled-RA bit in FRE Indu Bhagat
  2022-12-16 16:39 ` [PATCH 0/6] SFrame: support for .cfi_negate_ra_state in aarch64 Nick Clifton
  6 siblings, 0 replies; 8+ messages in thread
From: Indu Bhagat @ 2022-12-14 19:58 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

In the textual dump of the SFrame section, when an SFrame FRE recovers a
mangled RA, use string "[s]" in the output to indicate that the return
address is a signed (mangled) one.

ChangeLog:

        * libsframe/sframe-dump.c (dump_sframe_func_with_fres): Postfix
	with "[s]" if RA is signed with authorization code.
---
 libsframe/sframe-dump.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libsframe/sframe-dump.c b/libsframe/sframe-dump.c
index 5b063c9962d..8e5cd6116ef 100644
--- a/libsframe/sframe-dump.c
+++ b/libsframe/sframe-dump.c
@@ -116,7 +116,7 @@ dump_sframe_func_with_fres (sframe_decoder_ctx *sfd_ctx,
   char temp[100];
   memset (temp, 0, 100);
 
-  printf ("\n    %-7s%-8s %-10s%-10s%-10s", "STARTPC", fde_type_marker, "CFA", "FP", "RA");
+  printf ("\n    %-7s%-8s %-10s%-10s%-13s", "STARTPC", fde_type_marker, "CFA", "FP", "RA");
   for (j = 0; j < num_fres; j++)
     {
       sframe_decoder_get_fre (sfd_ctx, funcidx, j, &fre);
@@ -149,10 +149,17 @@ dump_sframe_func_with_fres (sframe_decoder_ctx *sfd_ctx,
       /* Dump RA info.  */
       memset (temp, 0, 100);
       if (err[2] == 0)
-	sprintf (temp, "c%+d", ra_offset);
+	{
+	  /* Mark SFrame FRE's RA information with "[s]" if the RA is mangled
+	     with signature bits.  */
+	  const char *ra_mangled_p_str
+	    = ((sframe_fre_get_ra_mangled_p (sfd_ctx, &fre, &err[2]))
+	       ? "[s]" : "   ");
+	  sprintf (temp, "c%+d%-3s", ra_offset, ra_mangled_p_str);
+	}
       else
 	strcpy (temp, "u");
-      printf ("%-10s", temp);
+      printf ("%-13s", temp);
     }
 }
 
-- 
2.37.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 6/6] [6/6] sframe: doc: update spec for the mangled-RA bit in FRE
  2022-12-14 19:58 [PATCH 0/6] SFrame: support for .cfi_negate_ra_state in aarch64 Indu Bhagat
                   ` (4 preceding siblings ...)
  2022-12-14 19:58 ` [PATCH 5/6] [5/6] objdump/readelf: sframe: emit marker for FREs with mangled RA Indu Bhagat
@ 2022-12-14 19:58 ` Indu Bhagat
  2022-12-16 16:39 ` [PATCH 0/6] SFrame: support for .cfi_negate_ra_state in aarch64 Nick Clifton
  6 siblings, 0 replies; 8+ messages in thread
From: Indu Bhagat @ 2022-12-14 19:58 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

ChangeLog:

	* libsframe/doc/sframe-spec.texi
---
 libsframe/doc/sframe-spec.texi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libsframe/doc/sframe-spec.texi b/libsframe/doc/sframe-spec.texi
index 0559d7c3882..fa66d801dd3 100644
--- a/libsframe/doc/sframe-spec.texi
+++ b/libsframe/doc/sframe-spec.texi
@@ -566,8 +566,8 @@ The SFrame FRE info word is a bitfield split into four parts.  From MSB to LSB:
 @multitable {Bit offset} {@code{fre_cfa_base_reg_id}} {Size of stack offsets in bytes.  Valid values}
 @headitem Bit offset @tab Name @tab Description
 @item 7
-@tab @code{unused}
-@tab Unused bit.
+@tab @code{fre_mangled_ra_p}
+@tab Indicate whether the return address is mangled with any authorization bits (signed RA).
 
 @item 5-6
 @tab @code{fre_offset_size}
-- 
2.37.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/6] SFrame: support for .cfi_negate_ra_state in aarch64
  2022-12-14 19:58 [PATCH 0/6] SFrame: support for .cfi_negate_ra_state in aarch64 Indu Bhagat
                   ` (5 preceding siblings ...)
  2022-12-14 19:58 ` [PATCH 6/6] [6/6] sframe: doc: update spec for the mangled-RA bit in FRE Indu Bhagat
@ 2022-12-16 16:39 ` Nick Clifton
  6 siblings, 0 replies; 8+ messages in thread
From: Nick Clifton @ 2022-12-16 16:39 UTC (permalink / raw)
  To: Indu Bhagat, binutils

Hi Indu,
> Indu Bhagat (6):
>    [1/6] sframe.h: add support for .cfi_negate_ra_state
>    [2/6] gas: sframe: add support for .cfi_negate_ra_state
>    [3/6] gas: sframe: testsuite: add testcase for .cfi_negate_ra_state
>    [4/6] libsframe: provide new access API for mangled RA bit
>    [5/6] objdump/readelf: sframe: emit marker for FREs with mangled RA
>    [6/6] sframe: doc: update spec for the mangled-RA bit in FRE
> 

Patch series approved - please apply.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-12-16 16:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-14 19:58 [PATCH 0/6] SFrame: support for .cfi_negate_ra_state in aarch64 Indu Bhagat
2022-12-14 19:58 ` [PATCH 1/6] [1/6] sframe.h: add support for .cfi_negate_ra_state Indu Bhagat
2022-12-14 19:58 ` [PATCH 2/6] [2/6] gas: sframe: " Indu Bhagat
2022-12-14 19:58 ` [PATCH 3/6] [3/6] gas: sframe: testsuite: add testcase " Indu Bhagat
2022-12-14 19:58 ` [PATCH 4/6] [4/6] libsframe: provide new access API for mangled RA bit Indu Bhagat
2022-12-14 19:58 ` [PATCH 5/6] [5/6] objdump/readelf: sframe: emit marker for FREs with mangled RA Indu Bhagat
2022-12-14 19:58 ` [PATCH 6/6] [6/6] sframe: doc: update spec for the mangled-RA bit in FRE Indu Bhagat
2022-12-16 16:39 ` [PATCH 0/6] SFrame: support for .cfi_negate_ra_state in aarch64 Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).