diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index 7e7333e20dd1..7ec6462a8de1 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -28,7 +28,7 @@
 
 /* Our private data in struct so_list.  */
 
-struct lm_info_aix : public lm_info
+struct lm_info_aix final : public lm_info
 {
   /* The name of the file mapped by the loader.  Apart from the entry
      for the main executable, this is usually a shared library (which,
@@ -360,18 +360,6 @@ solib_aix_relocate_section_addresses (so_list &so, target_section *sec)
     }
 }
 
-/* Implement the "free_so" target_so_ops method.  */
-
-static void
-solib_aix_free_so (so_list &so)
-{
-  lm_info_aix *li = (lm_info_aix *) so.lm_info;
-
-  solib_debug_printf ("%s", so.so_name);
-
-  delete li;
-}
-
 /* Compute and return the OBJFILE's section_offset array, using
    the associated loader info (INFO).  */
 
@@ -704,7 +692,6 @@ solib_aix_normal_stop_observer (struct bpstat *unused_1, int unused_2)
 const struct target_so_ops solib_aix_so_ops =
 {
   solib_aix_relocate_section_addresses,
-  solib_aix_free_so,
   nullptr,
   nullptr,
   solib_aix_solib_create_inferior_hook,
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 2ca2d533a9b4..cb6ed3a70afc 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -135,7 +135,7 @@ darwin_load_image_infos (struct darwin_info *info)
 
 /* Link map info to include in an allocated so_list entry.  */
 
-struct lm_info_darwin : public lm_info
+struct lm_info_darwin final : public lm_info
 {
   /* The target location of lm.  */
   CORE_ADDR lm_addr = 0;
@@ -608,14 +608,6 @@ darwin_clear_solib (program_space *pspace)
   info->all_image.version = 0;
 }
 
-static void
-darwin_free_so (so_list &so)
-{
-  lm_info_darwin *li = (lm_info_darwin *) so.lm_info;
-
-  delete li;
-}
-
 /* The section table is built from bfd sections using bfd VMAs.
    Relocate these VMAs according to solib info.  */
 
@@ -673,7 +665,6 @@ darwin_bfd_open (const char *pathname)
 const struct target_so_ops darwin_so_ops =
 {
   darwin_relocate_section_addresses,
-  darwin_free_so,
   nullptr,
   darwin_clear_solib,
   darwin_solib_create_inferior_hook,
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index 5458ef51571a..af99afc33caa 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -123,7 +123,7 @@ struct dbst_ext_link_map
 
 /* Link map info to include in an allocated so_list entry */
 
-struct lm_info_dsbt : public lm_info
+struct lm_info_dsbt final : public lm_info
 {
   ~lm_info_dsbt ()
   {
@@ -879,14 +879,6 @@ dsbt_clear_solib (program_space *pspace)
   info->main_executable_lm_info = NULL;
 }
 
-static void
-dsbt_free_so (so_list &so)
-{
-  lm_info_dsbt *li = (lm_info_dsbt *) so.lm_info;
-
-  delete li;
-}
-
 static void
 dsbt_relocate_section_addresses (so_list &so, target_section *sec)
 {
@@ -917,7 +909,6 @@ show_dsbt_debug (struct ui_file *file, int from_tty,
 const struct target_so_ops dsbt_so_ops =
 {
   dsbt_relocate_section_addresses,
-  dsbt_free_so,
   nullptr,
   dsbt_clear_solib,
   dsbt_solib_create_inferior_hook,
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index caf8a9a87701..853d90a8c86c 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -196,7 +196,7 @@ struct ext_link_map
 
 /* Link map info to include in an allocated so_list entry.  */
 
-struct lm_info_frv : public lm_info
+struct lm_info_frv final : public lm_info
 {
   ~lm_info_frv ()
   {
@@ -815,14 +815,6 @@ frv_clear_solib (program_space *pspace)
   main_executable_lm_info = NULL;
 }
 
-static void
-frv_free_so (so_list &so)
-{
-  lm_info_frv *li = (lm_info_frv *) so.lm_info;
-
-  delete li;
-}
-
 static void
 frv_relocate_section_addresses (so_list &so, target_section *sec)
 {
@@ -1089,7 +1081,6 @@ frv_fetch_objfile_link_map (struct objfile *objfile)
 const struct target_so_ops frv_so_ops =
 {
   frv_relocate_section_addresses,
-  frv_free_so,
   nullptr,
   frv_clear_solib,
   frv_solib_create_inferior_hook,
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 6fae926d5e62..0bf8bb8446c7 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -976,16 +976,6 @@ svr4_free_objfile_observer (struct objfile *objfile)
   probes_table_remove_objfile_probes (objfile);
 }
 
-/* Implementation for target_so_ops.free_so.  */
-
-static void
-svr4_free_so (so_list &so)
-{
-  lm_info_svr4 *li = (lm_info_svr4 *) so.lm_info;
-
-  delete li;
-}
-
 /* Implement target_so_ops.clear_so.  */
 
 static void
@@ -3465,7 +3455,6 @@ svr4_iterate_over_objfiles_in_search_order
 const struct target_so_ops svr4_so_ops =
 {
   svr4_relocate_section_addresses,
-  svr4_free_so,
   svr4_clear_so,
   svr4_clear_solib,
   svr4_solib_create_inferior_hook,
diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h
index 050c702f620b..1aff3b59da8c 100644
--- a/gdb/solib-svr4.h
+++ b/gdb/solib-svr4.h
@@ -29,7 +29,7 @@ extern const struct target_so_ops svr4_so_ops;
 
 /* Link map info to include in an allocated so_list entry.  */
 
-struct lm_info_svr4 : public lm_info
+struct lm_info_svr4 final : public lm_info
 {
   /* Amount by which addresses in the binary should be relocated to
      match the inferior.  The direct inferior value is L_ADDR_INFERIOR.
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index 8e6a440c4673..f79b59a36de0 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -28,7 +28,7 @@
 #include "inferior.h"
 
 /* Private data for each loaded library.  */
-struct lm_info_target : public lm_info
+struct lm_info_target final : public lm_info
 {
   /* The library's name.  The name is normally kept in the struct
      so_list; it is only here during XML parsing.  */
@@ -281,16 +281,6 @@ solib_target_solib_create_inferior_hook (int from_tty)
   /* Nothing needed.  */
 }
 
-static void
-solib_target_free_so (so_list &so)
-{
-  lm_info_target *li = (lm_info_target *) so.lm_info;
-
-  gdb_assert (li->name.empty ());
-
-  delete li;
-}
-
 static void
 solib_target_relocate_section_addresses (so_list &so, target_section *sec)
 {
@@ -431,7 +421,6 @@ solib_target_in_dynsym_resolve_code (CORE_ADDR pc)
 const struct target_so_ops solib_target_so_ops =
 {
   solib_target_relocate_section_addresses,
-  solib_target_free_so,
   nullptr,
   nullptr,
   solib_target_solib_create_inferior_hook,
diff --git a/gdb/solib.c b/gdb/solib.c
index 816dacb31829..4799fabe8213 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -658,6 +658,8 @@ clear_so (so_list &so)
     ops->clear_so (so);
 }
 
+lm_info::~lm_info () = default;
+
 /* Free the storage associated with the `struct so_list' object SO.
    If we have opened a BFD for SO, close it.
 
@@ -672,11 +674,8 @@ clear_so (so_list &so)
 void
 free_so (so_list &so)
 {
-  const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ());
-
   clear_so (so);
-  ops->free_so (so);
-
+  delete so.lm_info;
   delete &so;
 }
 
diff --git a/gdb/solist.h b/gdb/solist.h
index 51b1ceb0398e..12ea516a10cf 100644
--- a/gdb/solist.h
+++ b/gdb/solist.h
@@ -29,6 +29,9 @@
 
 struct lm_info
 {
+  lm_info () = default;
+  lm_info (const lm_info &) = default;
+  virtual ~lm_info () = 0;
 };
 
 struct so_list
@@ -86,13 +89,9 @@ struct target_so_ops
      which the object was actually mapped.  */
   void (*relocate_section_addresses) (so_list &so, target_section *);
 
-  /* Free the link map info and any other private data structures
-     associated with a so_list entry.  */
-  void (*free_so) (so_list &so);
-
   /* Reset private data structures associated with SO.
      This is called when SO is about to be reloaded.
-     It is also called before free_so when SO is about to be freed.  */
+     It is also called when SO is about to be freed.  */
   void (*clear_so) (const so_list &so);
 
   /* Free private data structures associated to PSPACE.  This method
