]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add an arm-tls feature which includes the tpidruro register from CP15.
authorJohn Baldwin <jhb@FreeBSD.org>
Tue, 3 May 2022 23:05:10 +0000 (16:05 -0700)
committerJohn Baldwin <jhb@FreeBSD.org>
Fri, 27 May 2022 21:17:34 +0000 (14:17 -0700)
(cherry picked from commit 92d48a1e4eac54db11f1a110328672394fce2853)

12 files changed:
gdb/arch/aarch32.c
gdb/arch/arm.c
gdb/arch/arm.h
gdb/arm-fbsd-tdep.c
gdb/arm-linux-nat.c
gdb/arm-linux-tdep.c
gdb/arm-netbsd-nat.c
gdb/arm-tdep.c
gdb/arm-tdep.h
gdb/features/Makefile
gdb/features/arm/arm-tls.c [new file with mode: 0644]
gdb/features/arm/arm-tls.xml [new file with mode: 0644]

index 0c544d381f145258fac2244e709b904e288115f0..4d6ffb44a152ef9859f4af59ad07ace5ff7fe330 100644 (file)
@@ -19,6 +19,7 @@
 #include "aarch32.h"
 
 #include "../features/arm/arm-core.c"
+#include "../features/arm/arm-tls.c"
 #include "../features/arm/arm-vfpv3.c"
 
 /* See aarch32.h.  */
@@ -38,6 +39,7 @@ aarch32_create_target_description ()
   /* Create a vfpv3 feature, then a blank NEON feature.  */
   regnum = create_feature_arm_arm_vfpv3 (tdesc.get (), regnum);
   tdesc_create_feature (tdesc.get (), "org.gnu.gdb.arm.neon");
+  regnum = create_feature_arm_arm_tls (tdesc.get (), regnum);
 
   return tdesc.release ();
 }
index 126e46a950a98c1821f755f1d822d882e9b63205..15b600e22f421d6e28ed7c1a72fb4fe4bce5027d 100644 (file)
@@ -22,6 +22,7 @@
 #include "arm.h"
 
 #include "../features/arm/arm-core.c"
+#include "../features/arm/arm-tls.c"
 #include "../features/arm/arm-vfpv2.c"
 #include "../features/arm/arm-vfpv3.c"
 #include "../features/arm/xscale-iwmmxt.c"
@@ -373,7 +374,7 @@ shifted_reg_val (struct regcache *regcache, unsigned long inst,
 /* See arch/arm.h.  */
 
 target_desc *
-arm_create_target_description (arm_fp_type fp_type)
+arm_create_target_description (arm_fp_type fp_type, bool tls)
 {
   target_desc_up tdesc = allocate_target_description ();
 
@@ -409,6 +410,9 @@ arm_create_target_description (arm_fp_type fp_type)
       error (_("Invalid Arm FP type: %d"), fp_type);
     }
 
+  if (tls)
+    regnum = create_feature_arm_arm_tls (tdesc.get (), regnum);
+
   return tdesc.release ();
 }
 
index f75470e7572724ab311fe859eec0689d10b9a7a7..2873effae8bc4fdea82426eaf894c56609bc4e50 100644 (file)
@@ -193,7 +193,7 @@ unsigned long shifted_reg_val (struct regcache *regcache,
 
 /* Create an Arm target description with the given FP hardware type.  */
 
-target_desc *arm_create_target_description (arm_fp_type fp_type);
+target_desc *arm_create_target_description (arm_fp_type fp_type, bool tls);
 
 /* Create an Arm M-profile target description with the given hardware type.  */
 
index bf337b13f98e23e8cb59061c1611f72be686d978..06745a3618637b224fcb5ef9f6e1a0b6552d0326 100644 (file)
@@ -188,9 +188,9 @@ arm_fbsd_read_description_auxv (struct target_ops *target)
        return aarch32_read_description ();
       else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPD32))
               == (HWCAP_VFPv3 | HWCAP_VFPD32))
-       return arm_read_description (ARM_FP_TYPE_VFPV3);
+       return arm_read_description (ARM_FP_TYPE_VFPV3, false);
       else
