[binutils-gdb] gdb, gdbserver: propagate use of target_desc unique pointers

Simon Marchi simark@sourceware.org
Mon Dec 1 21:28:48 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1a5362ce51ef79ffb61caa20c93284dc368dc74a

commit 1a5362ce51ef79ffb61caa20c93284dc368dc74a
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Mon Nov 17 16:48:25 2025 -0500

    gdb, gdbserver: propagate use of target_desc unique pointers
    
    Propagate the use of target_desc unique pointers further.  Basically,
    avoid releasing target_desc objects, except in some spots in gdbserver
    (e.g. netbsd) where we don't currently have a persistent container for
    created target descriptions (and the target desc just leaks).  Introduce
    const_target_desc_up to change some `const target_desc *` to a unique
    pointer without loss of constness.
    
    Architectures that use the old regformats/regdat.sh don't need to be
    changed, because their target_desc objects are statically allocated in
    the generated files.
    
    I was able to built-test these native configs:
    
     - Linux AArch64
     - Linux ARC
     - Linux AMD64
     - Linux ARM
     - Linux LoongArch
     - Linux M68K
     - Linux Microblaze
     - Linux MIPS (32 and 64)
     - Linux or1k
     - Linux PPC (32 and 64)
     - Linux RISC-V
     - Linux s390x
     - Linux SH4
     - Linux Sparc (32 and 64)
     - Linux Xtensa
     - FreeBSD AMD64
     - NetBSD AMD64
     - Windows i686
     - Windows AMD64
    
    For the rest, I did my best by staring at the code long enough.  I
    probably missed or messed some spots, but that shouldn't be difficult to
    fix.
    
    Change-Id: I8db8790c57942edd2bfe890987157e2dc0c67879
    Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>

Diff:
---
 gdb/aarch32-tdep.c                                 | 11 ++----
 gdb/aarch64-tdep.c                                 | 15 +++-----
 gdb/alpha-tdep.c                                   |  2 +-
 gdb/amd64-tdep.c                                   | 27 +++++++------
 gdb/arch/aarch32.c                                 |  4 +-
 gdb/arch/aarch32.h                                 |  2 +-
 gdb/arch/aarch64.c                                 |  4 +-
 gdb/arch/aarch64.h                                 |  2 +-
 gdb/arch/amd64-linux-tdesc.c                       | 19 +++++-----
 gdb/arch/amd64.c                                   |  4 +-
 gdb/arch/amd64.h                                   |  6 +--
 gdb/arch/arm.c                                     | 28 +++++++-------
 gdb/arch/arm.h                                     |  5 ++-
 gdb/arch/i386-linux-tdesc.c                        | 19 +++++-----
 gdb/arch/i386.c                                    |  4 +-
 gdb/arch/i386.h                                    |  5 +--
 gdb/arch/loongarch.c                               | 19 +++-------
 gdb/arch/ppc-linux-common.c                        | 36 +++++++++---------
 gdb/arch/ppc-linux-tdesc.h                         | 42 +++++++++++----------
 gdb/arch/tic6x.c                                   |  4 +-
 gdb/arch/tic6x.h                                   |  4 +-
 gdb/arm-tdep.c                                     | 22 ++++-------
 gdb/features/alpha.c                               |  4 +-
 gdb/features/microblaze-linux.c                    |  4 +-
 gdb/features/microblaze-with-stack-protect.c       |  4 +-
 gdb/features/microblaze.c                          |  4 +-
 gdb/features/mips-dsp-linux.c                      |  4 +-
 gdb/features/mips-linux.c                          |  4 +-
 gdb/features/mips64-dsp-linux.c                    |  4 +-
 gdb/features/mips64-linux.c                        |  4 +-
 gdb/features/nds32.c                               |  4 +-
 gdb/features/or1k-linux.c                          |  4 +-
 gdb/features/or1k.c                                |  4 +-
 gdb/features/rs6000/powerpc-32.c                   |  4 +-
 gdb/features/rs6000/powerpc-32l.c                  |  4 +-
 gdb/features/rs6000/powerpc-403.c                  |  4 +-
 gdb/features/rs6000/powerpc-403gc.c                |  4 +-
 gdb/features/rs6000/powerpc-405.c                  |  4 +-
 gdb/features/rs6000/powerpc-505.c                  |  4 +-
 gdb/features/rs6000/powerpc-601.c                  |  4 +-
 gdb/features/rs6000/powerpc-602.c                  |  4 +-
 gdb/features/rs6000/powerpc-603.c                  |  4 +-
 gdb/features/rs6000/powerpc-604.c                  |  4 +-
 gdb/features/rs6000/powerpc-64.c                   |  4 +-
 gdb/features/rs6000/powerpc-64l.c                  |  4 +-
 gdb/features/rs6000/powerpc-7400.c                 |  4 +-
 gdb/features/rs6000/powerpc-750.c                  |  4 +-
 gdb/features/rs6000/powerpc-860.c                  |  4 +-
 gdb/features/rs6000/powerpc-altivec32.c            |  4 +-
 gdb/features/rs6000/powerpc-altivec32l.c           |  4 +-
 gdb/features/rs6000/powerpc-altivec64.c            |  4 +-
 gdb/features/rs6000/powerpc-altivec64l.c           |  4 +-
 gdb/features/rs6000/powerpc-e500.c                 |  4 +-
 gdb/features/rs6000/powerpc-e500l.c                |  4 +-
 gdb/features/rs6000/powerpc-isa205-32l.c           |  4 +-
 gdb/features/rs6000/powerpc-isa205-64l.c           |  4 +-
 gdb/features/rs6000/powerpc-isa205-altivec32l.c    |  4 +-
 gdb/features/rs6000/powerpc-isa205-altivec64l.c    |  4 +-
 .../rs6000/powerpc-isa205-ppr-dscr-vsx32l.c        |  4 +-
 .../rs6000/powerpc-isa205-ppr-dscr-vsx64l.c        |  4 +-
 gdb/features/rs6000/powerpc-isa205-vsx32l.c        |  4 +-
 gdb/features/rs6000/powerpc-isa205-vsx64l.c        |  4 +-
 gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c    |  4 +-
 gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c    |  4 +-
 gdb/features/rs6000/powerpc-isa207-vsx32l.c        |  4 +-
 gdb/features/rs6000/powerpc-isa207-vsx64l.c        |  4 +-
 gdb/features/rs6000/powerpc-vsx32.c                |  4 +-
 gdb/features/rs6000/powerpc-vsx32l.c               |  4 +-
 gdb/features/rs6000/powerpc-vsx64.c                |  4 +-
 gdb/features/rs6000/powerpc-vsx64l.c               |  4 +-
 gdb/features/rs6000/rs6000.c                       |  4 +-
 gdb/features/rx.c                                  |  4 +-
 gdb/features/s390-gs-linux64.c                     |  4 +-
 gdb/features/s390-linux32.c                        |  4 +-
 gdb/features/s390-linux32v1.c                      |  4 +-
 gdb/features/s390-linux32v2.c                      |  4 +-
 gdb/features/s390-linux64.c                        |  4 +-
 gdb/features/s390-linux64v1.c                      |  4 +-
 gdb/features/s390-linux64v2.c                      |  4 +-
 gdb/features/s390-te-linux64.c                     |  4 +-
 gdb/features/s390-tevx-linux64.c                   |  4 +-
 gdb/features/s390-vx-linux64.c                     |  4 +-
 gdb/features/s390x-gs-linux64.c                    |  4 +-
 gdb/features/s390x-linux64.c                       |  4 +-
 gdb/features/s390x-linux64v1.c                     |  4 +-
 gdb/features/s390x-linux64v2.c                     |  4 +-
 gdb/features/s390x-te-linux64.c                    |  4 +-
 gdb/features/s390x-tevx-linux64.c                  |  4 +-
 gdb/features/s390x-vx-linux64.c                    |  4 +-
 gdb/features/sparc/sparc32-solaris.c               |  4 +-
 gdb/features/sparc/sparc64-solaris.c               |  4 +-
 gdb/features/z80.c                                 |  4 +-
 gdb/i386-tdep.c                                    | 24 ++++++------
 gdb/microblaze-tdep.c                              |  6 +--
 gdb/mips-linux-nat.c                               |  7 ++--
 gdb/mips-linux-tdep.h                              | 10 +++--
 gdb/nds32-tdep.c                                   |  2 +-
 gdb/or1k-tdep.c                                    |  2 +-
 gdb/ppc-linux-nat.c                                |  2 +-
 gdb/ppc-tdep.h                                     | 11 +++---
 gdb/rs6000-aix-nat.c                               |  8 ++--
 gdb/rs6000-aix-tdep.c                              |  8 ++--
 gdb/rs6000-tdep.c                                  |  4 +-
 gdb/rx-tdep.c                                      |  2 +-
 gdb/s390-linux-nat.c                               |  6 +--
 gdb/s390-linux-tdep.c                              |  6 +--
 gdb/s390-linux-tdep.h                              | 32 ++++++++--------
 gdb/s390-tdep.c                                    |  4 +-
 gdb/s390-tdep.h                                    |  5 ++-
 gdb/target-descriptions.c                          |  6 +--
 gdb/z80-tdep.c                                     |  6 ++-
 gdbserver/linux-aarch32-tdesc.cc                   | 11 +++---
 gdbserver/linux-aarch64-tdesc.cc                   | 15 ++++----
 gdbserver/linux-arc-low.cc                         |  6 +--
 gdbserver/linux-arm-tdesc.cc                       | 14 +++----
 gdbserver/linux-ppc-ipa.cc                         | 42 ++++++++++-----------
 gdbserver/linux-ppc-low.cc                         | 44 +++++++++++-----------
 gdbserver/linux-tic6x-low.cc                       | 13 ++++---
 gdbserver/netbsd-aarch64-low.cc                    |  7 ++--
 gdbserver/netbsd-amd64-low.cc                      |  6 +--
 gdbserver/netbsd-i386-low.cc                       |  6 +--
 gdbserver/tdesc.cc                                 |  2 +-
 gdbserver/win32-i386-low.cc                        | 12 +++---
 gdbserver/win32-low.cc                             |  8 ++--
 gdbserver/win32-low.h                              |  5 ++-
 gdbsupport/tdesc.h                                 |  6 ++-
 126 files changed, 454 insertions(+), 458 deletions(-)

diff --git a/gdb/aarch32-tdep.c b/gdb/aarch32-tdep.c
index 8f27a4ee49e..54e67496a0e 100644
--- a/gdb/aarch32-tdep.c
+++ b/gdb/aarch32-tdep.c
@@ -20,20 +20,17 @@
 #include "gdbsupport/common-regcache.h"
 #include "arch/aarch32.h"
 
-static struct target_desc *tdesc_aarch32_list[2];
+static const_target_desc_up tdesc_aarch32_list[2];
 
 /* See aarch32-tdep.h.  */
 
 const target_desc *
 aarch32_read_description (bool tls)
 {
-  struct target_desc *tdesc = tdesc_aarch32_list[tls];
+  const_target_desc_up &tdesc = tdesc_aarch32_list[tls];
 
   if (tdesc == nullptr)
-    {
-      tdesc = aarch32_create_target_description (tls);
-      tdesc_aarch32_list[tls] = tdesc;
-    }
+    tdesc = aarch32_create_target_description (tls);
 
-  return tdesc;
+  return tdesc.get ();
 }
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index db8dff5d031..86bfa559ee6 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -54,7 +54,6 @@
 
 #include "opcode/aarch64.h"
 #include <algorithm>
-#include <unordered_map>
 
 /* For inferior_ptid and current_inferior ().  */
 #include "inferior.h"
@@ -66,7 +65,8 @@
 #define HA_MAX_NUM_FLDS		4
 
 /* All possible aarch64 target descriptors.  */
-static gdb::unordered_map <aarch64_features, target_desc *> tdesc_aarch64_map;
+static gdb::unordered_map <aarch64_features, const_target_desc_up>
+  tdesc_aarch64_map;
 
 /* The standard register names, and all the valid aliases for them.
    We're not adding fp here, that name is already taken, see
@@ -4029,15 +4029,12 @@ aarch64_read_description (const aarch64_features &features)
     error (_("VQ is %" PRIu64 ", maximum supported value is %d"), features.vq,
 	   AARCH64_MAX_SVE_VQ);
 
-  struct target_desc *tdesc = tdesc_aarch64_map[features];
+  const_target_desc_up &tdesc = tdesc_aarch64_map[features];
 
-  if (tdesc == NULL)
-    {
-      tdesc = aarch64_create_target_description (features);
-      tdesc_aarch64_map[features] = tdesc;
-    }
+  if (tdesc == nullptr)
+    tdesc = aarch64_create_target_description (features);
 
-  return tdesc;
+  return tdesc.get ();
 }
 
 /* Return the VQ used when creating the target description TDESC.  */
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index 2fd0317d99a..562450ea779 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -1702,7 +1702,7 @@ alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     return arches->gdbarch;
 
   if (tdesc == nullptr)
-    tdesc = tdesc_alpha;
+    tdesc = tdesc_alpha.get ();
 
   /* Validate target description.  */
   if (tdesc_has_registers (tdesc))
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index f7224ff76e7..63f05d4b452 100755
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -3716,21 +3716,20 @@ amd64_x32_none_init_abi (gdbarch_info info, gdbarch *arch)
 const struct target_desc *
 amd64_target_description (uint64_t xstate_bv, bool segments)
 {
-  static target_desc *amd64_tdescs \
+  static const_target_desc_up amd64_tdescs \
     [2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*CET_U*/][2/*segments*/] = {};
-  target_desc **tdesc;
-
-  tdesc = &amd64_tdescs[(xstate_bv & X86_XSTATE_AVX) ? 1 : 0]
-    [(xstate_bv & X86_XSTATE_AVX512) ? 1 : 0]
-    [(xstate_bv & X86_XSTATE_PKRU) ? 1 : 0]
-    [(xstate_bv & X86_XSTATE_CET_U) ? 1 : 0]
-    [segments ? 1 : 0];
-
-  if (*tdesc == NULL)
-    *tdesc = amd64_create_target_description (xstate_bv, false,
-					      false, segments);
-
-  return *tdesc;
+  const_target_desc_up &tdesc
+    = amd64_tdescs[(xstate_bv & X86_XSTATE_AVX) ? 1 : 0]
+		  [(xstate_bv & X86_XSTATE_AVX512) ? 1 : 0]
+		  [(xstate_bv & X86_XSTATE_PKRU) ? 1 : 0]
+		  [(xstate_bv & X86_XSTATE_CET_U) ? 1 : 0]
+		  [segments ? 1 : 0];
+
+  if (tdesc == nullptr)
+    tdesc = amd64_create_target_description (xstate_bv, false,
+					     false, segments);
+
+  return tdesc.get ();
 }
 
 #if GDB_SELF_TEST
