This register will be used to indicate whether a return address is
mangled with a PAC or not, in accordance with the DWARF AARCH64 ABI [1].

[1] 
https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#41dwarf-register-names

Signed-off-by: German Gomez <german.go...@arm.com>
---
 backends/aarch64_init.c    | 6 +++---
 backends/aarch64_initreg.c | 2 ++
 backends/aarch64_regs.c    | 5 ++++-
 libdw/dwarf.h              | 5 +++++
 tests/run-addrcfi.sh       | 1 +
 tests/run-allregs.sh       | 1 +
 6 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/backends/aarch64_init.c b/backends/aarch64_init.c
index bed92954..0a3a2c79 100644
--- a/backends/aarch64_init.c
+++ b/backends/aarch64_init.c
@@ -55,10 +55,10 @@ aarch64_init (Elf *elf __attribute__ ((unused)),
   HOOK (eh, data_marker_symbol);
   HOOK (eh, abi_cfi);
 
-  /* X0-X30 (31 regs) + SP + 1 Reserved + ELR, 30 Reserved regs (34-43)
+  /* X0-X30 (31 regs) + SP + 1 Reserved + ELR + RA_SIGN_STATE, 30 Reserved 
regs (34-43)
      + V0-V31 (32 regs, least significant 64 bits only)
-     + ALT_FRAME_RETURN_COLUMN (used when LR isn't used) = 97 DWARF regs. */
-  eh->frame_nregs = 97;
+     + ALT_FRAME_RETURN_COLUMN (used when LR isn't used) = 98 DWARF regs. */
+  eh->frame_nregs = 98;
   HOOK (eh, set_initial_registers_tid);
   HOOK (eh, unwind);
 
diff --git a/backends/aarch64_initreg.c b/backends/aarch64_initreg.c
index daf6f375..4661068a 100644
--- a/backends/aarch64_initreg.c
+++ b/backends/aarch64_initreg.c
@@ -73,6 +73,8 @@ aarch64_set_initial_registers_tid (pid_t tid __attribute__ 
((unused)),
 
   /* ELR cannot be found.  */
 
+  /* RA_SIGN_STATE cannot be found */
+
   /* FP registers (only 64bits are used).  */
   struct user_fpsimd_struct fregs;
   iovec.iov_base = &fregs;
diff --git a/backends/aarch64_regs.c b/backends/aarch64_regs.c
index 23014bfc..e95ece37 100644
--- a/backends/aarch64_regs.c
+++ b/backends/aarch64_regs.c
@@ -87,7 +87,10 @@ aarch64_register_info (Ebl *ebl __attribute__ ((unused)),
     case 33:
       return regtype ("integer", DW_ATE_address, "elr");
 
-    case 34 ... 63:
+    case 34:
+      return regtype ("integer", DW_ATE_unsigned, "ra_sign_state");
+
+    case 35 ... 63:
       return 0;
 
     case 64 ... 95:
diff --git a/libdw/dwarf.h b/libdw/dwarf.h
index 3ce7f236..f234c411 100644
--- a/libdw/dwarf.h
+++ b/libdw/dwarf.h
@@ -1011,6 +1011,11 @@ enum
     DW_EH_PE_indirect = 0x80
   };
 
+/* AARCH64 DWARF registers. */
+enum
+  {
+    DW_AARCH64_RA_SIGN_STATE = 34
+  };
 
 /* DWARF XXX.  */
 #define DW_ADDR_none   0
diff --git a/tests/run-addrcfi.sh b/tests/run-addrcfi.sh
index 64fa24d7..ce9e753e 100755
--- a/tests/run-addrcfi.sh
+++ b/tests/run-addrcfi.sh
@@ -3639,6 +3639,7 @@ dwarf_cfi_addrframe (.eh_frame): no matching address range
        integer reg30 (x30): same_value
        integer reg31 (sp): location expression: call_frame_cfa stack_value
        integer reg33 (elr): undefined
+       integer reg34 (ra_sign_state): undefined
        FP/SIMD reg64 (v0): undefined
        FP/SIMD reg65 (v1): undefined
        FP/SIMD reg66 (v2): undefined
diff --git a/tests/run-allregs.sh b/tests/run-allregs.sh
index 87b16c95..ed086651 100755
--- a/tests/run-allregs.sh
+++ b/tests/run-allregs.sh
@@ -2693,6 +2693,7 @@ integer registers:
         30: x30 (x30), signed 64 bits
         31: sp (sp), address 64 bits
         33: elr (elr), address 64 bits
+        34: ra_sign_state (ra_sign_state), unsigned 64 bits
 FP/SIMD registers:
         64: v0 (v0), unsigned 128 bits
         65: v1 (v1), unsigned 128 bits
-- 
2.25.1

Reply via email to