From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 85LFC7LxeWk4tRkAWB0awg (envelope-from ) for ; Wed, 28 Jan 2026 06:23:30 -0500 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=P1mqpPrH; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 21F521E08D; Wed, 28 Jan 2026 06:23:30 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id CBA7C1E08D for ; Wed, 28 Jan 2026 06:23:28 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 3C6C34BAD141 for ; Wed, 28 Jan 2026 11:23:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C6C34BAD141 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=P1mqpPrH Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 8BD994BA2E21 for ; Wed, 28 Jan 2026 11:22:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8BD994BA2E21 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8BD994BA2E21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769599379; cv=none; b=fd2TqT2wP8v2CUJ2rk4z7SlZO/khx27usyaPrJb2LoJVkUBba1PXxJ0yi7gY6cBco9ZBVmYsSntnkv0/Yz/iM9qKHA35sF046DCQ7YCoomsjVVc3v+Y4FsyMVgweaeXoFivLk9sfDE1ZDHz1SZEBaqjKxo0CzRfQMPAbKDp/u+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769599379; c=relaxed/simple; bh=f3tSweeUkQByIMnA6UT+gNORSHBs4wz3zgmtkHvy618=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=cIlF+6LB307A9cCPTezI8MjhSju8RONKBpfC6Lf9eJ/gYr0VjYDAsq6nwmLihPl4skRbwCgrnyC7Qv5NG+FFdZrQ4JWBqPPCFPoWFSXl9KDk3VMgOt7/+JFnofoVB2RDSx/NRlH8vwBaRC/fSfQtypx8GOnv2ypVpqyLu10y5bg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BD994BA2E21 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769599379; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=eT+GtBUcS/2BaQiHtTSA5oIqtcV6jha4gu4pn5HORMk=; b=P1mqpPrH4yvG2txUa242qO0BM8QkS2qRc2Ju0MDhurpXMnfE5WIzFY8B6WjAF4dLdQGde7 xNCB2toB1wYkr5e3grtjEo/81VG3hKYZkqBrXIvEVmJq6ppQjpW4FzTMx/elvlbzNK91UB bbG2Czixg9NQ/jxZEcEAlK7Q2T0s9hY= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-655-bnbxji-kNp-VVEOQPGdaoA-1; Wed, 28 Jan 2026 06:22:58 -0500 X-MC-Unique: bnbxji-kNp-VVEOQPGdaoA-1 X-Mimecast-MFC-AGG-ID: bnbxji-kNp-VVEOQPGdaoA_1769599377 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-43284f60a8aso4597723f8f.3 for ; Wed, 28 Jan 2026 03:22:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769599376; x=1770204176; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dwa1sJXvXuI95nEd5WbWDF5FIXdgDQ6W1j7IGP3xH5A=; b=NMB2T+FAj11HKqxhT+e47IW73JSucgzMjOmpRAZvGcgHFKAeBsvZLJUz/dIZIhGa7K r6gfFjoOZfnVPhHOuHiGhIbolOTEFuB1ax76Ow4wMFOoUFiB3hPjsQu4LnQp1dCHlTEz a0wpu9ojAcPuaz54tOr4rCv8udMN4ib3kqhXNuBgcye+2hMBovYE1S3ScxIZ4TNpoP6F h5YMDma6sZeAmPgab9/iCbICU5xDLdF057+Q/qZ2bYk735DIasd42h20wTpPgv+pXtE5 W1mZ/xqRhfLPatU1eoUCXOaNljmKLoVT/8Y66G+45AelJQZdVJh8VpvOs5F9ACnrIPLv y24g== X-Forwarded-Encrypted: i=1; AJvYcCWd8TEorPjw5mC6zn7DjBwcTT3ezOT6L5fOZ0VeFHD0E6y4QCkAPh8InSTnVInLf6PIic6xKgxrV0LXbw==@sourceware.org X-Gm-Message-State: AOJu0YxIkjnJxbGBeAYrEhUepPt3hAXhZX26DlnUR8Xgy9yqzVwvlnTf GhF0qltVj9expk9MtHp17jJXJadvasBMat68aW+ngDIyqzF12FlXVaTubqC9Vi1paTMNZCHkzyC kBBeHns1gPOsS/AK4VlX9Ac4k0hAZY+SbUT2MZ1c/XHU8y7v6+iRXBSvd1F4ufAG/Sk8TLTQ= X-Gm-Gg: AZuq6aLOYrOZvmhCBnwtD1q8hPqKnP8U17rhQq9NA6oLz31UDiAWUC6hoLFNk0p/mKF LTn5zY1x+nKzt6NJ5uuQFDcoy98GFHQVwQsDbmfgi5Of8Am2Uu5htrHM+Piha4ff/aslVU+UE3Z aLlglqRWVE+kwqmN+QhdJ2Ggj61LWo0VFqfJrBtrlpr1JwyGXdtcV966QaI7JDwfAlAz38ucSWP aq7MEsGLBtw1ZUdwgVQns4yOOtknHVxtA763SttQshbg2hkma2jl4IQJgmDjENQkNKPxJbgqHph KxdJaxIbAjfS0p+B41X9FwWYLzjpdD1DHUmyhMF0ZMgIaTrq55cnDjmGTqtWrJC/6L7BQ8Yoms6 8qcqK X-Received: by 2002:a05:6000:2481:b0:435:9f1b:8d19 with SMTP id ffacd0b85a97d-435dd1c0b8amr6818894f8f.38.1769599376132; Wed, 28 Jan 2026 03:22:56 -0800 (PST) X-Received: by 2002:a05:6000:2481:b0:435:9f1b:8d19 with SMTP id ffacd0b85a97d-435dd1c0b8amr6818858f8f.38.1769599375537; Wed, 28 Jan 2026 03:22:55 -0800 (PST) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435e10ed952sm6266153f8f.10.2026.01.28.03.22.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jan 2026 03:22:55 -0800 (PST) From: Andrew Burgess To: Guinevere Larsen , gdb-patches@sourceware.org Cc: Guinevere Larsen Subject: Re: [PATCH v6 1/3] gdb: make lookup_minimal_symbol_linkage work with linker namespaces In-Reply-To: <20251029125831.2102647-2-guinevere@redhat.com> References: <20251029125831.2102647-1-guinevere@redhat.com> <20251029125831.2102647-2-guinevere@redhat.com> Date: Wed, 28 Jan 2026 11:22:54 +0000 Message-ID: <87jyx2f0c1.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: zBNxcXB0Iqei5q-yNG9CI4BOV2Ol4V38EZkjYcfWEeA_1769599377 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Guinevere Larsen writes: > When a symbol found by GDB may have copy relocation, GDB calculates the > address of the symbol by checking all the objfiles in the current > program space for another instance of the same symbol, and returns the > address of the first instance found. > > This works well when linker namespaces are not involved, but fails when > a symbol is present in more than one namespace. That's because copy > relocations respect linker namespace boundaries, and so if we're trying > to find the symbol in namespace N, the symbol from a different namespace > M may be returned, if the SO containing the symbol was loaded in M > before N. > > To make the search work correctly, lookup_minimal_symbol_linkage would > need to also respect linker namespace boundaries. However, to avoid > leaking solib knowledge to minsyms, and because of how little > information is passed to the function, this commit instead makes the > function take a vector of objfiles to search, in place of the program > space. This makes it so symbol::get_maybe_copied_address (and the > equivalent of minimal_symbol) need to request the objfiles for the > correct namespace, since they have enough context to figure out the > namespace. Creating the vector is left as a function in solib.c > > Since minimal_symbol::get_maybe_copied_address only searches main_file > objfiles, if we can guarantee that only one is loaded for each program > space, we could avoid the work of constructing an std::vector that will > be mostly ignored. However, I couldn't convince myself that that is the > case, so I decided to keep the behavior exactly as is. > > Ideally, lookup_minimal_symbol_linkage would receive an iterator instead > of a vector, but as of now it isn't possible to do forward declarations > of nested types (we'd need program_space::objfiles_range) and > progspace.h can't be included into minsyms.h, so we're stuck > constructing a vector for it. I think the wording of this paragraph is unchanged since v5. You're saying: I'd like to do but the current GDB code prevents me. Based on this, I asked, my not rework GDB. You then explained that there's a deeper reason for why you cannot do what you want. I would suggest you update the commit message in cases like this as future readers might have the same questions I had... ... except in this case, I have some deeper thoughts on this patch. > > Finally, as some minor refactoring, find_solib_for_objfile is moved to > solib.c to simplify looking for which namespace contains the objfile > where we found the symbol the user was looking for. I'll not leave this comment inline with the diff, as it's a more general observation. But I'm not super keen on find_solib_for_objfile moving out of solib-svr4.c, at least not in its current form. The reason: the function is broken and really shouldn't be used at all. The relationship between objfiles and solibs is 1 to many. The obvious example here is the runtime linker, this will be mapped multiple times, but only appear in memory once. There will be many solibs, but only a single objfile. Prior to this patch, find_solib_for_objfile was used in one place, in svr4_solib_ops::iterate_over_objfiles_in_search_order. If we look at how it is used, the function takes a CURRENT_OBJFILE and limits symbols searches to objfiles in the same namespace. But what if the dynamic linker is the CURRENT_OBJFILE? Right now we'll just search the first namespace that we find, when we probably should be searching all namespaces. I got thinking about this because, I'm really keen on the build a vector prior to calling lookup_minimal_symbol_linkage approach. I cannot really put my finger on why I don't like this, but it just doesn't feel great. I think my problem is that we already have a list of objfiles, and all we really want to do is ask for each one; is this in the right linker namespace? The whole pre-build a vector business is necessitated because, given an objfile, we cannot easily answer the question; is this in the same namespace as some other objfile. If we could ask that question easily, then the change here would be simple, right? In minsyms.c, in lookup_minimal_symbol_linkage, we'd do this: const solib_ops *ops = pspace->solib_ops (); for (objfile &objfile : pspace->objfiles ()) if (ops->in_same_linker_namespace (objfile, original_objfile)) { ... existing code ... } I did some hacking, and gives the same answer as the current approach, but it isn't efficient as (currently) this requires looping over all solib within the in_same_linker_namespace method. And we need that loop because find_solib_for_objfile is broken. I wonder if we should first try to fix find_solib_for_objfile? If this could both return all solib in some way (more below), and maybe not require a loop over all solib to search for the objfile, then this would make what you want to do really straight forward. On returning all solib, in order to avoid building a vector, I wondered if we should consider linking all "sibling" solib into some kind of linked list (sibling solib being solib that reference the same objfile), then find_solib_for_objfile would return a single solib*, but users would then need to iterate over all sibling solib. > --- > gdb/dwarf2/ada-imported.c | 8 +++- > gdb/minsyms.c | 15 ++++--- > gdb/minsyms.h | 9 ++-- > gdb/solib-svr4.c | 20 --------- > gdb/solib.c | 86 ++++++++++++++++++++++++++++++++++++++- > gdb/solib.h | 19 +++++++++ > gdb/symtab.c | 13 +++++- > 7 files changed, 136 insertions(+), 34 deletions(-) > > diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c > index 48e6fccdb73..15ecfdaf6ce 100644 > --- a/gdb/dwarf2/ada-imported.c > +++ b/gdb/dwarf2/ada-imported.c > @@ -35,9 +35,13 @@ static struct value * > ada_imported_read_variable (struct symbol *symbol, const frame_info_ptr &frame) > { > const char *name = get_imported_name (symbol); > + > + std::vector objfiles_to_search; > + for (objfile &objf : symbol->objfile ()->pspace ()->objfiles ()) > + objfiles_to_search.push_back (&objf); > + > bound_minimal_symbol minsym > - = lookup_minimal_symbol_linkage (symbol->objfile ()->pspace (), name, > - true, false); > + = lookup_minimal_symbol_linkage (objfiles_to_search, name, true, false); I would have expected some discussion in the commit message about why this use of lookup_minimal_symbol_linkage doesn't require the same namespace handling. I haven't looked at the code to try and figure it out, so maybe it is obvious. But still, I think it's worth mentioning. > if (minsym.minsym == nullptr) > error (_("could not find imported name %s"), name); > return value_at (symbol->type (), minsym.value_address ()); > diff --git a/gdb/minsyms.c b/gdb/minsyms.c > index 90a0c601c59..7e4f47b8c3f 100644 > --- a/gdb/minsyms.c > +++ b/gdb/minsyms.c > @@ -54,6 +54,7 @@ > #include "gdbsupport/cxx-thread.h" > #include "gdbsupport/parallel-for.h" > #include "inferior.h" > +#include "solib.h" > > /* Return true if MINSYM is a cold clone symbol. > Recognize f.i. these symbols (mangled/demangled): > @@ -584,19 +585,21 @@ lookup_minimal_symbol_linkage (const char *name, struct objfile *objf, > /* See minsyms.h. */ > > bound_minimal_symbol > -lookup_minimal_symbol_linkage (program_space *pspace, const char *name, > - bool match_static_type, bool only_main) > +lookup_minimal_symbol_linkage (gdb::array_view objfiles_to_search, > + const char *name, bool match_static_type, > + bool only_main) > { > - for (objfile &objfile : pspace->objfiles ()) > + for (objfile *objfile : objfiles_to_search) > { > - if (objfile.separate_debug_objfile_backlink != nullptr) > + if (objfile == nullptr > + || objfile->separate_debug_objfile_backlink != nullptr) > continue; > > - if (only_main && (objfile.flags & OBJF_MAINLINE) == 0) > + if (only_main && (objfile->flags & OBJF_MAINLINE) == 0) > continue; > > bound_minimal_symbol minsym > - = lookup_minimal_symbol_linkage (name, &objfile, match_static_type); > + = lookup_minimal_symbol_linkage (name, objfile, match_static_type); > if (minsym.minsym != nullptr) > return minsym; > } > diff --git a/gdb/minsyms.h b/gdb/minsyms.h > index ed38044a38c..4aa8a428470 100644 > --- a/gdb/minsyms.h > +++ b/gdb/minsyms.h > @@ -237,11 +237,14 @@ extern bound_minimal_symbol lookup_minimal_symbol_linkage > > /* A variant of lookup_minimal_symbol_linkage that iterates over all > objfiles of PSPACE. If ONLY_MAIN is true, then only an objfile with > - OBJF_MAINLINE will be considered. */ > + OBJF_MAINLINE will be considered. This function should receive a > + program_space::objfile_ranges instead, but we can't include progspace.h > + here, nor can we do forward declarations of nested types, so std::vector > + will waste a bit of memory to work around that issue. */ The reference to PSPACE here is now out of date. Thanks, Andrew > > extern bound_minimal_symbol lookup_minimal_symbol_linkage > - (program_space *pspace, const char *name, bool match_static_type, > - bool only_main) ATTRIBUTE_NONNULL (1); > + (gdb::array_view objfiles_to_search, const char *name, > + bool match_static_type, bool only_main); > > /* Look through all the current minimal symbol tables and find the > first minimal symbol that matches NAME and PC. If OBJF is non-NULL, > diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c > index c91e0b2c37b..49d2b207c36 100644 > --- a/gdb/solib-svr4.c > +++ b/gdb/solib-svr4.c > @@ -3595,26 +3595,6 @@ lp64_svr4_solib_ops::fetch_link_map_offsets () const > } > > > -/* Return the DSO matching OBJFILE or nullptr if none can be found. */ > - > -static const solib * > -find_solib_for_objfile (struct objfile *objfile) > -{ > - if (objfile == nullptr) > - return nullptr; > - > - /* If OBJFILE is a separate debug object file, look for the original > - object file. */ > - if (objfile->separate_debug_objfile_backlink != nullptr) > - objfile = objfile->separate_debug_objfile_backlink; > - > - for (const solib &so : current_program_space->solibs ()) > - if (so.objfile == objfile) > - return &so; > - > - return nullptr; > -} > - > /* Return the address of the r_debug object for the namespace containing > SOLIB or zero if it cannot be found. This may happen when symbol files > are added manually, for example, or with the main executable. > diff --git a/gdb/solib.c b/gdb/solib.c > index dade2a76a48..34b0d6b3f9c 100644 > --- a/gdb/solib.c > +++ b/gdb/solib.c > @@ -1825,8 +1825,92 @@ solib_linker_namespace_count (program_space *pspace) > return 0; > } > > -/* Implementation of the linker_namespace convenience variable. > +/* See solib.h. */ > + > +const solib * > +find_solib_for_objfile (struct objfile *objfile) > +{ > + if (objfile == nullptr) > + return nullptr; > + > + /* If OBJFILE is a separate debug object file, look for the original > + object file. */ > + if (objfile->separate_debug_objfile_backlink != nullptr) > + objfile = objfile->separate_debug_objfile_backlink; > + > + for (const solib &so : objfile->pspace ()->solibs ()) > + if (so.objfile == objfile) > + return &so; > + > + return nullptr; > +} > + > +/* See solib.h. */ > + > +std::vector > +get_objfiles_in_linker_namespace (int nsid, program_space *pspace) > +{ > + std::vector objfiles_in_ns; > + const solib_ops *ops = pspace->solib_ops (); > + > + gdb_assert (ops->supports_namespaces ()); > + > + /* If we're looking at the default namespace, we also need > + to add the mainline objfiles by hand, since there is no > + solib associated with those files. We add them first > + because if we're searching for copy relocations, they > + should be in the main file, so we'll find it faster. */ > + if (nsid == 0) > + for (objfile &objf : pspace->objfiles ()) > + if ((objf.flags & OBJF_MAINLINE) != 0) > + objfiles_in_ns.push_back (&objf); > + > + std::vector solibs = ops->get_solibs_in_ns (nsid); > + /* Reserve for efficiency. */ > + objfiles_in_ns.reserve (solibs.size () + objfiles_in_ns.size ()); > + for (const solib *so : solibs) > + objfiles_in_ns.push_back (so->objfile); > + > + return objfiles_in_ns; > +} > + > +/* See solib.h. */ > + > +std::vector > +get_objfiles_in_linker_namespace (objfile *objfile) > +{ > + program_space *pspace = objfile->pspace (); > + const solib_ops *ops = pspace->solib_ops (); > + const solib *so = find_solib_for_objfile (objfile); > + > + /* If the inferior hasn't started yet, the solib_ops won't be > + set for the program space. Since namespaces only make sense > + when the inferior has already created some, we can just skip > + it here. */ > + if (ops != nullptr && ops->supports_namespaces () > + /* If we're searching for a symbol from the linker, we'll reach here > + before having any namespaces. Return all objfiles since the > + boundaries haven't been setup yet. */ > + && ops->num_active_namespaces () > 0 > + /* When trying to load libthread_db, we can search for a symbol in an > + objfile with no associated solib. In that case, again, we should > + return all objfiles. */ > + && so != nullptr) > + { > + return get_objfiles_in_linker_namespace (ops->find_solib_ns (*so), > + pspace); > + } > + > + /* If any of the previous conditions isn't satisfied, we return > + the full list of objfiles in the inferior. */ > + std::vector found_objfiles; > + for (struct objfile &objf : objfile->pspace ()->objfiles ()) > + found_objfiles.push_back (&objf); > > + return found_objfiles; > +} > + > +/* Implementation of the linker_namespace convenience variable. > This returns the GDB internal identifier of the linker namespace, > for the selected frame, as an integer. If the inferior doesn't support > linker namespaces, this always returns 0. */ > diff --git a/gdb/solib.h b/gdb/solib.h > index 85ea6675b79..81389da6267 100644 > --- a/gdb/solib.h > +++ b/gdb/solib.h > @@ -20,6 +20,9 @@ > #ifndef GDB_SOLIB_H > #define GDB_SOLIB_H > > +/* Forward decl's for prototypes */ > +struct objfile; > + > #include "gdb_bfd.h" > #include "gdbsupport/function-view.h" > #include "gdbsupport/intrusive_list.h" > @@ -409,4 +412,20 @@ extern void handle_solib_event (void); > > extern int solib_linker_namespace_count (program_space *pspace); > > +/* Return a vector with pointers of all objfiles in the namespace > + NSID. This version assumes that the inferior supports namespaces. */ > + > +std::vector get_objfiles_in_linker_namespace > + (int nsid, program_space *pspace); > + > +/* Return a vector with pointers of all objfiles in the same namespace > + as OBJFILE. If the inferior doesn't support namespaces, return all > + objfiles in the program_space. */ > + > +std::vector get_objfiles_in_linker_namespace (objfile *objfile); > + > +/* Return the DSO matching OBJFILE or nullptr if none can be found. */ > + > +const solib *find_solib_for_objfile (struct objfile *objfile); > + > #endif /* GDB_SOLIB_H */ > diff --git a/gdb/symtab.c b/gdb/symtab.c > index 3b0687c0750..786dd9f56ba 100644 > --- a/gdb/symtab.c > +++ b/gdb/symtab.c > @@ -74,6 +74,7 @@ > #include "gdbsupport/common-utils.h" > #include > #include "gdbsupport/unordered_set.h" > +#include "solib.h" > > /* Forward declarations for local functions. */ > > @@ -6575,8 +6576,12 @@ symbol::get_maybe_copied_address () const > gdb_assert (this->loc_class () == LOC_STATIC); > > const char *linkage_name = this->linkage_name (); > + > + std::vector objfiles_to_search > + (get_objfiles_in_linker_namespace (this->objfile ())); > + > bound_minimal_symbol minsym > - = lookup_minimal_symbol_linkage (this->objfile ()->pspace (), linkage_name, > + = lookup_minimal_symbol_linkage (objfiles_to_search, linkage_name, > false, false); > if (minsym.minsym != nullptr) > return minsym.value_address (); > @@ -6593,8 +6598,12 @@ minimal_symbol::get_maybe_copied_address (objfile *objf) const > gdb_assert ((objf->flags & OBJF_MAINLINE) == 0); > > const char *linkage_name = this->linkage_name (); > + > + std::vector objfiles_to_search > + (get_objfiles_in_linker_namespace (objf)); > + > bound_minimal_symbol found > - = lookup_minimal_symbol_linkage (objf->pspace (), linkage_name, > + = lookup_minimal_symbol_linkage (objfiles_to_search, linkage_name, > false, true); > if (found.minsym != nullptr) > return found.value_address (); > -- > 2.51.0