Fix failure to diagnose GOTOFF relocation to undef symbol in shared lib (i386).
authorCary Coutant <ccoutant@gmail.com>
Sun, 27 Mar 2016 23:09:56 +0000 (16:09 -0700)
committerCary Coutant <ccoutant@gmail.com>
Sun, 27 Mar 2016 23:11:27 +0000 (16:11 -0700)
gold/
PR gold/16111
* i386.cc (Target_i386): Add check for fully-resolved symbol for
R_386_GOTOFF.

gold/ChangeLog
gold/i386.cc

index c3b4577d022e6bcde8966d3e3096cbb3e4e598cc..e03536bcdc506bd14767020f14db25c530c38951 100644 (file)
@@ -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.
index 8bcd44e5c917c5f6309f9162473e8be83b455ac5..8aaa2a881aa49a3acf81eefb4d3cc857188a8b2b 100644 (file)
@@ -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);