diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 7229b53838e..87335ad22ae 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -254,7 +254,8 @@ aarch64_frame_unmask_lr (aarch64_gdbarch_tdep *tdep,
 {
   if (tdep->has_pauth ()
       && frame_unwind_register_unsigned (this_frame,
-					 tdep->ra_sign_state_regnum))
+					 tdep->get_ra_sign_state_regnum (
+						get_frame_arch (this_frame))))
     {
       int cmask_num = AARCH64_PAUTH_CMASK_REGNUM (tdep->pauth_reg_base);
       CORE_ADDR cmask = frame_unwind_register_unsigned (this_frame, cmask_num);
@@ -542,7 +543,7 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch,
 
 	  if (tdep->has_pauth () && cache != nullptr)
 	    {
-	      int regnum = tdep->ra_sign_state_regnum;
+	      int regnum = tdep->get_ra_sign_state_regnum (gdbarch);
 	      cache->saved_regs[regnum].set_value (ra_state_val);
 	    }
 	}
@@ -882,7 +883,7 @@ aarch64_analyze_prologue_test (void)
 
       if (tdep->has_pauth ())
 	{
-	  int regnum = tdep->ra_sign_state_regnum;
+	  int regnum = tdep->get_ra_sign_state_regnum (gdbarch);
 	  SELF_CHECK (cache.saved_regs[regnum].is_value ());
 	}
     }
@@ -1137,7 +1138,8 @@ aarch64_prologue_prev_register (struct frame_info *this_frame,
       lr = frame_unwind_register_unsigned (this_frame, AARCH64_LR_REGNUM);
 
       if (tdep->has_pauth ()
-	  && cache->saved_regs[tdep->ra_sign_state_regnum].is_value ())
+	  && cache->saved_regs[tdep->get_ra_sign_state_regnum (gdbarch)]
+		.is_value ())
 	lr = aarch64_frame_unmask_lr (tdep, this_frame, lr);
 
       return frame_unwind_got_constant (this_frame, prev_regnum, lr);
@@ -1344,7 +1346,7 @@ aarch64_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
   /* Init pauth registers.  */
   if (tdep->has_pauth ())
     {
-      if (regnum == tdep->ra_sign_state_regnum)
+      if (regnum == tdep->get_ra_sign_state_regnum (gdbarch))
 	{
 	  /* Initialize RA_STATE to zero.  */
 	  reg->how = DWARF2_FRAME_REG_SAVED_VAL_EXP;
@@ -2255,7 +2257,7 @@ aarch64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
   if (tdep->has_pauth ())
     {
       if (reg == AARCH64_DWARF_RA_SIGN_STATE)
-	return tdep->ra_sign_state_regnum;
+	return tdep->get_ra_sign_state_regnum (gdbarch);
     }
 
   return -1;
@@ -2662,7 +2664,7 @@ aarch64_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
   /* RA_STATE is used for unwinding only.  Do not assign it a name - this
      prevents it from being read by methods such as
      mi_cmd_trace_frame_collected.  */
-  if (tdep->has_pauth () && regnum == tdep->ra_sign_state_regnum)
+  if (tdep->has_pauth () && p_regnum == tdep->ra_sign_state_pseudo_regnum)
     return "";
 
   internal_error (__FILE__, __LINE__,
@@ -2698,7 +2700,7 @@ aarch64_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
       && p_regnum < AARCH64_SVE_V0_REGNUM + AARCH64_V_REGS_NUM)
     return aarch64_vnv_type (gdbarch);
 
-  if (tdep->has_pauth () && regnum == tdep->ra_sign_state_regnum)
+  if (tdep->has_pauth () && p_regnum == tdep->ra_sign_state_pseudo_regnum)
     return builtin_type (gdbarch)->builtin_uint64;
 
   internal_error (__FILE__, __LINE__,
@@ -2732,7 +2734,7 @@ aarch64_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 	   && p_regnum < AARCH64_SVE_V0_REGNUM + AARCH64_V_REGS_NUM)
     return group == all_reggroup || group == vector_reggroup;
   /* RA_STATE is used for unwinding only.  Do not assign it to any groups.  */
-  if (tdep->has_pauth () && regnum == tdep->ra_sign_state_regnum)
+  if (tdep->has_pauth () && p_regnum == tdep->ra_sign_state_pseudo_regnum)
     return 0;
 
   return group == all_reggroup;
@@ -3598,8 +3600,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->jb_elt_size = 8;
   tdep->vq = vq;
   tdep->pauth_reg_base = first_pauth_regnum;
-  tdep->ra_sign_state_regnum = (feature_pauth == NULL) ? -1
-				: ra_sign_state_offset + num_regs;
+  tdep->ra_sign_state_pseudo_regnum = ra_sign_state_offset;
   tdep->mte_reg_base = first_mte_regnum;
   tdep->tls_regnum = tls_regnum;
 
diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h
index d8513023c37..acb69b2dc40 100644
--- a/gdb/aarch64-tdep.h
+++ b/gdb/aarch64-tdep.h
@@ -94,7 +94,13 @@ struct aarch64_gdbarch_tdep : gdbarch_tdep_base
   }
 
   int pauth_reg_base = 0;
-  int ra_sign_state_regnum = 0;
+  int ra_sign_state_pseudo_regnum = -1;
+
+  int get_ra_sign_state_regnum (gdbarch *gdbarch) const
+  {
+    gdb_assert (ra_sign_state_pseudo_regnum >= 0);
+    return ra_sign_state_pseudo_regnum + gdbarch_num_regs (gdbarch);
+  }
 
   /* Returns true if the target supports pauth.  */
   bool has_pauth () const