diff --git a/gdb/arch/aarch32.c b/gdb/arch/aarch32.c
index 9ae69fd589e..489215c6c1c 100644
--- a/gdb/arch/aarch32.c
+++ b/gdb/arch/aarch32.c
@@ -23,7 +23,7 @@
 
 /* See aarch32.h.  */
 
-target_desc *
+target_desc_up
 aarch32_create_target_description (bool tls)
 {
   target_desc_up tdesc = allocate_target_description ();
@@ -41,5 +41,5 @@ aarch32_create_target_description (bool tls)
   if (tls)
     regnum = create_feature_arm_arm_tls (tdesc.get (), regnum);
 
-  return tdesc.release ();
+  return tdesc;
 }
diff --git a/gdb/arch/aarch32.h b/gdb/arch/aarch32.h
index 7dd43f804e6..eff96673d85 100644
--- a/gdb/arch/aarch32.h
+++ b/gdb/arch/aarch32.h
@@ -22,6 +22,6 @@
 
 /* Create the AArch32 target description.  */
 
-target_desc *aarch32_create_target_description (bool tls);
+target_desc_up aarch32_create_target_description (bool tls);
 
 #endif /* GDB_ARCH_AARCH32_H */
diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c
index 622138f43b5..091b4e2982c 100644
--- a/gdb/arch/aarch64.c
+++ b/gdb/arch/aarch64.c
@@ -32,7 +32,7 @@
 
 /* See arch/aarch64.h.  */
 
-target_desc *
+target_desc_up
 aarch64_create_target_description (const aarch64_features &features)
 {
   target_desc_up tdesc = allocate_target_description ();
@@ -77,7 +77,7 @@ aarch64_create_target_description (const aarch64_features &features)
   if (features.fpmr)
     regnum = create_feature_aarch64_fpmr (tdesc.get (), regnum);
 
-  return tdesc.release ();
+  return tdesc;
 }
 
 /* See arch/aarch64.h.  */
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index bcbf47dc3a3..16e91c51aad 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -109,7 +109,7 @@ namespace std
 
 /* Create the aarch64 target description.  */
 
-target_desc *
+target_desc_up
   aarch64_create_target_description (const aarch64_features &features);
 
 /* Given a pointer value POINTER and a MASK of non-address bits, remove the
diff --git a/gdb/arch/amd64-linux-tdesc.c b/gdb/arch/amd64-linux-tdesc.c
index 4a7f2329f23..eefa3c45b6e 100644
--- a/gdb/arch/amd64-linux-tdesc.c
+++ b/gdb/arch/amd64-linux-tdesc.c
@@ -30,7 +30,7 @@ const struct target_desc *
 amd64_linux_read_description (uint64_t xstate_bv, bool is_x32)
 {
   /* The type used for the amd64 and x32 target description caches.  */
-  using tdesc_cache_type = gdb::unordered_map<uint64_t, target_desc_up>;
+  using tdesc_cache_type = gdb::unordered_map<uint64_t, const_target_desc_up>;
 
   /* Caches for the previously seen amd64 and x32 target descriptions,
      indexed by the xstate_bv value that created the target
@@ -50,19 +50,18 @@ amd64_linux_read_description (uint64_t xstate_bv, bool is_x32)
     ? x86_linux_x32_xstate_bv_feature_mask ()
     : x86_linux_amd64_xstate_bv_feature_mask ();
 
-  const auto it = tdesc_cache.find (xstate_bv);
-  if (it != tdesc_cache.end ())
-    return it->second.get ();
+  const_target_desc_up &tdesc = tdesc_cache[xstate_bv];
+  if (tdesc != nullptr)
+    return tdesc.get ();
 
   /* Create the previously unseen target description.  */
-  target_desc_up tdesc (amd64_create_target_description (xstate_bv, is_x32,
-							 true, true));
-  x86_linux_post_init_tdesc (tdesc.get (), true);
+  target_desc_up new_tdesc
+    = amd64_create_target_description (xstate_bv, is_x32, true, true);
+  x86_linux_post_init_tdesc (new_tdesc.get (), true);
 
   /* Add to the cache, and return a pointer borrowed from the
      target_desc_up.  This is safe as the cache (and the pointers contained
      within it) are not deleted until GDB exits.  */
-  target_desc *ptr = tdesc.get ();
-  tdesc_cache.emplace (xstate_bv, std::move (tdesc));
-  return ptr;
+  tdesc = std::move (new_tdesc);
+  return tdesc.get ();
 }
diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
index 9fbe8026600..01a0de2d5f3 100644
--- a/gdb/arch/amd64.c
+++ b/gdb/arch/amd64.c
@@ -34,7 +34,7 @@
 
 /* See arch/amd64.h.  */
 
-target_desc *
+target_desc_up
 amd64_create_target_description (uint64_t xstate_bv, bool is_x32,
 				 bool is_linux, bool segments)
 {
@@ -78,5 +78,5 @@ amd64_create_target_description (uint64_t xstate_bv, bool is_x32,
 	regnum = create_feature_i386_32bit_ssp (tdesc.get (), regnum);
     }
 
-  return tdesc.release ();
+  return tdesc;
 }
diff --git a/gdb/arch/amd64.h b/gdb/arch/amd64.h
index 60c17ebc42d..1782d39cc59 100644
--- a/gdb/arch/amd64.h
+++ b/gdb/arch/amd64.h
@@ -26,8 +26,8 @@
    target descriptions for Linux.  If SEGMENTS is true, then include
    the "org.gnu.gdb.i386.segments" feature registers.  */
 
-target_desc *amd64_create_target_description (uint64_t xstate_bv,
-					      bool is_x32, bool is_linux,
-					      bool segments);
+target_desc_up amd64_create_target_description (uint64_t xstate_bv,
+						bool is_x32, bool is_linux,
+						bool segments);
 
 #endif /* GDB_ARCH_AMD64_H */