-       return arm_read_description (ARM_FP_TYPE_VFPV2);
+       return arm_read_description (ARM_FP_TYPE_VFPV2, false);
     }
 
   return nullptr;
index f0f09acf2f9407c321076a74490d515f22dca028..2abaf5a675d8d4169e9e259d7a7f5ccd1c993a0d 100644 (file)
@@ -550,7 +550,7 @@ arm_linux_nat_target::read_description ()
     }
 
   if (arm_hwcap & HWCAP_IWMMXT)
-    return arm_read_description (ARM_FP_TYPE_IWMMXT);
+    return arm_read_description (ARM_FP_TYPE_IWMMXT, false);
 
   if (arm_hwcap & HWCAP_VFP)
     {
@@ -567,9 +567,9 @@ arm_linux_nat_target::read_description ()
       if (arm_hwcap & HWCAP_NEON)
        return aarch32_read_description ();
       else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
-       return arm_read_description (ARM_FP_TYPE_VFPV3);
+       return arm_read_description (ARM_FP_TYPE_VFPV3, false);
 
-      return arm_read_description (ARM_FP_TYPE_VFPV2);
+      return arm_read_description (ARM_FP_TYPE_VFPV2, false);
     }
 
   return this->beneath ()->read_description ();
index 6aac016afb91291b0c86dfef6ac54d4c4ed827e4..805c6ac04599cc2f8926943d229f432409a580a9 100644 (file)
@@ -741,9 +741,9 @@ arm_linux_core_read_description (struct gdbarch *gdbarch,
       if (arm_hwcap & HWCAP_NEON)
        return aarch32_read_description ();
       else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
-       return arm_read_description (ARM_FP_TYPE_VFPV3);
+       return arm_read_description (ARM_FP_TYPE_VFPV3, false);
 
-      return arm_read_description (ARM_FP_TYPE_VFPV2);
+      return arm_read_description (ARM_FP_TYPE_VFPV2, false);
     }
 
   return nullptr;
index 591a0ab1d54194c98a587fcfa20346bc3728d345..764bbe8cd3d50c590339596bfbb6243db37e0602 100644 (file)
@@ -346,13 +346,13 @@ arm_netbsd_nat_target::read_description ()
 
   if (sysctlbyname("machdep.fpu_present", &flag, &len, NULL, 0) != 0
       || !flag)
-    return arm_read_description (ARM_FP_TYPE_NONE);
+    return arm_read_description (ARM_FP_TYPE_NONE, false);
 
   len = sizeof(flag);
   if (sysctlbyname("machdep.neon_present", &flag, &len, NULL, 0) == 0 && flag)
     return aarch32_read_description ();
 
-  return arm_read_description (ARM_FP_TYPE_VFPV3);
+  return arm_read_description (ARM_FP_TYPE_VFPV3, false);
 }
 
 void _initialize_arm_netbsd_nat ();
index 8e245648f2392d630a863e7f10e5790dc7160ac5..0c87388bc110cd48d03a8f34267bc429ff1597b9 100644 (file)
@@ -239,7 +239,7 @@ static const char **valid_disassembly_styles;
 static const char *disassembly_style;
 
 /* All possible arm target descriptors.  */
-static struct target_desc *tdesc_arm_list[ARM_FP_TYPE_INVALID];
+static struct target_desc *tdesc_arm_list[ARM_FP_TYPE_INVALID][2];
 static struct target_desc *tdesc_arm_mprofile_list[ARM_M_TYPE_INVALID];
 
 /* This is used to keep the bfd arch_info in sync with the disassembly
@@ -9100,6 +9100,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   bool have_mve = false;
   int mve_vpr_regnum = -1;
   int register_count = ARM_NUM_REGS;
+  int tls_regnum = 0;
 
   /* If we have an object to base this architecture on, try to determine
      its ABI.  */
@@ -9410,6 +9411,19 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
            }
        }
 
+      /* Check for the TLS register feature.  */
+      feature = tdesc_find_feature (tdesc, "org.gnu.gdb.arm.tls");
+      if (feature != nullptr)
+       {
+         valid_p &= tdesc_numbered_register (feature, tdesc_data.get (),
+                                             register_count, "tpidruro");
+         if (!valid_p)
+           return nullptr;
+
+         tls_regnum = register_count;
+         register_count++;
+       }
+
       /* Check for MVE after all the checks for GPR's, VFP and Neon.
         MVE (Helium) is an M-profile extension.  */
       if (is_m)
