This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils 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]

[binutils-gdb] Fix failure to diagnose GOTOFF relocation to undef symbol in shared lib (i386).


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ed700649d0607e6509d5bbc51f4617bbae13a543

commit ed700649d0607e6509d5bbc51f4617bbae13a543
Author: Cary Coutant <ccoutant@gmail.com>
Date:   Sun Mar 27 16:09:56 2016 -0700

    Fix failure to diagnose GOTOFF relocation to undef symbol in shared lib (i386).
    
    gold/
    	PR gold/16111
    	* i386.cc (Target_i386): Add check for fully-resolved symbol for
    	R_386_GOTOFF.

Diff:
---
 gold/ChangeLog |  6 ++++++
 gold/i386.cc   | 17 +++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index c3b4577..e03536b 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,9 @@
+2016-03-27  Cary Coutant  <ccoutant@gmail.com>
+
+	PR gold/16111
+	* i386.cc (Target_i386): Add check for fully-resolved symbol for
+	R_386_GOTOFF.
+
 2016-03-22  Nick Clifton  <nickc@redhat.com>
 
 	* configure: Regenerate.
diff --git a/gold/i386.cc b/gold/i386.cc
index 8bcd44e..8aaa2a8 100644
--- a/gold/i386.cc
+++ b/gold/i386.cc
@@ -2394,6 +2394,23 @@ Target_i386::Scan::global(Symbol_table* symtab,
       break;
 
     case elfcpp::R_386_GOTOFF:
+      // A GOT-relative reference must resolve locally.
+      if (!gsym->is_defined())
+        gold_error(_("%s: relocation R_386_GOTOFF against undefined symbol %s"
+		     " cannot be used when making a shared object"),
+		   object->name().c_str(), gsym->name());
+      else if (gsym->is_from_dynobj())
+        gold_error(_("%s: relocation R_386_GOTOFF against external symbol %s"
+		     " cannot be used when making a shared object"),
+		   object->name().c_str(), gsym->name());
+      else if (gsym->is_preemptible())
+        gold_error(_("%s: relocation R_386_GOTOFF against preemptible symbol %s"
+		     " cannot be used when making a shared object"),
+		   object->name().c_str(), gsym->name());
+      // We need a GOT section.
+      target->got_section(symtab, layout);
+      break;
+
     case elfcpp::R_386_GOTPC:
       // We need a GOT section.
       target->got_section(symtab, layout);


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