]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/solib: add solib -> solib_ops backlink
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 16 Jun 2025 19:33:01 +0000 (15:33 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Thu, 26 Jun 2025 18:08:31 +0000 (14:08 -0400)
The subsequent C++ification commit makes it so that one struct solib_ops
is instantiated for each program space.  For some operations, it will
then become necessary to be able to get the right solib_ops instance
from a given solib.  Add an solib -> solib_ops backlink for that.

Change-Id: Ib95407b3fa5fcfba55cf874e0e9dcd2d43a402e4
Approved-By: Pedro Alves <pedro@palves.net>
gdb/solib-aix.c
gdb/solib-darwin.c
gdb/solib-dsbt.c
gdb/solib-frv.c
gdb/solib-rocm.c
gdb/solib-svr4.c
gdb/solib-target.c
gdb/solib.h

index 1c6d695f3d091e9c330ffbd7808da49cdfb90bd4..b10e41164bdfa9338122a405a45888f6d0a44c0c 100644 (file)
@@ -480,7 +480,7 @@ solib_aix_current_sos ()
        }
 
       /* Add it to the list.  */
-      auto &new_solib = sos.emplace_back ();
+      auto &new_solib = sos.emplace_back (solib_aix_so_ops);
       new_solib.original_name = so_name;
       new_solib.name = so_name;
       new_solib.lm_info = std::make_unique<lm_info_aix> (info);
index 4003c77748ca22e7cba057842c7a659ad33d4156..88a2962f5dd5f3ac2667a02cb442313ff5c58a20 100644 (file)
@@ -250,7 +250,7 @@ darwin_current_sos ()
        break;
 
       /* Create and fill the new struct solib element.  */
-      auto &newobj = sos.emplace_back ();
+      auto &newobj = sos.emplace_back (darwin_so_ops);
 
       auto li = std::make_unique<lm_info_darwin> ();
 
index cc1b2a7fb8a349f3facf32068ed6a8c3e2a89e89..6cc0264b45c2fd757427b5054db7f43550a0b73c 100644 (file)
@@ -584,7 +584,7 @@ dsbt_current_sos (void)
              break;
            }
 
-         auto &sop = sos.emplace_back ();
+         auto &sop = sos.emplace_back (dsbt_so_ops);
          auto li = std::make_unique<lm_info_dsbt> ();
          li->map = loadmap;
          /* Fetch the name.  */
index ceef72208a1bc05ce7ce4bf95108b822f7d00d58..12d3140b513cd845e4f10ac0e1de67dc53ed90d2 100644 (file)
@@ -367,7 +367,7 @@ frv_current_sos ()
              break;
            }
 
-         auto &sop = sos.emplace_back ();
+         auto &sop = sos.emplace_back (frv_so_ops);
          auto li = std::make_unique<lm_info_frv> ();
          li->map = loadmap;
          li->got_value = got_addr;
index 86e5d82aaa193ec624d8a46e13feb61531bf3a1c..bda19ac4b82980349d383cbd8b9289e148e6d97e 100644 (file)
@@ -210,7 +210,7 @@ solibs_from_rocm_sos (const std::vector<rocm_so> &sos)
 
   for (const rocm_so &so : sos)
     {
-      auto &newobj = dst.emplace_back ();
+      auto &newobj = dst.emplace_back (rocm_solib_ops);
 
       newobj.lm_info = std::make_unique<lm_info_svr4> (*so.lm_info);
       newobj.name = so.name;
index 80214f23cb4f36677d65e05c43a787e47bf82768..b5945f5ac82ca54da34b862c185a6af524f19df2 100644 (file)
@@ -1050,7 +1050,7 @@ solib_from_svr4_sos (const std::vector<svr4_so> &sos)
 
   for (const svr4_so &so : sos)
     {
-      auto &newobj = dst.emplace_back ();
+      auto &newobj = dst.emplace_back (svr4_so_ops);
 
       newobj.name = so.name;
       newobj.original_name = so.name;
@@ -1250,7 +1250,7 @@ svr4_default_sos (svr4_info *info)
   li->l_addr_p = 1;
 
   owning_intrusive_list<solib> sos;
-  auto &newobj = sos.emplace_back ();
+  auto &newobj = sos.emplace_back (svr4_so_ops);
 
   newobj.lm_info = std::move (li);
   newobj.name = info->debug_loader_name;
index 68dc3cc92c0ae7a3e502530653f18921abad3682..61b841928ff8a6070512a2e5de67bd83b67c8aa5 100644 (file)
@@ -245,7 +245,7 @@ solib_target_current_sos (void)
   /* Build a struct solib for each entry on the list.  */
   for (lm_info_target_up &info : library_list)
     {
-      auto &new_solib = sos.emplace_back ();
+      auto &new_solib = sos.emplace_back (solib_target_so_ops);
 
       /* We don't need a copy of the name in INFO anymore.  */
       new_solib.name = std::move (info->name);
index f5922aa5f5d6e319671c9dc14514d3b434180ba5..09d56c08b9533045860961e9b2d04597875541d5 100644 (file)
@@ -54,8 +54,19 @@ struct lm_info
 
 using lm_info_up = std::unique_ptr<lm_info>;
 
+struct solib_ops;
+
 struct solib : intrusive_list_node<solib>
 {
+  /* Constructor
+
+     OPS is the solib_ops implementation providing this solib.  */
+  explicit solib (const solib_ops &ops) : m_ops (&ops) {}
+
+  /* Return the solib_ops implementation providing this solib.  */
+  const solib_ops &ops () const
+  { return *m_ops; }
+
   /* Free symbol-file related contents of SO and reset for possible reloading
      of SO.  If we have opened a BFD for SO, close it.  If we have placed SO's
      sections in some target's section table, the caller is responsible for
@@ -111,6 +122,10 @@ struct solib : intrusive_list_node<solib>
      that supports outputting multiple segments once the related code
      supports them.  */
   CORE_ADDR addr_low = 0, addr_high = 0;
+
+private:
+  /* The solib_ops responsible for this solib.  */
+  const solib_ops *m_ops;
 };
 
 /* A unique pointer to an solib.  */