From patchwork Tue Jul 30 21:00:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33862 Received: (qmail 4538 invoked by alias); 30 Jul 2019 21:00:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 118215 invoked by uid 89); 30 Jul 2019 21:00:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=*die, investigated X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 30 Jul 2019 21:00:14 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 22E92116F8F; Tue, 30 Jul 2019 17:00:10 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Yubv3q2ZzMku; Tue, 30 Jul 2019 17:00:10 -0400 (EDT) Received: from murgatroyd (97-122-178-82.hlrn.qwest.net [97.122.178.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 9F03F116EAA; Tue, 30 Jul 2019 17:00:09 -0400 (EDT) From: Tom Tromey To: Pedro Alves Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [PATCH 2/4] Handle copy relocations References: <20190627145235.21222-1-tromey@adacore.com> <20190627145235.21222-3-tromey@adacore.com> Date: Tue, 30 Jul 2019 15:00:08 -0600 In-Reply-To: (Pedro Alves's message of "Sat, 20 Jul 2019 02:10:58 +0100") Message-ID: <87d0hrkzl3.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Pedro> To be more correct, this depends on ABI, or how you compile your Pedro> binary. Compiling the main binary as PIC/PIE may or may not use Pedro> copy relocations and use GOT accesses instead, for example. Yes, thanks for mentioning that. Pedro> I'm surprised to find no tests in this patch? The existing Ada exception-catching tests cover this, so I didn't add a new test. Pedro> FAIL: gdb.base/print-file-var.exp: hidden=1: dlopen=0: version_id_main=0: 'print-file-var-lib2.c'::this_version_id == v2 I haven't investigated the other failures yet, but I think this one in particular is an existing bug in c-exp.y. What happens is that this does not actually look up the symbol from that source file! Instead it finds the symbol in print-file-var-lib1.c. Pedro> But I'm wondering whether fixing the hidden=1 cases would fit Pedro> with the design of your patch, or does that scenario require Pedro> thinking about all this differently? I think applying the appended probably makes sense. This rules out symbols where the corresponding minsym is hidden. Tom diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index f81efb4f433..90dfde0f1e9 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -21653,11 +21653,19 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, else if (attr2 && (DW_UNSND (attr2) != 0)) { if (SYMBOL_CLASS (sym) == LOC_STATIC - && (objfile->flags & OBJF_MAINLINE) == 0) + && (objfile->flags & OBJF_MAINLINE) == 0 + && dwarf2_per_objfile->can_copy) { /* A global static variable might be subject to - copy relocation. */ - sym->maybe_copied = dwarf2_per_objfile->can_copy; + copy relocation. We first check for a local + minsym, though, because maybe the symbol was + marked hidden, in which case this would not + apply. */ + minimal_symbol *found + = (lookup_minimal_symbol_linkage + (SYMBOL_LINKAGE_NAME (sym), objfile)); + if (found != nullptr) + sym->maybe_copied = 1; } /* A variable with DW_AT_external is never static,