This is the mail archive of the
mailing list for the GDB project.
Re: [PATCH 2/4] Handle copy relocations
- From: Tom Tromey <tromey at adacore dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Tom Tromey <tromey at adacore dot com>, gdb-patches at sourceware dot org
- Date: Tue, 30 Jul 2019 15:00:08 -0600
- Subject: Re: [PATCH 2/4] Handle copy relocations
- References: <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org>
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
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.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index f81efb4f433..90dfde0f1e9 100644
@@ -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,