From: Simon Marchi Date: Mon, 16 Jun 2025 19:33:01 +0000 (-0400) Subject: gdb/solib: add solib -> solib_ops backlink X-Git-Tag: binutils-2_45~219 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f643d36e9f82946efc9676b73be037ecfafb895a;p=thirdparty%2Fbinutils-gdb.git gdb/solib: add solib -> solib_ops backlink 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 --- diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c index 1c6d695f3d0..b10e41164bd 100644 --- a/gdb/solib-aix.c +++ b/gdb/solib-aix.c @@ -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 (info); diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c index 4003c77748c..88a2962f5dd 100644 --- a/gdb/solib-darwin.c +++ b/gdb/solib-darwin.c @@ -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 (); diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index cc1b2a7fb8a..6cc0264b45c 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -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 (); li->map = loadmap; /* Fetch the name. */ diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index ceef72208a1..12d3140b513 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -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 (); li->map = loadmap; li->got_value = got_addr; diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c index 86e5d82aaa1..bda19ac4b82 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -210,7 +210,7 @@ solibs_from_rocm_sos (const std::vector &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 (*so.lm_info); newobj.name = so.name; diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 80214f23cb4..b5945f5ac82 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1050,7 +1050,7 @@ solib_from_svr4_sos (const std::vector &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 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; diff --git a/gdb/solib-target.c b/gdb/solib-target.c index 68dc3cc92c0..61b841928ff 100644 --- a/gdb/solib-target.c +++ b/gdb/solib-target.c @@ -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); diff --git a/gdb/solib.h b/gdb/solib.h index f5922aa5f5d..09d56c08b95 100644 --- a/gdb/solib.h +++ b/gdb/solib.h @@ -54,8 +54,19 @@ struct lm_info using lm_info_up = std::unique_ptr; +struct solib_ops; + struct solib : intrusive_list_node { + /* 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 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. */