[PATCH] AArch64 pauth: Indicate addresses in backtrace for kernel

Kuan-Ying Lee Kuan-Ying.Lee@mediatek.com
Mon Oct 25 11:47:05 GMT 2021


Armv8.3-a Pointer Authentication cause the function return address to
be changed. GDB need to use address bit[55] to know which mode is active
and mask/unmask the link register in order to get backtrace.

If address is in kernel mode, we mask the address. If address is in user mode,
we need to unmask the address.
---
 gdb/aarch64-tdep.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 4b5af4616af..d4bb4305cea 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -257,7 +257,10 @@ aarch64_frame_unmask_lr (struct gdbarch_tdep *tdep,
     {
       int cmask_num = AARCH64_PAUTH_CMASK_REGNUM (tdep->pauth_reg_base);
       CORE_ADDR cmask = frame_unwind_register_unsigned (this_frame, cmask_num);
-      addr = addr & ~cmask;
+      if (addr & 0x0080000000000000ULL)
+        addr = addr | cmask;
+      else
+        addr = addr & ~cmask;
 
       /* Record in the frame that the link register required unmasking.  */
       set_frame_previous_pc_masked (this_frame);
-- 
2.25.1


More information about the Gdb-patches mailing list