diff --git a/gdb/arch/arm.c b/gdb/arch/arm.c
index 1843dbee612..36241f70f8f 100644
--- a/gdb/arch/arm.c
+++ b/gdb/arch/arm.c
@@ -373,7 +373,7 @@ shifted_reg_val (reg_buffer_common *regcache, unsigned long inst,
 
 /* See arch/arm.h.  */
 
-target_desc *
+target_desc_up
 arm_create_target_description (arm_fp_type fp_type, bool tls)
 {
   target_desc_up tdesc = allocate_target_description ();
@@ -413,18 +413,18 @@ arm_create_target_description (arm_fp_type fp_type, bool tls)
   if (tls)
     regnum = create_feature_arm_arm_tls (tdesc.get (), regnum);
 
-  return tdesc.release ();
+  return tdesc;
 }
 
 /* See arch/arm.h.  */
 
-target_desc *
+target_desc_up
 arm_create_mprofile_target_description (arm_m_profile_type m_type)
 {
-  target_desc *tdesc = allocate_target_description ().release ();
+  target_desc_up tdesc = allocate_target_description ();
 
 #ifndef IN_PROCESS_AGENT
-  set_tdesc_architecture (tdesc, "arm");
+  set_tdesc_architecture (tdesc.get (), "arm");
 #endif
 
   long regnum = 0;
@@ -432,27 +432,27 @@ arm_create_mprofile_target_description (arm_m_profile_type m_type)
   switch (m_type)
     {
     case ARM_M_TYPE_M_PROFILE:
-      regnum = create_feature_arm_arm_m_profile (tdesc, regnum);
+      regnum = create_feature_arm_arm_m_profile (tdesc.get (), regnum);
       break;
 
     case ARM_M_TYPE_VFP_D16:
-      regnum = create_feature_arm_arm_m_profile (tdesc, regnum);
-      regnum = create_feature_arm_arm_vfpv2 (tdesc, regnum);
+      regnum = create_feature_arm_arm_m_profile (tdesc.get (), regnum);
+      regnum = create_feature_arm_arm_vfpv2 (tdesc.get (), regnum);
       break;
 
     case ARM_M_TYPE_WITH_FPA:
-      regnum = create_feature_arm_arm_m_profile_with_fpa (tdesc, regnum);
+      regnum = create_feature_arm_arm_m_profile_with_fpa (tdesc.get (), regnum);
       break;
 
     case ARM_M_TYPE_MVE:
-      regnum = create_feature_arm_arm_m_profile (tdesc, regnum);
-      regnum = create_feature_arm_arm_vfpv2 (tdesc, regnum);
-      regnum = create_feature_arm_arm_m_profile_mve (tdesc, regnum);
+      regnum = create_feature_arm_arm_m_profile (tdesc.get (), regnum);
+      regnum = create_feature_arm_arm_vfpv2 (tdesc.get (), regnum);
+      regnum = create_feature_arm_arm_m_profile_mve (tdesc.get (), regnum);
       break;
 
     case ARM_M_TYPE_SYSTEM:
-      regnum = create_feature_arm_arm_m_profile (tdesc, regnum);
-      regnum = create_feature_arm_arm_m_system (tdesc, regnum);
+      regnum = create_feature_arm_arm_m_profile (tdesc.get (), regnum);
+      regnum = create_feature_arm_arm_m_system (tdesc.get (), regnum);
       break;
 
     default:
diff --git a/gdb/arch/arm.h b/gdb/arch/arm.h
index d9c750329a4..3e99e1bf6af 100644
--- a/gdb/arch/arm.h
+++ b/gdb/arch/arm.h
@@ -238,10 +238,11 @@ unsigned long shifted_reg_val (reg_buffer_common *regcache,
 
 /* Create an Arm target description with the given FP hardware type.  */
 
-target_desc *arm_create_target_description (arm_fp_type fp_type, bool tls);
+target_desc_up arm_create_target_description (arm_fp_type fp_type, bool tls);
 
 /* Create an Arm M-profile target description with the given hardware type.  */
 
-target_desc *arm_create_mprofile_target_description (arm_m_profile_type m_type);
+target_desc_up arm_create_mprofile_target_description
+  (arm_m_profile_type m_type);
 
 #endif /* GDB_ARCH_ARM_H */
diff --git a/gdb/arch/i386-linux-tdesc.c b/gdb/arch/i386-linux-tdesc.c
index 74f192b9c37..c3ee3028785 100644
--- a/gdb/arch/i386-linux-tdesc.c
+++ b/gdb/arch/i386-linux-tdesc.c
@@ -32,7 +32,7 @@ i386_linux_read_description (uint64_t xstate_bv)
      xstate_bv value that created the target description.  This
      needs to be static within this function to ensure it is initialised
      before first use.  */
-  static gdb::unordered_map<uint64_t, target_desc_up> i386_tdesc_cache;
+  static gdb::unordered_map<uint64_t, const_target_desc_up> i386_tdesc_cache;
 
   /* Only some bits are checked when creating a tdesc, but the
      XSTATE_BV value contains other feature bits that are not relevant
@@ -42,19 +42,18 @@ i386_linux_read_description (uint64_t xstate_bv)
      set.  */
   xstate_bv &= x86_linux_i386_xstate_bv_feature_mask ();
 
-  const auto it = i386_tdesc_cache.find (xstate_bv);
-  if (it != i386_tdesc_cache.end ())
-    return it->second.get ();
+  const_target_desc_up &tdesc = i386_tdesc_cache[xstate_bv];
+  if (tdesc != nullptr)
+    return tdesc.get ();
 
   /* Create the previously unseen target description.  */
-  target_desc_up tdesc
-    (i386_create_target_description (xstate_bv, true, false));
-  x86_linux_post_init_tdesc (tdesc.get (), false);
+  target_desc_up new_tdesc
+    = i386_create_target_description (xstate_bv, true, false);
+  x86_linux_post_init_tdesc (new_tdesc.get (), false);
 
   /* Add to the cache, and return a pointer borrowed from the
      target_desc_up.  This is safe as the cache (and the pointers contained
      within it) are not deleted until GDB exits.  */
-  target_desc *ptr = tdesc.get ();
-  i386_tdesc_cache.emplace (xstate_bv, std::move (tdesc));
-  return ptr;
+  tdesc = std::move (new_tdesc);
+  return tdesc.get ();
 }
diff --git a/gdb/arch/i386.c b/gdb/arch/i386.c
index 4ec4f103111..88aa22323f6 100644
--- a/gdb/arch/i386.c
+++ b/gdb/arch/i386.c
@@ -32,7 +32,7 @@
 
 /* See arch/i386.h.  */
 
-target_desc *
+target_desc_up
 i386_create_target_description (uint64_t xstate_bv, bool is_linux,
 				bool segments)
 {
@@ -70,5 +70,5 @@ i386_create_target_description (uint64_t xstate_bv, bool is_linux,
   if (xstate_bv & X86_XSTATE_CET_U)
     regnum = create_feature_i386_32bit_ssp (tdesc.get (), regnum);
 
-  return tdesc.release ();
+  return tdesc;
 }
diff --git a/gdb/arch/i386.h b/gdb/arch/i386.h
index 91a581f83ee..145ed151acd 100644
--- a/gdb/arch/i386.h
+++ b/gdb/arch/i386.h
@@ -25,8 +25,7 @@
    true, create target descriptions for Linux.  If SEGMENTS is true, then
    include the "org.gnu.gdb.i386.segments" feature registers.  */
 
-target_desc *i386_create_target_description (uint64_t xstate_bv,
-					     bool is_linux,
-					     bool segments);
+target_desc_up i386_create_target_description (uint64_t xstate_bv,
+					       bool is_linux, bool segments);
 
 #endif /* GDB_ARCH_I386_H */
diff --git a/gdb/arch/loongarch.c b/gdb/arch/loongarch.c
index 25e698d9fce..395c3db0614 100644
--- a/gdb/arch/loongarch.c
+++ b/gdb/arch/loongarch.c
@@ -89,7 +89,7 @@ struct loongarch_gdbarch_features_hasher
 /* Cache of previously seen target descriptions, indexed by the feature set
    that created them.  */
 static std::unordered_map<loongarch_gdbarch_features,
-			  const target_desc_up,
+			  const_target_desc_up,
 			  loongarch_gdbarch_features_hasher> loongarch_tdesc_cache;
 
 const target_desc *
@@ -98,18 +98,11 @@ loongarch_lookup_target_description (const struct loongarch_gdbarch_features fea
   /* Lookup in the cache.  If we find it then return the pointer out of
      the target_desc_up (which is a unique_ptr).  This is safe as the
      loongarch_tdesc_cache will exist until GDB exits.  */
-  const auto it = loongarch_tdesc_cache.find (features);
-  if (it != loongarch_tdesc_cache.end ())
-    return it->second.get ();
-
-  target_desc_up tdesc (loongarch_create_target_description (features));
-
-  /* Add to the cache, and return a pointer borrowed from the
-     target_desc_up.  This is safe as the cache (and the pointers
-     contained within it) are not deleted until GDB exits.  */
-  target_desc *ptr = tdesc.get ();
-  loongarch_tdesc_cache.emplace (features, std::move (tdesc));
-  return ptr;
+  const_target_desc_up &tdesc = loongarch_tdesc_cache[features];
+  if (tdesc == nullptr)
+    tdesc = loongarch_create_target_description (features);
+
+  return tdesc.get ();
 }
 
 #endif /* !GDBSERVER */
diff --git a/gdb/arch/ppc-linux-common.c b/gdb/arch/ppc-linux-common.c
index 2088b7656b1..40c54c191a6 100644
--- a/gdb/arch/ppc-linux-common.c
+++ b/gdb/arch/ppc-linux-common.c
@@ -50,34 +50,34 @@ ppc_linux_match_description (struct ppc_linux_features features)
   if (features.wordsize == 8)
     {
       if (features.vsx)
-	tdesc = (features.htm? tdesc_powerpc_isa207_htm_vsx64l
-		 : features.isa207? tdesc_powerpc_isa207_vsx64l
-		 : features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx64l
-		 : features.isa205? tdesc_powerpc_isa205_vsx64l
-		 : tdesc_powerpc_vsx64l);
+	tdesc = (features.htm ? tdesc_powerpc_isa207_htm_vsx64l
+		 : features.isa207 ? tdesc_powerpc_isa207_vsx64l
+		 : features.ppr_dscr ? tdesc_powerpc_isa205_ppr_dscr_vsx64l
+		 : features.isa205 ? tdesc_powerpc_isa205_vsx64l
+		 : tdesc_powerpc_vsx64l).get ();
       else if (features.altivec)
-	tdesc = (features.isa205? tdesc_powerpc_isa205_altivec64l
-		 : tdesc_powerpc_altivec64l);
+	tdesc = (features.isa205 ? tdesc_powerpc_isa205_altivec64l
+		 : tdesc_powerpc_altivec64l).get ();
       else
-	tdesc = (features.isa205? tdesc_powerpc_isa205_64l
-		 : tdesc_powerpc_64l);
+	tdesc = (features.isa205 ? tdesc_powerpc_isa205_64l
+		 : tdesc_powerpc_64l).get ();
     }
   else
     {
       gdb_assert (features.wordsize == 4);
 
       if (features.vsx)
-	tdesc = (features.htm? tdesc_powerpc_isa207_htm_vsx32l
-		 : features.isa207? tdesc_powerpc_isa207_vsx32l
-		 : features.ppr_dscr? tdesc_powerpc_isa205_ppr_dscr_vsx32l
-		 : features.isa205? tdesc_powerpc_isa205_vsx32l
-		 : tdesc_powerpc_vsx32l);
+	tdesc = (features.htm ? tdesc_powerpc_isa207_htm_vsx32l
+		 : features.isa207 ? tdesc_powerpc_isa207_vsx32l
+		 : features.ppr_dscr ? tdesc_powerpc_isa205_ppr_dscr_vsx32l
+		 : features.isa205 ? tdesc_powerpc_isa205_vsx32l
+		 : tdesc_powerpc_vsx32l).get ();
       else if (features.altivec)
-	tdesc = (features.isa205? tdesc_powerpc_isa205_altivec32l
-		 : tdesc_powerpc_altivec32l);
+	tdesc = (features.isa205 ? tdesc_powerpc_isa205_altivec32l
+		 : tdesc_powerpc_altivec32l).get ();
       else
-	tdesc = (features.isa205? tdesc_powerpc_isa205_32l
-		 : tdesc_powerpc_32l);
+	tdesc = (features.isa205 ? tdesc_powerpc_isa205_32l
+		 : tdesc_powerpc_32l).get ();
     }
 
   gdb_assert (tdesc != NULL);
diff --git a/gdb/arch/ppc-linux-tdesc.h b/gdb/arch/ppc-linux-tdesc.h
index 1ff316ad826..fbed67a7990 100644
--- a/gdb/arch/ppc-linux-tdesc.h
+++ b/gdb/arch/ppc-linux-tdesc.h
@@ -20,27 +20,29 @@
 #ifndef GDB_ARCH_PPC_LINUX_TDESC_H
 #define GDB_ARCH_PPC_LINUX_TDESC_H
 
+#include "gdbsupport/tdesc.h"
+
 struct target_desc;
 
-extern const struct target_desc *tdesc_powerpc_32l;
-extern const struct target_desc *tdesc_powerpc_altivec32l;
-extern const struct target_desc *tdesc_powerpc_vsx32l;
-extern const struct target_desc *tdesc_powerpc_isa205_32l;
-extern const struct target_desc *tdesc_powerpc_isa205_altivec32l;
-extern const struct target_desc *tdesc_powerpc_isa205_vsx32l;
-extern const struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx32l;
-extern const struct target_desc *tdesc_powerpc_isa207_vsx32l;
-extern const struct target_desc *tdesc_powerpc_isa207_htm_vsx32l;
-extern const struct target_desc *tdesc_powerpc_e500l;
-
-extern const struct target_desc *tdesc_powerpc_64l;
-extern const struct target_desc *tdesc_powerpc_altivec64l;
-extern const struct target_desc *tdesc_powerpc_vsx64l;
-extern const struct target_desc *tdesc_powerpc_isa205_64l;
-extern const struct target_desc *tdesc_powerpc_isa205_altivec64l;
-extern const struct target_desc *tdesc_powerpc_isa205_vsx64l;
-extern const struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx64l;
-extern const struct target_desc *tdesc_powerpc_isa207_vsx64l;
-extern const struct target_desc *tdesc_powerpc_isa207_htm_vsx64l;
+extern const_target_desc_up tdesc_powerpc_32l;
+extern const_target_desc_up tdesc_powerpc_altivec32l;
+extern const_target_desc_up tdesc_powerpc_vsx32l;
+extern const_target_desc_up tdesc_powerpc_isa205_32l;
+extern const_target_desc_up tdesc_powerpc_isa205_altivec32l;
+extern const_target_desc_up tdesc_powerpc_isa205_vsx32l;
+extern const_target_desc_up tdesc_powerpc_isa205_ppr_dscr_vsx32l;
+extern const_target_desc_up tdesc_powerpc_isa207_vsx32l;
+extern const_target_desc_up tdesc_powerpc_isa207_htm_vsx32l;
+extern const_target_desc_up tdesc_powerpc_e500l;
+
+extern const_target_desc_up tdesc_powerpc_64l;
+extern const_target_desc_up tdesc_powerpc_altivec64l;
+extern const_target_desc_up tdesc_powerpc_vsx64l;
+extern const_target_desc_up tdesc_powerpc_isa205_64l;
+extern const_target_desc_up tdesc_powerpc_isa205_altivec64l;
+extern const_target_desc_up tdesc_powerpc_isa205_vsx64l;
+extern const_target_desc_up tdesc_powerpc_isa205_ppr_dscr_vsx64l;
+extern const_target_desc_up tdesc_powerpc_isa207_vsx64l;
+extern const_target_desc_up tdesc_powerpc_isa207_htm_vsx64l;
 
 #endif /* GDB_ARCH_PPC_LINUX_TDESC_H */
diff --git a/gdb/arch/tic6x.c b/gdb/arch/tic6x.c
index 57243051608..ecfbd559f2b 100644
--- a/gdb/arch/tic6x.c
+++ b/gdb/arch/tic6x.c
@@ -25,7 +25,7 @@
 
 /* Create tic6x target descriptions according to FEATURE.  */
 
-target_desc *
+target_desc_up
 tic6x_create_target_description (enum c6x_feature feature)
 {
   target_desc_up tdesc = allocate_target_description ();
@@ -43,5 +43,5 @@ tic6x_create_target_description (enum c6x_feature feature)
   if (feature == C6X_C6XP)
     regnum = create_feature_tic6x_c6xp (tdesc.get (), regnum);
 
-  return tdesc.release ();
+  return tdesc;
 }
diff --git a/gdb/arch/tic6x.h b/gdb/arch/tic6x.h
index 6120892113e..30950e740b2 100644
--- a/gdb/arch/tic6x.h
+++ b/gdb/arch/tic6x.h
@@ -18,6 +18,8 @@
 #ifndef GDB_ARCH_TIC6X_H
 #define GDB_ARCH_TIC6X_H
 
+#include "gdbsupport/tdesc.h"
+
 enum c6x_feature
 {
   C6X_CORE,
@@ -26,6 +28,6 @@ enum c6x_feature
   C6X_LAST,
 };
 
-target_desc *tic6x_create_target_description (enum c6x_feature feature);
+target_desc_up tic6x_create_target_description (c6x_feature feature);
 
 #endif /* GDB_ARCH_TIC6X_H */
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 8845ef27acc..eef985bb276 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -240,8 +240,8 @@ 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][2];
-static struct target_desc *tdesc_arm_mprofile_list[ARM_M_TYPE_INVALID];
+static const_target_desc_up tdesc_arm_list[ARM_FP_TYPE_INVALID][2];
+static const_target_desc_up tdesc_arm_mprofile_list[ARM_M_TYPE_INVALID];
 
 /* This is used to keep the bfd arch_info in sync with the disassembly
    style.  */
@@ -14961,15 +14961,12 @@ arm_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
 const target_desc *
 arm_read_description (arm_fp_type fp_type, bool tls)
 {
-  struct target_desc *tdesc = tdesc_arm_list[fp_type][tls];
+  const_target_desc_up &tdesc = tdesc_arm_list[fp_type][tls];
 
   if (tdesc == nullptr)
-    {
-      tdesc = arm_create_target_description (fp_type, tls);
-      tdesc_arm_list[fp_type][tls] = tdesc;
-    }
+    tdesc = arm_create_target_description (fp_type, tls);
 
-  return tdesc;
+  return tdesc.get ();
 }
 
 /* See arm-tdep.h.  */
@@ -14977,13 +14974,10 @@ arm_read_description (arm_fp_type fp_type, bool tls)
 const target_desc *
 arm_read_mprofile_description (arm_m_profile_type m_type)
 {
-  struct target_desc *tdesc = tdesc_arm_mprofile_list[m_type];
+  const_target_desc_up &tdesc = tdesc_arm_mprofile_list[m_type];
 
   if (tdesc == nullptr)
-    {
-      tdesc = arm_create_mprofile_target_description (m_type);
-      tdesc_arm_mprofile_list[m_type] = tdesc;
-    }
+    tdesc = arm_create_mprofile_target_description (m_type);
 
-  return tdesc;
+  return tdesc.get ();
 }
diff --git a/gdb/features/alpha.c b/gdb/features/alpha.c
index 35f12fcbd4c..73d3fdf6804 100644
--- a/gdb/features/alpha.c
+++ b/gdb/features/alpha.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_alpha;
+const_target_desc_up tdesc_alpha;
 static void
 initialize_tdesc_alpha (void)
 {
@@ -107,5 +107,5 @@ initialize_tdesc_alpha (void)
   tdesc_create_reg (feature, "", 65, 0, NULL, 64, "int64");
   tdesc_create_reg (feature, "unique", 66, 1, "system", 64, "int64");
 
-  tdesc_alpha = result.release ();
+  tdesc_alpha = std::move (result);
 }
diff --git a/gdb/features/microblaze-linux.c b/gdb/features/microblaze-linux.c
index 087865cd41c..9f9fae38b5c 100644
--- a/gdb/features/microblaze-linux.c
+++ b/gdb/features/microblaze-linux.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_microblaze_linux;
+const_target_desc_up tdesc_microblaze_linux;
 static void
 initialize_tdesc_microblaze_linux (void)
 {
@@ -74,5 +74,5 @@ initialize_tdesc_microblaze_linux (void)
   tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
 
-  tdesc_microblaze_linux = result.release ();
+  tdesc_microblaze_linux = std::move (result);
 }
diff --git a/gdb/features/microblaze-with-stack-protect.c b/gdb/features/microblaze-with-stack-protect.c
index e5c0956610a..a3e75d123a2 100644
--- a/gdb/features/microblaze-with-stack-protect.c
+++ b/gdb/features/microblaze-with-stack-protect.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_microblaze_with_stack_protect;
+const_target_desc_up tdesc_microblaze_with_stack_protect;
 static void
 initialize_tdesc_microblaze_with_stack_protect (void)
 {
@@ -74,5 +74,5 @@ initialize_tdesc_microblaze_with_stack_protect (void)
   tdesc_create_reg (feature, "rslr", 57, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "rshr", 58, 1, NULL, 32, "int");
 
-  tdesc_microblaze_with_stack_protect = result.release ();
+  tdesc_microblaze_with_stack_protect = std::move (result);
 }
diff --git a/gdb/features/microblaze.c b/gdb/features/microblaze.c
index 32ae3b02ad7..fe367f3b82f 100644
--- a/gdb/features/microblaze.c
+++ b/gdb/features/microblaze.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_microblaze;
+const_target_desc_up tdesc_microblaze;
 static void
 initialize_tdesc_microblaze (void)
 {
@@ -70,5 +70,5 @@ initialize_tdesc_microblaze (void)
   tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
 
-  tdesc_microblaze = result.release ();
+  tdesc_microblaze = std::move (result);
 }
diff --git a/gdb/features/mips-dsp-linux.c b/gdb/features/mips-dsp-linux.c
index 4873037b69d..62771b72b94 100644
--- a/gdb/features/mips-dsp-linux.c
+++ b/gdb/features/mips-dsp-linux.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_mips_dsp_linux;
+const_target_desc_up tdesc_mips_dsp_linux;
 static void
 initialize_tdesc_mips_dsp_linux (void)
 {
@@ -105,5 +105,5 @@ initialize_tdesc_mips_dsp_linux (void)
   feature = tdesc_create_feature (result.get (), "org.gnu.gdb.mips.linux");
   tdesc_create_reg (feature, "restart", 79, 1, "system", 32, "int");
 
-  tdesc_mips_dsp_linux = result.release ();
+  tdesc_mips_dsp_linux = std::move (result);
 }
diff --git a/gdb/features/mips-linux.c b/gdb/features/mips-linux.c
index 5ff2e5fb92d..ae668ae6ac9 100644
--- a/gdb/features/mips-linux.c
+++ b/gdb/features/mips-linux.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_mips_linux;
+const_target_desc_up tdesc_mips_linux;
 static void
 initialize_tdesc_mips_linux (void)
 {
@@ -96,5 +96,5 @@ initialize_tdesc_mips_linux (void)
   feature = tdesc_create_feature (result.get (), "org.gnu.gdb.mips.linux");
   tdesc_create_reg (feature, "restart", 72, 1, "system", 32, "int");
 
-  tdesc_mips_linux = result.release ();
+  tdesc_mips_linux = std::move (result);
 }
diff --git a/gdb/features/mips64-dsp-linux.c b/gdb/features/mips64-dsp-linux.c
index 646f5487f49..f186394ebb9 100644
--- a/gdb/features/mips64-dsp-linux.c
+++ b/gdb/features/mips64-dsp-linux.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_mips64_dsp_linux;
+const_target_desc_up tdesc_mips64_dsp_linux;
 static void
 initialize_tdesc_mips64_dsp_linux (void)
 {
@@ -105,5 +105,5 @@ initialize_tdesc_mips64_dsp_linux (void)
   feature = tdesc_create_feature (result.get (), "org.gnu.gdb.mips.linux");
   tdesc_create_reg (feature, "restart", 79, 1, "system", 64, "int");
 
-  tdesc_mips64_dsp_linux = result.release ();
+  tdesc_mips64_dsp_linux = std::move (result);
 }
diff --git a/gdb/features/mips64-linux.c b/gdb/features/mips64-linux.c
index 98b3d34448d..168b8d83477 100644
--- a/gdb/features/mips64-linux.c
+++ b/gdb/features/mips64-linux.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_mips64_linux;
+const_target_desc_up tdesc_mips64_linux;
 static void
 initialize_tdesc_mips64_linux (void)
 {
@@ -96,5 +96,5 @@ initialize_tdesc_mips64_linux (void)
   feature = tdesc_create_feature (result.get (), "org.gnu.gdb.mips.linux");
   tdesc_create_reg (feature, "restart", 72, 1, "system", 64, "int");
 
-  tdesc_mips64_linux = result.release ();
+  tdesc_mips64_linux = std::move (result);
 }
diff --git a/gdb/features/nds32.c b/gdb/features/nds32.c
index e5c5d50dce1..46e86ef0ed2 100644
--- a/gdb/features/nds32.c
+++ b/gdb/features/nds32.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_nds32;
+const_target_desc_up tdesc_nds32;
 static void
 initialize_tdesc_nds32 (void)
 {
@@ -87,5 +87,5 @@ initialize_tdesc_nds32 (void)
   tdesc_create_reg (feature, "itb", 66, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "ifc_lp", 67, 1, NULL, 32, "int");
 
-  tdesc_nds32 = result.release ();
+  tdesc_nds32 = std::move (result);
 }
diff --git a/gdb/features/or1k-linux.c b/gdb/features/or1k-linux.c
index 85a681f89ba..51e8412cd5c 100644
--- a/gdb/features/or1k-linux.c
+++ b/gdb/features/or1k-linux.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_or1k_linux;
+const_target_desc_up tdesc_or1k_linux;
 static void
 initialize_tdesc_or1k_linux (void)
 {
@@ -73,5 +73,5 @@ initialize_tdesc_or1k_linux (void)
   tdesc_create_reg (feature, "npc", 33, 1, NULL, 32, "code_ptr");
   tdesc_create_reg (feature, "sr", 34, 1, NULL, 32, "sr_flags");
 
-  tdesc_or1k_linux = result.release ();
+  tdesc_or1k_linux = std::move (result);
 }
diff --git a/gdb/features/or1k.c b/gdb/features/or1k.c
index ee5e2f5b206..2a62e72837c 100644
--- a/gdb/features/or1k.c
+++ b/gdb/features/or1k.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_or1k;
+const_target_desc_up tdesc_or1k;
 static void
 initialize_tdesc_or1k (void)
 {
@@ -71,5 +71,5 @@ initialize_tdesc_or1k (void)
   tdesc_create_reg (feature, "npc", 33, 1, NULL, 32, "code_ptr");
   tdesc_create_reg (feature, "sr", 34, 1, NULL, 32, "sr_flags");
 
-  tdesc_or1k = result.release ();
+  tdesc_or1k = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-32.c b/gdb/features/rs6000/powerpc-32.c
index 562761e69a5..9fc7e572e2f 100644
--- a/gdb/features/rs6000/powerpc-32.c
+++ b/gdb/features/rs6000/powerpc-32.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_32;
+const_target_desc_up tdesc_powerpc_32;
 static void
 initialize_tdesc_powerpc_32 (void)
 {
@@ -88,5 +88,5 @@ initialize_tdesc_powerpc_32 (void)
   tdesc_create_reg (feature, "f31", 63, 1, NULL, 64, "ieee_double");
   tdesc_create_reg (feature, "fpscr", 70, 1, "float", 32, "int");
 
-  tdesc_powerpc_32 = result.release ();
+  tdesc_powerpc_32 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-32l.c b/gdb/features/rs6000/powerpc-32l.c
index caf81b76017..5e734af9f8d 100644
--- a/gdb/features/rs6000/powerpc-32l.c
+++ b/gdb/features/rs6000/powerpc-32l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_32l;
+const_target_desc_up tdesc_powerpc_32l;
 static void
 initialize_tdesc_powerpc_32l (void)
 {
@@ -92,5 +92,5 @@ initialize_tdesc_powerpc_32l (void)
   tdesc_create_reg (feature, "orig_r3", 71, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "trap", 72, 1, NULL, 32, "int");
 
-  tdesc_powerpc_32l = result.release ();
+  tdesc_powerpc_32l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-403.c b/gdb/features/rs6000/powerpc-403.c
index 7cff21ceed7..23c863669e9 100644
--- a/gdb/features/rs6000/powerpc-403.c
+++ b/gdb/features/rs6000/powerpc-403.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_403;
+const_target_desc_up tdesc_powerpc_403;
 static void
 initialize_tdesc_powerpc_403 (void)
 {
@@ -162,5 +162,5 @@ initialize_tdesc_powerpc_403 (void)
   tdesc_create_reg (feature, "pbl2", 141, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "pbu2", 142, 1, NULL, 32, "int");
 
-  tdesc_powerpc_403 = result.release ();
+  tdesc_powerpc_403 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-403gc.c b/gdb/features/rs6000/powerpc-403gc.c
index e86b51c4346..6bba1400997 100644
--- a/gdb/features/rs6000/powerpc-403gc.c
+++ b/gdb/features/rs6000/powerpc-403gc.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_403gc;
+const_target_desc_up tdesc_powerpc_403gc;
 static void
 initialize_tdesc_powerpc_403gc (void)
 {
@@ -168,5 +168,5 @@ initialize_tdesc_powerpc_403gc (void)
   tdesc_create_reg (feature, "tbhu", 147, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "tblu", 148, 1, NULL, 32, "int");
 
-  tdesc_powerpc_403gc = result.release ();
+  tdesc_powerpc_403gc = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-405.c b/gdb/features/rs6000/powerpc-405.c
index 2716e37d8a8..c55a4bcf12b 100644
--- a/gdb/features/rs6000/powerpc-405.c
+++ b/gdb/features/rs6000/powerpc-405.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_405;
+const_target_desc_up tdesc_powerpc_405;
 static void
 initialize_tdesc_powerpc_405 (void)
 {
@@ -131,5 +131,5 @@ initialize_tdesc_powerpc_405 (void)
   tdesc_create_reg (feature, "su0r", 160, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "usprg0", 161, 1, NULL, 32, "int");
 
-  tdesc_powerpc_405 = result.release ();
+  tdesc_powerpc_405 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-505.c b/gdb/features/rs6000/powerpc-505.c
index 51352e78bac..e36043d51b0 100644
--- a/gdb/features/rs6000/powerpc-505.c
+++ b/gdb/features/rs6000/powerpc-505.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_505;
+const_target_desc_up tdesc_powerpc_505;
 static void
 initialize_tdesc_powerpc_505 (void)
 {
@@ -141,5 +141,5 @@ initialize_tdesc_powerpc_505 (void)
   tdesc_create_reg (feature, "eid", 120, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "nri", 121, 1, NULL, 32, "int");
 
-  tdesc_powerpc_505 = result.release ();
+  tdesc_powerpc_505 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-601.c b/gdb/features/rs6000/powerpc-601.c
index 2b700bbe128..6cc502dc686 100644
--- a/gdb/features/rs6000/powerpc-601.c
+++ b/gdb/features/rs6000/powerpc-601.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_601;
+const_target_desc_up tdesc_powerpc_601;
 static void
 initialize_tdesc_powerpc_601 (void)
 {
@@ -145,5 +145,5 @@ initialize_tdesc_powerpc_601 (void)
   tdesc_create_reg (feature, "rtcu", 125, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "rtcl", 126, 1, NULL, 32, "int");
 
-  tdesc_powerpc_601 = result.release ();
+  tdesc_powerpc_601 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-602.c b/gdb/features/rs6000/powerpc-602.c
index 13591b95302..6f9344115d8 100644
--- a/gdb/features/rs6000/powerpc-602.c
+++ b/gdb/features/rs6000/powerpc-602.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_602;
+const_target_desc_up tdesc_powerpc_602;
 static void
 initialize_tdesc_powerpc_602 (void)
 {
@@ -148,5 +148,5 @@ initialize_tdesc_powerpc_602 (void)
   tdesc_create_reg (feature, "sp", 129, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "lt", 130, 1, NULL, 32, "int");
 
-  tdesc_powerpc_602 = result.release ();
+  tdesc_powerpc_602 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-603.c b/gdb/features/rs6000/powerpc-603.c
index 88b2b2c98c6..01f46bfff61 100644
--- a/gdb/features/rs6000/powerpc-603.c
+++ b/gdb/features/rs6000/powerpc-603.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_603;
+const_target_desc_up tdesc_powerpc_603;
 static void
 initialize_tdesc_powerpc_603 (void)
 {
@@ -148,5 +148,5 @@ initialize_tdesc_powerpc_603 (void)
   tdesc_create_reg (feature, "icmp", 129, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "rpa", 130, 1, NULL, 32, "int");
 
-  tdesc_powerpc_603 = result.release ();
+  tdesc_powerpc_603 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-604.c b/gdb/features/rs6000/powerpc-604.c
index d266ba6ee89..0f332bcc163 100644
--- a/gdb/features/rs6000/powerpc-604.c
+++ b/gdb/features/rs6000/powerpc-604.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_604;
+const_target_desc_up tdesc_powerpc_604;
 static void
 initialize_tdesc_powerpc_604 (void)
 {
@@ -147,5 +147,5 @@ initialize_tdesc_powerpc_604 (void)
   tdesc_create_reg (feature, "sia", 126, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "sda", 127, 1, NULL, 32, "int");
 
-  tdesc_powerpc_604 = result.release ();
+  tdesc_powerpc_604 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-64.c b/gdb/features/rs6000/powerpc-64.c
index c2f74109185..03f8195a6ae 100644
--- a/gdb/features/rs6000/powerpc-64.c
+++ b/gdb/features/rs6000/powerpc-64.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_64;
+const_target_desc_up tdesc_powerpc_64;
 static void
 initialize_tdesc_powerpc_64 (void)
 {
@@ -88,5 +88,5 @@ initialize_tdesc_powerpc_64 (void)
   tdesc_create_reg (feature, "f31", 63, 1, NULL, 64, "ieee_double");
   tdesc_create_reg (feature, "fpscr", 70, 1, "float", 32, "int");
 
-  tdesc_powerpc_64 = result.release ();
+  tdesc_powerpc_64 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-64l.c b/gdb/features/rs6000/powerpc-64l.c
index dbe06acdb20..3b863e62e3b 100644
--- a/gdb/features/rs6000/powerpc-64l.c
+++ b/gdb/features/rs6000/powerpc-64l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_64l;
+const_target_desc_up tdesc_powerpc_64l;
 static void
 initialize_tdesc_powerpc_64l (void)
 {
@@ -92,5 +92,5 @@ initialize_tdesc_powerpc_64l (void)
   tdesc_create_reg (feature, "orig_r3", 71, 1, NULL, 64, "int");
   tdesc_create_reg (feature, "trap", 72, 1, NULL, 64, "int");
 
-  tdesc_powerpc_64l = result.release ();
+  tdesc_powerpc_64l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-7400.c b/gdb/features/rs6000/powerpc-7400.c
index f1f52eb51e6..6fdd2ef363e 100644
--- a/gdb/features/rs6000/powerpc-7400.c
+++ b/gdb/features/rs6000/powerpc-7400.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_7400;
+const_target_desc_up tdesc_powerpc_7400;
 static void
 initialize_tdesc_powerpc_7400 (void)
 {
@@ -199,5 +199,5 @@ initialize_tdesc_powerpc_7400 (void)
   tdesc_create_reg (feature, "vscr", 151, 1, "vector", 32, "int");
   tdesc_create_reg (feature, "vrsave", 152, 1, "vector", 32, "int");
 
-  tdesc_powerpc_7400 = result.release ();
+  tdesc_powerpc_7400 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-750.c b/gdb/features/rs6000/powerpc-750.c
index 14f49056590..fc61ad552f4 100644
--- a/gdb/features/rs6000/powerpc-750.c
+++ b/gdb/features/rs6000/powerpc-750.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_750;
+const_target_desc_up tdesc_powerpc_750;
 static void
 initialize_tdesc_powerpc_750 (void)
 {
@@ -160,5 +160,5 @@ initialize_tdesc_powerpc_750 (void)
   tdesc_create_reg (feature, "thrm2", 141, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "thrm3", 142, 1, NULL, 32, "int");
 
-  tdesc_powerpc_750 = result.release ();
+  tdesc_powerpc_750 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-860.c b/gdb/features/rs6000/powerpc-860.c
index b02fcc4e357..5cb55107150 100644
--- a/gdb/features/rs6000/powerpc-860.c
+++ b/gdb/features/rs6000/powerpc-860.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_860;
+const_target_desc_up tdesc_powerpc_860;
 static void
 initialize_tdesc_powerpc_860 (void)
 {
@@ -185,5 +185,5 @@ initialize_tdesc_powerpc_860 (void)
   tdesc_create_reg (feature, "md_dbram0", 164, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "md_dbram1", 165, 1, NULL, 32, "int");
 
-  tdesc_powerpc_860 = result.release ();
+  tdesc_powerpc_860 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-altivec32.c b/gdb/features/rs6000/powerpc-altivec32.c
index 05f7348df9a..d683591e8c4 100644
--- a/gdb/features/rs6000/powerpc-altivec32.c
+++ b/gdb/features/rs6000/powerpc-altivec32.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_altivec32;
+const_target_desc_up tdesc_powerpc_altivec32;
 static void
 initialize_tdesc_powerpc_altivec32 (void)
 {
@@ -151,5 +151,5 @@ initialize_tdesc_powerpc_altivec32 (void)
   tdesc_create_reg (feature, "vscr", 103, 1, "vector", 32, "int");
   tdesc_create_reg (feature, "vrsave", 104, 1, "vector", 32, "int");
 
-  tdesc_powerpc_altivec32 = result.release ();
+  tdesc_powerpc_altivec32 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-altivec32l.c b/gdb/features/rs6000/powerpc-altivec32l.c
index 0bcae972502..3670597daae 100644
--- a/gdb/features/rs6000/powerpc-altivec32l.c
+++ b/gdb/features/rs6000/powerpc-altivec32l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_altivec32l;
+const_target_desc_up tdesc_powerpc_altivec32l;
 static void
 initialize_tdesc_powerpc_altivec32l (void)
 {
@@ -155,5 +155,5 @@ initialize_tdesc_powerpc_altivec32l (void)
   tdesc_create_reg (feature, "vscr", 105, 1, "vector", 32, "int");
   tdesc_create_reg (feature, "vrsave", 106, 1, "vector", 32, "int");
 
-  tdesc_powerpc_altivec32l = result.release ();
+  tdesc_powerpc_altivec32l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-altivec64.c b/gdb/features/rs6000/powerpc-altivec64.c
index bdc50004391..4f720b774d8 100644
--- a/gdb/features/rs6000/powerpc-altivec64.c
+++ b/gdb/features/rs6000/powerpc-altivec64.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_altivec64;
+const_target_desc_up tdesc_powerpc_altivec64;
 static void
 initialize_tdesc_powerpc_altivec64 (void)
 {
@@ -151,5 +151,5 @@ initialize_tdesc_powerpc_altivec64 (void)
   tdesc_create_reg (feature, "vscr", 103, 1, "vector", 32, "int");
   tdesc_create_reg (feature, "vrsave", 104, 1, "vector", 32, "int");
 
-  tdesc_powerpc_altivec64 = result.release ();
+  tdesc_powerpc_altivec64 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-altivec64l.c b/gdb/features/rs6000/powerpc-altivec64l.c
index 2392f349657..9df0d53c4f9 100644
--- a/gdb/features/rs6000/powerpc-altivec64l.c
+++ b/gdb/features/rs6000/powerpc-altivec64l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_altivec64l;
+const_target_desc_up tdesc_powerpc_altivec64l;
 static void
 initialize_tdesc_powerpc_altivec64l (void)
 {
@@ -155,5 +155,5 @@ initialize_tdesc_powerpc_altivec64l (void)
   tdesc_create_reg (feature, "vscr", 105, 1, "vector", 32, "int");
   tdesc_create_reg (feature, "vrsave", 106, 1, "vector", 32, "int");
 
-  tdesc_powerpc_altivec64l = result.release ();
+  tdesc_powerpc_altivec64l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-e500.c b/gdb/features/rs6000/powerpc-e500.c
index 0442569c318..81be763087e 100644
--- a/gdb/features/rs6000/powerpc-e500.c
+++ b/gdb/features/rs6000/powerpc-e500.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_e500;
+const_target_desc_up tdesc_powerpc_e500;
 static void
 initialize_tdesc_powerpc_e500 (void)
 {
@@ -89,5 +89,5 @@ initialize_tdesc_powerpc_e500 (void)
   tdesc_create_reg (feature, "acc", 73, 1, NULL, 64, "int");
   tdesc_create_reg (feature, "spefscr", 74, 1, NULL, 32, "int");
 
-  tdesc_powerpc_e500 = result.release ();
+  tdesc_powerpc_e500 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-e500l.c b/gdb/features/rs6000/powerpc-e500l.c
index 4e426c3005a..7803ff76f13 100644
--- a/gdb/features/rs6000/powerpc-e500l.c
+++ b/gdb/features/rs6000/powerpc-e500l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_e500l;
+const_target_desc_up tdesc_powerpc_e500l;
 static void
 initialize_tdesc_powerpc_e500l (void)
 {
@@ -93,5 +93,5 @@ initialize_tdesc_powerpc_e500l (void)
   tdesc_create_reg (feature, "orig_r3", 71, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "trap", 72, 1, NULL, 32, "int");
 
-  tdesc_powerpc_e500l = result.release ();
+  tdesc_powerpc_e500l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-isa205-32l.c b/gdb/features/rs6000/powerpc-isa205-32l.c
index 3834c980019..a6f2b900dc5 100644
--- a/gdb/features/rs6000/powerpc-isa205-32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-32l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_isa205_32l;
+const_target_desc_up tdesc_powerpc_isa205_32l;
 static void
 initialize_tdesc_powerpc_isa205_32l (void)
 {
@@ -92,5 +92,5 @@ initialize_tdesc_powerpc_isa205_32l (void)
   tdesc_create_reg (feature, "orig_r3", 71, 1, NULL, 32, "int");
   tdesc_create_reg (feature, "trap", 72, 1, NULL, 32, "int");
 
-  tdesc_powerpc_isa205_32l = result.release ();
+  tdesc_powerpc_isa205_32l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-isa205-64l.c b/gdb/features/rs6000/powerpc-isa205-64l.c
index 9a3621877c0..f9d8de03994 100644
--- a/gdb/features/rs6000/powerpc-isa205-64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-64l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_isa205_64l;
+const_target_desc_up tdesc_powerpc_isa205_64l;
 static void
 initialize_tdesc_powerpc_isa205_64l (void)
 {
@@ -92,5 +92,5 @@ initialize_tdesc_powerpc_isa205_64l (void)
   tdesc_create_reg (feature, "orig_r3", 71, 1, NULL, 64, "int");
   tdesc_create_reg (feature, "trap", 72, 1, NULL, 64, "int");
 
-  tdesc_powerpc_isa205_64l = result.release ();
+  tdesc_powerpc_isa205_64l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-isa205-altivec32l.c b/gdb/features/rs6000/powerpc-isa205-altivec32l.c
index e42e1b92297..bb1b5d97274 100644
--- a/gdb/features/rs6000/powerpc-isa205-altivec32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-altivec32l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_isa205_altivec32l;
+const_target_desc_up tdesc_powerpc_isa205_altivec32l;
 static void
 initialize_tdesc_powerpc_isa205_altivec32l (void)
 {
@@ -155,5 +155,5 @@ initialize_tdesc_powerpc_isa205_altivec32l (void)
   tdesc_create_reg (feature, "vscr", 105, 1, "vector", 32, "int");
   tdesc_create_reg (feature, "vrsave", 106, 1, "vector", 32, "int");
 
-  tdesc_powerpc_isa205_altivec32l = result.release ();
+  tdesc_powerpc_isa205_altivec32l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-isa205-altivec64l.c b/gdb/features/rs6000/powerpc-isa205-altivec64l.c
index dc43206a9d3..59ab1f8bef6 100644
--- a/gdb/features/rs6000/powerpc-isa205-altivec64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-altivec64l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_isa205_altivec64l;
+const_target_desc_up tdesc_powerpc_isa205_altivec64l;
 static void
 initialize_tdesc_powerpc_isa205_altivec64l (void)
 {
@@ -155,5 +155,5 @@ initialize_tdesc_powerpc_isa205_altivec64l (void)
   tdesc_create_reg (feature, "vscr", 105, 1, "vector", 32, "int");
   tdesc_create_reg (feature, "vrsave", 106, 1, "vector", 32, "int");
 
-  tdesc_powerpc_isa205_altivec64l = result.release ();
+  tdesc_powerpc_isa205_altivec64l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c
index acc1c5b9a3e..5108cf7eea8 100644
--- a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx32l;
+const_target_desc_up tdesc_powerpc_isa205_ppr_dscr_vsx32l;
 static void
 initialize_tdesc_powerpc_isa205_ppr_dscr_vsx32l (void)
 {
@@ -195,5 +195,5 @@ initialize_tdesc_powerpc_isa205_ppr_dscr_vsx32l (void)
   feature = tdesc_create_feature (result.get (), "org.gnu.gdb.power.dscr");
   tdesc_create_reg (feature, "dscr", 140, 1, NULL, 64, "uint64");
 
-  tdesc_powerpc_isa205_ppr_dscr_vsx32l = result.release ();
+  tdesc_powerpc_isa205_ppr_dscr_vsx32l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c
index 6bfe08d4cb5..15458dd726f 100644
--- a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx64l;
+const_target_desc_up tdesc_powerpc_isa205_ppr_dscr_vsx64l;
 static void
 initialize_tdesc_powerpc_isa205_ppr_dscr_vsx64l (void)
 {
@@ -195,5 +195,5 @@ initialize_tdesc_powerpc_isa205_ppr_dscr_vsx64l (void)
   feature = tdesc_create_feature (result.get (), "org.gnu.gdb.power.dscr");
   tdesc_create_reg (feature, "dscr", 140, 1, NULL, 64, "uint64");
 
-  tdesc_powerpc_isa205_ppr_dscr_vsx64l = result.release ();
+  tdesc_powerpc_isa205_ppr_dscr_vsx64l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-isa205-vsx32l.c b/gdb/features/rs6000/powerpc-isa205-vsx32l.c
index b3f40b9d009..794bcac37d7 100644
--- a/gdb/features/rs6000/powerpc-isa205-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-vsx32l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_isa205_vsx32l;
+const_target_desc_up tdesc_powerpc_isa205_vsx32l;
 static void
 initialize_tdesc_powerpc_isa205_vsx32l (void)
 {
@@ -189,5 +189,5 @@ initialize_tdesc_powerpc_isa205_vsx32l (void)
   tdesc_create_reg (feature, "vs30h", 137, 1, NULL, 64, "uint64");
   tdesc_create_reg (feature, "vs31h", 138, 1, NULL, 64, "uint64");
 
-  tdesc_powerpc_isa205_vsx32l = result.release ();
+  tdesc_powerpc_isa205_vsx32l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-isa205-vsx64l.c b/gdb/features/rs6000/powerpc-isa205-vsx64l.c
index 5f548176701..2de0e9bfd04 100644
--- a/gdb/features/rs6000/powerpc-isa205-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-vsx64l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_isa205_vsx64l;
+const_target_desc_up tdesc_powerpc_isa205_vsx64l;
 static void
 initialize_tdesc_powerpc_isa205_vsx64l (void)
 {
@@ -189,5 +189,5 @@ initialize_tdesc_powerpc_isa205_vsx64l (void)
   tdesc_create_reg (feature, "vs30h", 137, 1, NULL, 64, "uint64");
   tdesc_create_reg (feature, "vs31h", 138, 1, NULL, 64, "uint64");
 
-  tdesc_powerpc_isa205_vsx64l = result.release ();
+  tdesc_powerpc_isa205_vsx64l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c b/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c
index b9dfd309215..72153b84e03 100644
--- a/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_isa207_htm_vsx32l;
+const_target_desc_up tdesc_powerpc_isa207_htm_vsx32l;
 static void
 initialize_tdesc_powerpc_isa207_htm_vsx32l (void)
 {
@@ -391,5 +391,5 @@ initialize_tdesc_powerpc_isa207_htm_vsx32l (void)
   feature = tdesc_create_feature (result.get (), "org.gnu.gdb.power.htm.tar");
   tdesc_create_reg (feature, "ctar", 290, 0, NULL, 64, "uint64");
 
-  tdesc_powerpc_isa207_htm_vsx32l = result.release ();
+  tdesc_powerpc_isa207_htm_vsx32l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c b/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c
index 14a911b30aa..18753f2ddfd 100644
--- a/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_isa207_htm_vsx64l;
+const_target_desc_up tdesc_powerpc_isa207_htm_vsx64l;
 static void
 initialize_tdesc_powerpc_isa207_htm_vsx64l (void)
 {
@@ -391,5 +391,5 @@ initialize_tdesc_powerpc_isa207_htm_vsx64l (void)
   feature = tdesc_create_feature (result.get (), "org.gnu.gdb.power.htm.tar");
   tdesc_create_reg (feature, "ctar", 290, 0, NULL, 64, "uint64");
 
-  tdesc_powerpc_isa207_htm_vsx64l = result.release ();
+  tdesc_powerpc_isa207_htm_vsx64l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-isa207-vsx32l.c b/gdb/features/rs6000/powerpc-isa207-vsx32l.c
index bcfa7c175b8..d31a3309dbe 100644
--- a/gdb/features/rs6000/powerpc-isa207-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa207-vsx32l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_isa207_vsx32l;
+const_target_desc_up tdesc_powerpc_isa207_vsx32l;
 static void
 initialize_tdesc_powerpc_isa207_vsx32l (void)
 {
@@ -210,5 +210,5 @@ initialize_tdesc_powerpc_isa207_vsx32l (void)
   tdesc_create_reg (feature, "sdar", 148, 0, NULL, 64, "uint64");
   tdesc_create_reg (feature, "sier", 149, 0, NULL, 64, "uint64");
 
-  tdesc_powerpc_isa207_vsx32l = result.release ();
+  tdesc_powerpc_isa207_vsx32l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-isa207-vsx64l.c b/gdb/features/rs6000/powerpc-isa207-vsx64l.c
index 43bd6e58455..308bf545f54 100644
--- a/gdb/features/rs6000/powerpc-isa207-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa207-vsx64l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_isa207_vsx64l;
+const_target_desc_up tdesc_powerpc_isa207_vsx64l;
 static void
 initialize_tdesc_powerpc_isa207_vsx64l (void)
 {
@@ -210,5 +210,5 @@ initialize_tdesc_powerpc_isa207_vsx64l (void)
   tdesc_create_reg (feature, "sdar", 148, 0, NULL, 64, "uint64");
   tdesc_create_reg (feature, "sier", 149, 0, NULL, 64, "uint64");
 
-  tdesc_powerpc_isa207_vsx64l = result.release ();
+  tdesc_powerpc_isa207_vsx64l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-vsx32.c b/gdb/features/rs6000/powerpc-vsx32.c
index 6d60eca340f..5e82c3db313 100644
--- a/gdb/features/rs6000/powerpc-vsx32.c
+++ b/gdb/features/rs6000/powerpc-vsx32.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_vsx32;
+const_target_desc_up tdesc_powerpc_vsx32;
 static void
 initialize_tdesc_powerpc_vsx32 (void)
 {
@@ -185,5 +185,5 @@ initialize_tdesc_powerpc_vsx32 (void)
   tdesc_create_reg (feature, "vs30h", 135, 1, NULL, 64, "uint64");
   tdesc_create_reg (feature, "vs31h", 136, 1, NULL, 64, "uint64");
 
-  tdesc_powerpc_vsx32 = result.release ();
+  tdesc_powerpc_vsx32 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-vsx32l.c b/gdb/features/rs6000/powerpc-vsx32l.c
index cf233134978..6294ba4b776 100644
--- a/gdb/features/rs6000/powerpc-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-vsx32l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_vsx32l;
+const_target_desc_up tdesc_powerpc_vsx32l;
 static void
 initialize_tdesc_powerpc_vsx32l (void)
 {
@@ -189,5 +189,5 @@ initialize_tdesc_powerpc_vsx32l (void)
   tdesc_create_reg (feature, "vs30h", 137, 1, NULL, 64, "uint64");
   tdesc_create_reg (feature, "vs31h", 138, 1, NULL, 64, "uint64");
 
-  tdesc_powerpc_vsx32l = result.release ();
+  tdesc_powerpc_vsx32l = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-vsx64.c b/gdb/features/rs6000/powerpc-vsx64.c
index a5baaa2dfdc..cddd8920439 100644
--- a/gdb/features/rs6000/powerpc-vsx64.c
+++ b/gdb/features/rs6000/powerpc-vsx64.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_vsx64;
+const_target_desc_up tdesc_powerpc_vsx64;
 static void
 initialize_tdesc_powerpc_vsx64 (void)
 {
@@ -185,5 +185,5 @@ initialize_tdesc_powerpc_vsx64 (void)
   tdesc_create_reg (feature, "vs30h", 135, 1, NULL, 64, "uint64");
   tdesc_create_reg (feature, "vs31h", 136, 1, NULL, 64, "uint64");
 
-  tdesc_powerpc_vsx64 = result.release ();
+  tdesc_powerpc_vsx64 = std::move (result);
 }
diff --git a/gdb/features/rs6000/powerpc-vsx64l.c b/gdb/features/rs6000/powerpc-vsx64l.c
index 03d2b694b7d..c6deea9d2c2 100644
--- a/gdb/features/rs6000/powerpc-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-vsx64l.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_powerpc_vsx64l;
+const_target_desc_up tdesc_powerpc_vsx64l;
 static void
 initialize_tdesc_powerpc_vsx64l (void)
 {
@@ -189,5 +189,5 @@ initialize_tdesc_powerpc_vsx64l (void)
   tdesc_create_reg (feature, "vs30h", 137, 1, NULL, 64, "uint64");
   tdesc_create_reg (feature, "vs31h", 138, 1, NULL, 64, "uint64");
 
-  tdesc_powerpc_vsx64l = result.release ();
+  tdesc_powerpc_vsx64l = std::move (result);
 }
diff --git a/gdb/features/rs6000/rs6000.c b/gdb/features/rs6000/rs6000.c
index 210dd96e4f6..cee13f9b2ea 100644
--- a/gdb/features/rs6000/rs6000.c
+++ b/gdb/features/rs6000/rs6000.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_rs6000;
+const_target_desc_up tdesc_rs6000;
 static void
 initialize_tdesc_rs6000 (void)
 {
@@ -89,5 +89,5 @@ initialize_tdesc_rs6000 (void)
   tdesc_create_reg (feature, "f31", 63, 1, NULL, 64, "ieee_double");
   tdesc_create_reg (feature, "fpscr", 71, 1, "float", 32, "int");
 
-  tdesc_rs6000 = result.release ();
+  tdesc_rs6000 = std::move (result);
 }
diff --git a/gdb/features/rx.c b/gdb/features/rx.c
index f9a5584f9b8..44023fe26fe 100644
--- a/gdb/features/rx.c
+++ b/gdb/features/rx.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_rx;
+const_target_desc_up tdesc_rx;
 static void
 initialize_tdesc_rx (void)
 {
@@ -75,5 +75,5 @@ initialize_tdesc_rx (void)
   tdesc_create_reg (feature, "fpsw", 24, 1, NULL, 32, "fpsw_flags");
   tdesc_create_reg (feature, "acc", 25, 1, NULL, 64, "uint64");
 
-  tdesc_rx = result.release ();
+  tdesc_rx = std::move (result);
 }
diff --git a/gdb/features/s390-gs-linux64.c b/gdb/features/s390-gs-linux64.c
index ab6ad6f21e3..b3d22806ac2 100644
--- a/gdb/features/s390-gs-linux64.c
+++ b/gdb/features/s390-gs-linux64.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390_gs_linux64;
+const_target_desc_up tdesc_s390_gs_linux64;
 static void
 initialize_tdesc_s390_gs_linux64 (void)
 {
@@ -196,5 +196,5 @@ initialize_tdesc_s390_gs_linux64 (void)
   tdesc_create_reg (feature, "bc_gssm", 126, 1, "gs", 64, "uint64");
   tdesc_create_reg (feature, "bc_gsepla", 127, 1, "gs", 64, "data_ptr");
 
-  tdesc_s390_gs_linux64 = result.release ();
+  tdesc_s390_gs_linux64 = std::move (result);
 }
diff --git a/gdb/features/s390-linux32.c b/gdb/features/s390-linux32.c
index e45321a2099..62b4b53ae98 100644
--- a/gdb/features/s390-linux32.c
+++ b/gdb/features/s390-linux32.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390_linux32;
+const_target_desc_up tdesc_s390_linux32;
 static void
 initialize_tdesc_s390_linux32 (void)
 {
@@ -75,5 +75,5 @@ initialize_tdesc_s390_linux32 (void)
   feature = tdesc_create_feature (result.get (), "org.gnu.gdb.s390.linux");
   tdesc_create_reg (feature, "orig_r2", 51, 1, "system", 32, "uint32");
 
-  tdesc_s390_linux32 = result.release ();
+  tdesc_s390_linux32 = std::move (result);
 }
diff --git a/gdb/features/s390-linux32v1.c b/gdb/features/s390-linux32v1.c
index cea14c16969..cef4dcb2887 100644
--- a/gdb/features/s390-linux32v1.c
+++ b/gdb/features/s390-linux32v1.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390_linux32v1;
+const_target_desc_up tdesc_s390_linux32v1;
 static void
 initialize_tdesc_s390_linux32v1 (void)
 {
@@ -76,5 +76,5 @@ initialize_tdesc_s390_linux32v1 (void)
   tdesc_create_reg (feature, "orig_r2", 51, 1, "system", 32, "uint32");
   tdesc_create_reg (feature, "last_break", 52, 0, "system", 32, "code_ptr");
 
-  tdesc_s390_linux32v1 = result.release ();
+  tdesc_s390_linux32v1 = std::move (result);
 }
diff --git a/gdb/features/s390-linux32v2.c b/gdb/features/s390-linux32v2.c
index 182ab2f0b60..35498b2a275 100644
--- a/gdb/features/s390-linux32v2.c
+++ b/gdb/features/s390-linux32v2.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390_linux32v2;
+const_target_desc_up tdesc_s390_linux32v2;
 static void
 initialize_tdesc_s390_linux32v2 (void)
 {
@@ -77,5 +77,5 @@ initialize_tdesc_s390_linux32v2 (void)
   tdesc_create_reg (feature, "last_break", 52, 0, "system", 32, "code_ptr");
   tdesc_create_reg (feature, "system_call", 53, 1, "system", 32, "uint32");
 
-  tdesc_s390_linux32v2 = result.release ();
+  tdesc_s390_linux32v2 = std::move (result);
 }
diff --git a/gdb/features/s390-linux64.c b/gdb/features/s390-linux64.c
index 8bcec095174..2a9f16bb40c 100644
--- a/gdb/features/s390-linux64.c
+++ b/gdb/features/s390-linux64.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390_linux64;
+const_target_desc_up tdesc_s390_linux64;
 static void
 initialize_tdesc_s390_linux64 (void)
 {
@@ -91,5 +91,5 @@ initialize_tdesc_s390_linux64 (void)
   feature = tdesc_create_feature (result.get (), "org.gnu.gdb.s390.linux");
   tdesc_create_reg (feature, "orig_r2", 67, 1, "system", 32, "uint32");
 
-  tdesc_s390_linux64 = result.release ();
+  tdesc_s390_linux64 = std::move (result);
 }
diff --git a/gdb/features/s390-linux64v1.c b/gdb/features/s390-linux64v1.c
index 3a6394b513d..ff592c318e2 100644
--- a/gdb/features/s390-linux64v1.c
+++ b/gdb/features/s390-linux64v1.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390_linux64v1;
+const_target_desc_up tdesc_s390_linux64v1;
 static void
 initialize_tdesc_s390_linux64v1 (void)
 {
@@ -92,5 +92,5 @@ initialize_tdesc_s390_linux64v1 (void)
   tdesc_create_reg (feature, "orig_r2", 67, 1, "system", 32, "uint32");
   tdesc_create_reg (feature, "last_break", 68, 0, "system", 32, "code_ptr");
 
-  tdesc_s390_linux64v1 = result.release ();
+  tdesc_s390_linux64v1 = std::move (result);
 }
diff --git a/gdb/features/s390-linux64v2.c b/gdb/features/s390-linux64v2.c
index 5ff9a5709ef..0e1daad1475 100644
--- a/gdb/features/s390-linux64v2.c
+++ b/gdb/features/s390-linux64v2.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390_linux64v2;
+const_target_desc_up tdesc_s390_linux64v2;
 static void
 initialize_tdesc_s390_linux64v2 (void)
 {
@@ -93,5 +93,5 @@ initialize_tdesc_s390_linux64v2 (void)
   tdesc_create_reg (feature, "last_break", 68, 0, "system", 32, "code_ptr");
   tdesc_create_reg (feature, "system_call", 69, 1, "system", 32, "uint32");
 
-  tdesc_s390_linux64v2 = result.release ();
+  tdesc_s390_linux64v2 = std::move (result);
 }
diff --git a/gdb/features/s390-te-linux64.c b/gdb/features/s390-te-linux64.c
index 2abddd53bfa..5a03beb1750 100644
--- a/gdb/features/s390-te-linux64.c
+++ b/gdb/features/s390-te-linux64.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390_te_linux64;
+const_target_desc_up tdesc_s390_te_linux64;
 static void
 initialize_tdesc_s390_te_linux64 (void)
 {
@@ -115,5 +115,5 @@ initialize_tdesc_s390_te_linux64 (void)
   tdesc_create_reg (feature, "tr14", 88, 1, "tdb", 64, "uint64");
   tdesc_create_reg (feature, "tr15", 89, 1, "tdb", 64, "uint64");
 
-  tdesc_s390_te_linux64 = result.release ();
+  tdesc_s390_te_linux64 = std::move (result);
 }
diff --git a/gdb/features/s390-tevx-linux64.c b/gdb/features/s390-tevx-linux64.c
index 8e38a5cf81f..47954109719 100644
--- a/gdb/features/s390-tevx-linux64.c
+++ b/gdb/features/s390-tevx-linux64.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390_tevx_linux64;
+const_target_desc_up tdesc_s390_tevx_linux64;
 static void
 initialize_tdesc_s390_tevx_linux64 (void)
 {
@@ -186,5 +186,5 @@ initialize_tdesc_s390_tevx_linux64 (void)
   tdesc_create_reg (feature, "v30", 120, 1, NULL, 128, "vec128");
   tdesc_create_reg (feature, "v31", 121, 1, NULL, 128, "vec128");
 
-  tdesc_s390_tevx_linux64 = result.release ();
+  tdesc_s390_tevx_linux64 = std::move (result);
 }
diff --git a/gdb/features/s390-vx-linux64.c b/gdb/features/s390-vx-linux64.c
index 1ce5ad3671a..a4c523897d2 100644
--- a/gdb/features/s390-vx-linux64.c
+++ b/gdb/features/s390-vx-linux64.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390_vx_linux64;
+const_target_desc_up tdesc_s390_vx_linux64;
 static void
 initialize_tdesc_s390_vx_linux64 (void)
 {
@@ -164,5 +164,5 @@ initialize_tdesc_s390_vx_linux64 (void)
   tdesc_create_reg (feature, "v30", 100, 1, NULL, 128, "vec128");
   tdesc_create_reg (feature, "v31", 101, 1, NULL, 128, "vec128");
 
-  tdesc_s390_vx_linux64 = result.release ();
+  tdesc_s390_vx_linux64 = std::move (result);
 }
diff --git a/gdb/features/s390x-gs-linux64.c b/gdb/features/s390x-gs-linux64.c
index 76b8124863a..35626366ff1 100644
--- a/gdb/features/s390x-gs-linux64.c
+++ b/gdb/features/s390x-gs-linux64.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390x_gs_linux64;
+const_target_desc_up tdesc_s390x_gs_linux64;
 static void
 initialize_tdesc_s390x_gs_linux64 (void)
 {
@@ -180,5 +180,5 @@ initialize_tdesc_s390x_gs_linux64 (void)
   tdesc_create_reg (feature, "bc_gssm", 110, 1, "gs", 64, "uint64");
   tdesc_create_reg (feature, "bc_gsepla", 111, 1, "gs", 64, "data_ptr");
 
-  tdesc_s390x_gs_linux64 = result.release ();
+  tdesc_s390x_gs_linux64 = std::move (result);
 }
diff --git a/gdb/features/s390x-linux64.c b/gdb/features/s390x-linux64.c
index eb6b181f599..3ccc2574a51 100644
--- a/gdb/features/s390x-linux64.c
+++ b/gdb/features/s390x-linux64.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390x_linux64;
+const_target_desc_up tdesc_s390x_linux64;
 static void
 initialize_tdesc_s390x_linux64 (void)
 {
@@ -75,5 +75,5 @@ initialize_tdesc_s390x_linux64 (void)
   feature = tdesc_create_feature (result.get (), "org.gnu.gdb.s390.linux");
   tdesc_create_reg (feature, "orig_r2", 51, 1, "system", 64, "uint64");
 
-  tdesc_s390x_linux64 = result.release ();
+  tdesc_s390x_linux64 = std::move (result);
 }
diff --git a/gdb/features/s390x-linux64v1.c b/gdb/features/s390x-linux64v1.c
index 6b43f88ac84..efda35e3aef 100644
--- a/gdb/features/s390x-linux64v1.c
+++ b/gdb/features/s390x-linux64v1.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390x_linux64v1;
+const_target_desc_up tdesc_s390x_linux64v1;
 static void
 initialize_tdesc_s390x_linux64v1 (void)
 {
@@ -76,5 +76,5 @@ initialize_tdesc_s390x_linux64v1 (void)
   tdesc_create_reg (feature, "orig_r2", 51, 1, "system", 64, "uint64");
   tdesc_create_reg (feature, "last_break", 52, 0, "system", 64, "code_ptr");
 
-  tdesc_s390x_linux64v1 = result.release ();
+  tdesc_s390x_linux64v1 = std::move (result);
 }
diff --git a/gdb/features/s390x-linux64v2.c b/gdb/features/s390x-linux64v2.c
index eeba787ec7b..1a7ea9dc489 100644
--- a/gdb/features/s390x-linux64v2.c
+++ b/gdb/features/s390x-linux64v2.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390x_linux64v2;
+const_target_desc_up tdesc_s390x_linux64v2;
 static void
 initialize_tdesc_s390x_linux64v2 (void)
 {
@@ -77,5 +77,5 @@ initialize_tdesc_s390x_linux64v2 (void)
   tdesc_create_reg (feature, "last_break", 52, 0, "system", 64, "code_ptr");
   tdesc_create_reg (feature, "system_call", 53, 1, "system", 32, "uint32");
 
-  tdesc_s390x_linux64v2 = result.release ();
+  tdesc_s390x_linux64v2 = std::move (result);
 }
diff --git a/gdb/features/s390x-te-linux64.c b/gdb/features/s390x-te-linux64.c
index 0fec2b0bd02..b6b61a05b4d 100644
--- a/gdb/features/s390x-te-linux64.c
+++ b/gdb/features/s390x-te-linux64.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390x_te_linux64;
+const_target_desc_up tdesc_s390x_te_linux64;
 static void
 initialize_tdesc_s390x_te_linux64 (void)
 {
@@ -99,5 +99,5 @@ initialize_tdesc_s390x_te_linux64 (void)
   tdesc_create_reg (feature, "tr14", 72, 1, "tdb", 64, "uint64");
   tdesc_create_reg (feature, "tr15", 73, 1, "tdb", 64, "uint64");
 
-  tdesc_s390x_te_linux64 = result.release ();
+  tdesc_s390x_te_linux64 = std::move (result);
 }
diff --git a/gdb/features/s390x-tevx-linux64.c b/gdb/features/s390x-tevx-linux64.c
index c1b890045d3..104e467df9d 100644
--- a/gdb/features/s390x-tevx-linux64.c
+++ b/gdb/features/s390x-tevx-linux64.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390x_tevx_linux64;
+const_target_desc_up tdesc_s390x_tevx_linux64;
 static void
 initialize_tdesc_s390x_tevx_linux64 (void)
 {
@@ -170,5 +170,5 @@ initialize_tdesc_s390x_tevx_linux64 (void)
   tdesc_create_reg (feature, "v30", 104, 1, NULL, 128, "vec128");
   tdesc_create_reg (feature, "v31", 105, 1, NULL, 128, "vec128");
 
-  tdesc_s390x_tevx_linux64 = result.release ();
+  tdesc_s390x_tevx_linux64 = std::move (result);
 }
diff --git a/gdb/features/s390x-vx-linux64.c b/gdb/features/s390x-vx-linux64.c
index af57e052eab..af0ac984fcb 100644
--- a/gdb/features/s390x-vx-linux64.c
+++ b/gdb/features/s390x-vx-linux64.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_s390x_vx_linux64;
+const_target_desc_up tdesc_s390x_vx_linux64;
 static void
 initialize_tdesc_s390x_vx_linux64 (void)
 {
@@ -148,5 +148,5 @@ initialize_tdesc_s390x_vx_linux64 (void)
   tdesc_create_reg (feature, "v30", 84, 1, NULL, 128, "vec128");
   tdesc_create_reg (feature, "v31", 85, 1, NULL, 128, "vec128");
 
-  tdesc_s390x_vx_linux64 = result.release ();
+  tdesc_s390x_vx_linux64 = std::move (result);
 }
diff --git a/gdb/features/sparc/sparc32-solaris.c b/gdb/features/sparc/sparc32-solaris.c
index 70affdbc5b5..c46175bc8c3 100644
--- a/gdb/features/sparc/sparc32-solaris.c
+++ b/gdb/features/sparc/sparc32-solaris.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_sparc32_solaris;
+const_target_desc_up tdesc_sparc32_solaris;
 static void
 initialize_tdesc_sparc32_solaris (void)
 {
@@ -93,5 +93,5 @@ initialize_tdesc_sparc32_solaris (void)
   tdesc_create_reg (feature, "f30", 62, 1, NULL, 32, "ieee_single");
   tdesc_create_reg (feature, "f31", 63, 1, NULL, 32, "ieee_single");
 
-  tdesc_sparc32_solaris = result.release ();
+  tdesc_sparc32_solaris = std::move (result);
 }
diff --git a/gdb/features/sparc/sparc64-solaris.c b/gdb/features/sparc/sparc64-solaris.c
index 98edabe3864..40c83f93fe7 100644
--- a/gdb/features/sparc/sparc64-solaris.c
+++ b/gdb/features/sparc/sparc64-solaris.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_sparc64_solaris;
+const_target_desc_up tdesc_sparc64_solaris;
 static void
 initialize_tdesc_sparc64_solaris (void)
 {
@@ -107,5 +107,5 @@ initialize_tdesc_sparc64_solaris (void)
   tdesc_create_reg (feature, "f60", 78, 1, NULL, 64, "ieee_double");
   tdesc_create_reg (feature, "f62", 79, 1, NULL, 64, "ieee_double");
 
-  tdesc_sparc64_solaris = result.release ();
+  tdesc_sparc64_solaris = std::move (result);
 }
diff --git a/gdb/features/z80.c b/gdb/features/z80.c
index 627649cc690..6cf38ffb9e4 100644
--- a/gdb/features/z80.c
+++ b/gdb/features/z80.c
@@ -4,7 +4,7 @@
 #include "osabi.h"
 #include "target-descriptions.h"
 
-const struct target_desc *tdesc_z80;
+const_target_desc_up tdesc_z80;
 static void
 initialize_tdesc_z80 (void)
 {
@@ -39,5 +39,5 @@ initialize_tdesc_z80 (void)
   tdesc_create_reg (feature, "hl'", 11, 1, NULL, 16, "data_ptr");
   tdesc_create_reg (feature, "ir", 12, 1, NULL, 16, "uint16");
 
-  tdesc_z80 = result.release ();
+  tdesc_z80 = std::move (result);
 }
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 8996b80f5bc..a4eee1e9869 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -9116,25 +9116,25 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
 /* See i386-tdep.h.  */
 
-const struct target_desc *
+const target_desc *
 i386_target_description (uint64_t xstate_bv, bool segments)
 {
-  static target_desc *i386_tdescs \
+  static const_target_desc_up i386_tdescs \
     [2/*SSE*/][2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*CET_U*/] \
     [2/*segments*/] = {};
-  target_desc **tdesc;
 
-  tdesc = &i386_tdescs[(xstate_bv & X86_XSTATE_SSE) ? 1 : 0]
-    [(xstate_bv & X86_XSTATE_AVX) ? 1 : 0]
-    [(xstate_bv & X86_XSTATE_AVX512) ? 1 : 0]
-    [(xstate_bv & X86_XSTATE_PKRU) ? 1 : 0]
-    [(xstate_bv & X86_XSTATE_CET_U) ? 1 : 0]
-    [segments ? 1 : 0];
+  const_target_desc_up &tdesc
+    = i386_tdescs[(xstate_bv & X86_XSTATE_SSE) ? 1 : 0]
+		 [(xstate_bv & X86_XSTATE_AVX) ? 1 : 0]
+		 [(xstate_bv & X86_XSTATE_AVX512) ? 1 : 0]
+		 [(xstate_bv & X86_XSTATE_PKRU) ? 1 : 0]
+		 [(xstate_bv & X86_XSTATE_CET_U) ? 1 : 0]
+		 [segments ? 1 : 0];
 
-  if (*tdesc == NULL)
-    *tdesc = i386_create_target_description (xstate_bv, false, segments);
+  if (tdesc == nullptr)
+    tdesc = i386_create_target_description (xstate_bv, false, segments);
 
-  return *tdesc;
+  return tdesc.get ();
 }
 
 INIT_GDB_FILE (i386_tdep)
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index f4ab2ec595f..3ee33721819 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -711,11 +711,11 @@ microblaze_register_g_packet_guesses (struct gdbarch *gdbarch)
 {
   register_remote_g_packet_guess (gdbarch,
 				  4 * MICROBLAZE_NUM_CORE_REGS,
-				  tdesc_microblaze);
+				  tdesc_microblaze.get ());
 
   register_remote_g_packet_guess (gdbarch,
 				  4 * MICROBLAZE_NUM_REGS,
-				  tdesc_microblaze_with_stack_protect);
+				  tdesc_microblaze_with_stack_protect.get ());
 }
 
 static struct gdbarch *
@@ -729,7 +729,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   if (arches != NULL)
     return arches->gdbarch;
   if (tdesc == NULL)
-    tdesc = tdesc_microblaze;
+    tdesc = tdesc_microblaze.get ();
 
   /* Check any target description for validity.  */
   if (tdesc_has_registers (tdesc))
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index b90b546f572..a26ae039cfa 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -459,7 +459,8 @@ mips_linux_nat_target::read_description ()
     {
       /* Assume no DSP if there is no inferior to inspect with ptrace.  */
       if (inferior_ptid == null_ptid)
-	return _MIPS_SIM == _ABIO32 ? tdesc_mips_linux : tdesc_mips64_linux;
+	return (_MIPS_SIM == _ABIO32
+		? tdesc_mips_linux : tdesc_mips64_linux).get ();
 
       int tid = get_ptrace_pid (inferior_ptid);
 
@@ -482,9 +483,9 @@ mips_linux_nat_target::read_description ()
   /* Report that target registers are a size we know for sure
      that we can get from ptrace.  */
   if (_MIPS_SIM == _ABIO32)
-    return have_dsp ? tdesc_mips_dsp_linux : tdesc_mips_linux;
+    return (have_dsp ? tdesc_mips_dsp_linux : tdesc_mips_linux).get ();
   else
-    return have_dsp ? tdesc_mips64_dsp_linux : tdesc_mips64_linux;
+    return (have_dsp ? tdesc_mips64_dsp_linux : tdesc_mips64_linux).get ();
 }
 
 /* -1 if the kernel and/or CPU do not support watch registers.
diff --git a/gdb/mips-linux-tdep.h b/gdb/mips-linux-tdep.h
index 362c1488c5f..7e5ec9f4d08 100644
--- a/gdb/mips-linux-tdep.h
+++ b/gdb/mips-linux-tdep.h
@@ -20,6 +20,8 @@
 #ifndef GDB_MIPS_LINUX_TDEP_H
 #define GDB_MIPS_LINUX_TDEP_H
 
+#include "gdbsupport/tdesc.h"
+
 /* Copied from <asm/elf.h>.  */
 #define ELF_NGREG       45
 #define ELF_NFPREG      33
@@ -108,9 +110,9 @@ enum {
 int mips_linux_restart_reg_p (struct gdbarch *gdbarch);
 
 /* Target descriptions.  */
-extern const struct target_desc *tdesc_mips_linux;
-extern const struct target_desc *tdesc_mips64_linux;
-extern const struct target_desc *tdesc_mips_dsp_linux;
-extern const struct target_desc *tdesc_mips64_dsp_linux;
+extern const_target_desc_up tdesc_mips_linux;
+extern const_target_desc_up tdesc_mips64_linux;
+extern const_target_desc_up tdesc_mips_dsp_linux;
+extern const_target_desc_up tdesc_mips64_dsp_linux;
 
 #endif /* GDB_MIPS_LINUX_TDEP_H */
diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
index f0a0b338931..80a2e1c706d 100644
--- a/gdb/nds32-tdep.c
+++ b/gdb/nds32-tdep.c
@@ -1974,7 +1974,7 @@ nds32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     return best_arch->gdbarch;
 
   if (!tdesc_has_registers (tdesc))
-    tdesc = tdesc_nds32;
+    tdesc = tdesc_nds32.get ();
 
   tdesc_data = tdesc_data_alloc ();
 
diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c
index 442bdaf9fab..52222fef1dc 100644
--- a/gdb/or1k-tdep.c
+++ b/gdb/or1k-tdep.c
@@ -1234,7 +1234,7 @@ or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   if (!tdesc_has_registers (info.target_desc))
     /* Pick a default target description.  */
-    tdesc = tdesc_or1k;
+    tdesc = tdesc_or1k.get ();
 
   /* Check any target description for validity.  */
   if (tdesc_has_registers (tdesc))
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 27586d9a735..fd425654df7 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -1955,7 +1955,7 @@ ppc_linux_nat_target::read_description ()
       struct gdb_evrregset_t evrregset;
 
       if (ptrace (PTRACE_GETEVRREGS, tid, 0, &evrregset) >= 0)
-	return tdesc_powerpc_e500l;
+	return tdesc_powerpc_e500l.get ();
 
       /* EIO means that the PTRACE_GETEVRREGS request isn't supported.
 	 Anything else needs to be reported.  */
diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h
index bf0e82a2820..f5d60b58ea0 100644
--- a/gdb/ppc-tdep.h
+++ b/gdb/ppc-tdep.h
@@ -21,6 +21,7 @@
 #define GDB_PPC_TDEP_H
 
 #include "gdbarch.h"
+#include "gdbsupport/tdesc.h"
 
 struct gdbarch;
 class frame_info_ptr;
@@ -452,10 +453,10 @@ struct ppc_inferior_data
 
 extern ppc_inferior_data * get_ppc_per_inferior (inferior *inf);
 
-extern const struct target_desc *tdesc_powerpc_vsx64l;
-extern const struct target_desc *tdesc_powerpc_vsx64;
-extern const struct target_desc *tdesc_powerpc_vsx32;
-extern const struct target_desc *tdesc_powerpc_altivec64;
-extern const struct target_desc *tdesc_powerpc_altivec32;
+extern const_target_desc_up tdesc_powerpc_vsx64l;
+extern const_target_desc_up tdesc_powerpc_vsx64;
+extern const_target_desc_up tdesc_powerpc_vsx32;
+extern const_target_desc_up tdesc_powerpc_altivec64;
+extern const_target_desc_up tdesc_powerpc_altivec32;
 
 #endif /* GDB_PPC_TDEP_H */
diff --git a/gdb/rs6000-aix-nat.c b/gdb/rs6000-aix-nat.c
index 2b0cf8577fa..29f4735ca93 100644
--- a/gdb/rs6000-aix-nat.c
+++ b/gdb/rs6000-aix-nat.c
@@ -689,16 +689,16 @@ rs6000_nat_target::read_description ()
    if (ARCH64())
      {
        if (__power_vsx ())
-	 return tdesc_powerpc_vsx64;
+	 return tdesc_powerpc_vsx64.get ();
        else if (__power_vmx ())
-	 return tdesc_powerpc_altivec64;
+	 return tdesc_powerpc_altivec64.get ();
      }
    else
      {
        if (__power_vsx ())
-	 return tdesc_powerpc_vsx32;
+	 return tdesc_powerpc_vsx32.get ();
        else if (__power_vmx ())
-	 return tdesc_powerpc_altivec32;
+	 return tdesc_powerpc_altivec32.get ();
      }
    return NULL;
 }
diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
index ae1fb958628..366235f1919 100644
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -470,13 +470,13 @@ ppc_aix_core_read_description (struct gdbarch *gdbarch,
     arch64 = 1;
 
   if (vsx && arch64)
-    return tdesc_powerpc_vsx64;
+    return tdesc_powerpc_vsx64.get ();
   else if (vsx && !arch64)
-    return tdesc_powerpc_vsx32;
+    return tdesc_powerpc_vsx32.get ();
   else if (altivec && arch64)
-    return tdesc_powerpc_altivec64;
+    return tdesc_powerpc_altivec64.get ();
   else if (altivec && !arch64)
-    return tdesc_powerpc_altivec32;
+    return tdesc_powerpc_altivec32.get ();
 
   return NULL;
 }
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index b73ab87b699..3184952b848 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -3525,7 +3525,7 @@ struct ppc_variant
     unsigned long mach;
 
     /* Target description for this variant.  */
-    const struct target_desc **tdesc;
+    const_target_desc_up *tdesc;
   };
 
 static const ppc_variant variants[] =
@@ -7676,7 +7676,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       if (!v)
 	return NULL;
 
-      tdesc = *v->tdesc;
+      tdesc = v->tdesc->get ();
     }
 
   gdb_assert (tdesc_has_registers (tdesc));
diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c
index c7b1dfa6ae7..0e073ad5504 100644
--- a/gdb/rx-tdep.c
+++ b/gdb/rx-tdep.c
@@ -975,7 +975,7 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     }
 
   if (tdesc == NULL)
-      tdesc = tdesc_rx;
+    tdesc = tdesc_rx.get ();
 
   /* Check any target description for validity.  */
   if (tdesc_has_registers (tdesc))
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index 5b723b10680..a4745e4fc4e 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -1029,7 +1029,7 @@ s390_linux_nat_target::read_description ()
 	      have_regset_tdb ? tdesc_s390x_te_linux64 :
 	      have_regset_system_call ? tdesc_s390x_linux64v2 :
 	      have_regset_last_break ? tdesc_s390x_linux64v1 :
-	      tdesc_s390x_linux64);
+	      tdesc_s390x_linux64).get ();
 
     if (hwcap & HWCAP_S390_HIGH_GPRS)
       return (have_regset_gs ? tdesc_s390_gs_linux64 :
@@ -1039,7 +1039,7 @@ s390_linux_nat_target::read_description ()
 	      have_regset_tdb ? tdesc_s390_te_linux64 :
 	      have_regset_system_call ? tdesc_s390_linux64v2 :
 	      have_regset_last_break ? tdesc_s390_linux64v1 :
-	      tdesc_s390_linux64);
+	      tdesc_s390_linux64).get ();
   }
 #endif
 
@@ -1048,7 +1048,7 @@ s390_linux_nat_target::read_description ()
      mode, report s390 architecture with 32-bit GPRs.  */
   return (have_regset_system_call? tdesc_s390_linux32v2 :
 	  have_regset_last_break? tdesc_s390_linux32v1 :
-	  tdesc_s390_linux32);
+	  tdesc_s390_linux32).get ();
 }
 
 INIT_GDB_FILE (s390_nat)
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index 593befb495a..23f13a650a5 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -358,10 +358,10 @@ s390_core_read_description (struct gdbarch *gdbarch,
 		vx ? tdesc_s390_vx_linux64 :
 		te ? tdesc_s390_te_linux64 :
 		v2 ? tdesc_s390_linux64v2 :
-		v1 ? tdesc_s390_linux64v1 : tdesc_s390_linux64);
+		v1 ? tdesc_s390_linux64v1 : tdesc_s390_linux64).get ();
       else
 	return (v2 ? tdesc_s390_linux32v2 :
-		v1 ? tdesc_s390_linux32v1 : tdesc_s390_linux32);
+		v1 ? tdesc_s390_linux32v1 : tdesc_s390_linux32).get ();
 
     case s390x_sizeof_gregset:
       return (gs ? tdesc_s390x_gs_linux64 :
@@ -369,7 +369,7 @@ s390_core_read_description (struct gdbarch *gdbarch,
 	      vx ? tdesc_s390x_vx_linux64 :
 	      te ? tdesc_s390x_te_linux64 :
 	      v2 ? tdesc_s390x_linux64v2 :
-	      v1 ? tdesc_s390x_linux64v1 : tdesc_s390x_linux64);
+	      v1 ? tdesc_s390x_linux64v1 : tdesc_s390x_linux64).get ();
 
     default:
       return NULL;
diff --git a/gdb/s390-linux-tdep.h b/gdb/s390-linux-tdep.h
index 05ef893f64d..7044e0b2c97 100644
--- a/gdb/s390-linux-tdep.h
+++ b/gdb/s390-linux-tdep.h
@@ -20,6 +20,8 @@
 #ifndef GDB_S390_LINUX_TDEP_H
 #define GDB_S390_LINUX_TDEP_H
 
+#include "gdbsupport/tdesc.h"
+
 #define S390_IS_GREGSET_REGNUM(i)					\
   (((i) >= S390_PSWM_REGNUM && (i) <= S390_A15_REGNUM)			\
    || ((i) >= S390_R0_UPPER_REGNUM && (i) <= S390_R15_UPPER_REGNUM)	\
@@ -48,20 +50,20 @@ extern const struct regset s390_gs_regset;
 extern const struct regset s390_gsbc_regset;
 
 /* GNU/Linux target descriptions.  */
-extern const struct target_desc *tdesc_s390_linux32v1;
-extern const struct target_desc *tdesc_s390_linux32v2;
-extern const struct target_desc *tdesc_s390_linux64;
-extern const struct target_desc *tdesc_s390_linux64v1;
-extern const struct target_desc *tdesc_s390_linux64v2;
-extern const struct target_desc *tdesc_s390_te_linux64;
-extern const struct target_desc *tdesc_s390_vx_linux64;
-extern const struct target_desc *tdesc_s390_tevx_linux64;
-extern const struct target_desc *tdesc_s390_gs_linux64;
-extern const struct target_desc *tdesc_s390x_linux64v1;
-extern const struct target_desc *tdesc_s390x_linux64v2;
-extern const struct target_desc *tdesc_s390x_te_linux64;
-extern const struct target_desc *tdesc_s390x_vx_linux64;
-extern const struct target_desc *tdesc_s390x_tevx_linux64;
-extern const struct target_desc *tdesc_s390x_gs_linux64;
+extern const_target_desc_up tdesc_s390_linux32v1;
+extern const_target_desc_up tdesc_s390_linux32v2;
+extern const_target_desc_up tdesc_s390_linux64;
+extern const_target_desc_up tdesc_s390_linux64v1;
+extern const_target_desc_up tdesc_s390_linux64v2;
+extern const_target_desc_up tdesc_s390_te_linux64;
+extern const_target_desc_up tdesc_s390_vx_linux64;
+extern const_target_desc_up tdesc_s390_tevx_linux64;
+extern const_target_desc_up tdesc_s390_gs_linux64;
+extern const_target_desc_up tdesc_s390x_linux64v1;
+extern const_target_desc_up tdesc_s390x_linux64v2;
+extern const_target_desc_up tdesc_s390x_te_linux64;
+extern const_target_desc_up tdesc_s390x_vx_linux64;
+extern const_target_desc_up tdesc_s390x_tevx_linux64;
+extern const_target_desc_up tdesc_s390x_gs_linux64;
 
 #endif /* GDB_S390_LINUX_TDEP_H */
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index ccffafcecab..e47832e474c 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -7392,9 +7392,9 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   if (!tdesc_has_registers (tdesc))
     {
       if (info.bfd_arch_info->mach == bfd_mach_s390_31)
-	tdesc = tdesc_s390_linux32;
+	tdesc = tdesc_s390_linux32.get ();
       else
-	tdesc = tdesc_s390x_linux64;
+	tdesc = tdesc_s390x_linux64.get ();
     }
   tdep->tdesc = tdesc;
 
diff --git a/gdb/s390-tdep.h b/gdb/s390-tdep.h
index 80ca3b4b56c..cd720793d43 100644
--- a/gdb/s390-tdep.h
+++ b/gdb/s390-tdep.h
@@ -20,6 +20,7 @@
 #ifndef GDB_S390_TDEP_H
 #define GDB_S390_TDEP_H
 
+#include "gdbsupport/tdesc.h"
 #include "prologue-value.h"
 #include "gdbarch.h"
 
@@ -320,7 +321,7 @@ extern struct value *s390_trad_frame_prev_register
     (const frame_info_ptr &this_frame, struct trad_frame_saved_reg saved_regs[],
      int regnum);
 
-extern const struct target_desc *tdesc_s390_linux32;
-extern const struct target_desc *tdesc_s390x_linux64;
+extern const_target_desc_up tdesc_s390_linux32;
+extern const_target_desc_up tdesc_s390x_linux64;
 
 #endif /* GDB_S390_TDEP_H */
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 858a019e615..46e2219c971 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -1134,7 +1134,7 @@ allocate_target_description (void)
 /* See gdbsupport/tdesc.h.  */
 
 void
-target_desc_deleter::operator() (struct target_desc *target_desc) const
+target_desc_deleter::operator() (const target_desc *target_desc) const
 {
   delete target_desc;
 }
@@ -1292,7 +1292,7 @@ public:
     gdb_printf ("#include \"target-descriptions.h\"\n");
     gdb_printf ("\n");
 
-    gdb_printf ("const struct target_desc *tdesc_%s;\n", m_function);
+    gdb_printf ("const_target_desc_up tdesc_%s;\n", m_function);
     gdb_printf ("static void\n");
     gdb_printf ("initialize_tdesc_%s (void)\n", m_function);
     gdb_printf ("{\n");
@@ -1340,7 +1340,7 @@ public:
 
   void visit_post (const target_desc *e) override
   {
-    gdb_printf ("\n  tdesc_%s = result.release ();\n", m_function);
+    gdb_printf ("\n  tdesc_%s = std::move (result);\n", m_function);
     gdb_printf ("}\n");
   }
 
diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c
index 6a099cd6e74..b07d6b15385 100644
--- a/gdb/z80-tdep.c
+++ b/gdb/z80-tdep.c
@@ -1085,8 +1085,10 @@ z80_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   const struct target_desc *tdesc = info.target_desc;
 
   if (!tdesc_has_registers (tdesc))
-    /* Pick a default target description.  */
-    tdesc = tdesc_z80;
+    {
+      /* Pick a default target description.  */
+      tdesc = tdesc_z80.get ();
+    }
 
   /* Check any target description for validity.  */
   if (tdesc_has_registers (tdesc))
diff --git a/gdbserver/linux-aarch32-tdesc.cc b/gdbserver/linux-aarch32-tdesc.cc
index 675eb58e2c4..c97d52ef859 100644
--- a/gdbserver/linux-aarch32-tdesc.cc
+++ b/gdbserver/linux-aarch32-tdesc.cc
@@ -22,7 +22,7 @@
 #include "arch/aarch32.h"
 #include <inttypes.h>
 
-static struct target_desc *tdesc_aarch32;
+static const_target_desc_up tdesc_aarch32;
 
 /* See linux-aarch32-tdesc.h.  */
 
@@ -31,12 +31,13 @@ aarch32_linux_read_description ()
 {
   if (tdesc_aarch32 == nullptr)
     {
-      tdesc_aarch32 = aarch32_create_target_description (false);
+      target_desc_up new_tdesc = aarch32_create_target_description (false);
 
       static const char *expedite_regs[] = { "r11", "sp", "pc", 0 };
-      init_target_desc (tdesc_aarch32, expedite_regs, GDB_OSABI_LINUX);
+      init_target_desc (new_tdesc.get (), expedite_regs, GDB_OSABI_LINUX);
+      tdesc_aarch32 = std::move (new_tdesc);
     }
-  return tdesc_aarch32;
+  return tdesc_aarch32.get ();
 }
 
 /* See linux-aarch32-tdesc.h.  */
@@ -45,5 +46,5 @@ bool
 is_aarch32_linux_description (const target_desc *tdesc)
 {
   gdb_assert (tdesc != nullptr);
-  return tdesc == tdesc_aarch32;
+  return tdesc == tdesc_aarch32.get ();
 }
diff --git a/gdbserver/linux-aarch64-tdesc.cc b/gdbse[...]

[diff truncated at 100000 bytes]


More information about the Gdb-cvs mailing list