This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/4] Handle copy relocations


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,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]