@@ -9493,6 +9507,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->have_s_pseudos = have_s_pseudos;
   tdep->have_q_pseudos = have_q_pseudos;
   tdep->have_neon = have_neon;
+  tdep->tls_regnum = tls_regnum;
 
   /* Adjust the MVE feature settings.  */
   if (have_mve)
@@ -13725,14 +13740,14 @@ arm_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
 /* See arm-tdep.h.  */
 
 const target_desc *
-arm_read_description (arm_fp_type fp_type)
+arm_read_description (arm_fp_type fp_type, bool tls)
 {
-  struct target_desc *tdesc = tdesc_arm_list[fp_type];
+  struct target_desc *tdesc = tdesc_arm_list[fp_type][tls];
 
   if (tdesc == nullptr)
     {
-      tdesc = arm_create_target_description (fp_type);
-      tdesc_arm_list[fp_type] = tdesc;
+      tdesc = arm_create_target_description (fp_type, tls);
+      tdesc_arm_list[fp_type][tls] = tdesc;
     }
 
   return tdesc;
index 8a9f618539ff101b506749b7bad1afb6c3ffc8c8..ddcd08a4dc926a42e01838ee36f79f2a74e544ca 100644 (file)
@@ -119,6 +119,8 @@ struct arm_gdbarch_tdep : gdbarch_tdep
   int mve_pseudo_base = 0;     /* Number of the first MVE pseudo register.  */
   int mve_pseudo_count = 0;    /* Total number of MVE pseudo registers.  */
 
+  int tls_regnum = 0;          /* Number of the tpidruro register.  */
+
   bool is_m = false;           /* Does the target follow the "M" profile.  */
   CORE_ADDR lowest_pc = 0;     /* Lowest address at which instructions
                                   will appear.  */
@@ -301,7 +303,7 @@ extern void
                                       const struct regcache *regcache);
 
 /* Get the correct Arm target description with given FP hardware type.  */
-const target_desc *arm_read_description (arm_fp_type fp_type);
+const target_desc *arm_read_description (arm_fp_type fp_type, bool tls);
 
 /* Get the correct Arm M-Profile target description with given hardware
    type.  */
index 68e17d0085d345c09080d21936a1784ab86accf4..4b09819389a74aa44840fe06bbc4a9b99053219e 100644 (file)
@@ -207,6 +207,7 @@ FEATURE_XMLFILES = aarch64-core.xml \
        arm/arm-m-profile.xml \
        arm/arm-m-profile-mve.xml \
        arm/arm-m-profile-with-fpa.xml \
+       arm/arm-tls.xml \
        arm/arm-vfpv2.xml \
        arm/arm-vfpv3.xml \
        arm/xscale-iwmmxt.xml \
diff --git a/gdb/features/arm/arm-tls.c b/gdb/features/arm/arm-tls.c
new file mode 100644 (file)
index 0000000..d1214dd
--- /dev/null
@@ -0,0 +1,14 @@
+/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
+  Original: arm-tls.xml */
+
+#include "gdbsupport/tdesc.h"
+
+static int
+create_feature_arm_arm_tls (struct target_desc *result, long regnum)
+{
+  struct tdesc_feature *feature;
+
+  feature = tdesc_create_feature (result, "org.gnu.gdb.arm.tls");
+  tdesc_create_reg (feature, "tpidruro", regnum++, 1, NULL, 32, "data_ptr");
+  return regnum;
+}
diff --git a/gdb/features/arm/arm-tls.xml b/gdb/features/arm/arm-tls.xml
new file mode 100644 (file)
index 0000000..3cdf73e
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2022 Free Software Foundation, Inc.
+
+     Copying and distribution of this file, with or without modification,
+     are permitted in any medium without royalty provided the copyright
+     notice and this notice are preserved.  -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<feature name="org.gnu.gdb.arm.tls">
+  <reg name="tpidruro" bitsize="32" type="data_ptr"/>
+</feature>