]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[GOLD] PowerPC64 TOC indirect to TOC relative segfault
authorAlan Modra <amodra@gmail.com>
Fri, 3 Feb 2017 08:48:37 +0000 (19:18 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 21 Feb 2017 23:10:25 +0000 (09:40 +1030)
* powerpc.cc (Powerpc_relobj::make_toc_relative): Don't crash
when no .toc section exists.

gold/ChangeLog
gold/powerpc.cc

index 0aeff82535f61707dc05b96ed73ca6d58867be7f..30d3244f744595c0695b6af176b7012b9a051439 100644 (file)
@@ -1,6 +1,10 @@
 2017-02-22  Alan Modra  <amodra@gmail.com>
 
        Apply from master
+       2017-02-03  Alan Modra  <amodra@gmail.com>
+       * powerpc.cc (Powerpc_relobj::make_toc_relative): Don't crash
+       when no .toc section exists.
+
        2017-01-13  H.J. Lu  <hongjiu.lu@intel.com>
        PR gold/21040
        * powerpc.cc (Powerpc_relobj<size, big_endian>::make_toc_relative):
index fec18cdbb9d7af1e406cfd937f285fef7d51553e..81f9bff1c5de3423a4cde258dfebb74437c329fb 100644 (file)
@@ -1986,6 +1986,12 @@ Powerpc_relobj<size, big_endian>::make_toc_relative(
   if (size != 64)
     return false;
 
+  // With -mcmodel=medium code it is quite possible to have
+  // toc-relative relocs referring to objects outside the TOC.
+  // Don't try to look at a non-existent TOC.
+  if (this->toc_shndx() == 0)
+    return false;
+
   // Convert VALUE back to an address by adding got_base (see below),
   // then to an offset in the TOC by subtracting the TOC output
   // section address and the TOC output offset.  Since this TOC output