[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>
Fri, 3 Feb 2017 09:36:53 +0000 (20:06 +1030)
* powerpc.cc (Powerpc_relobj::make_toc_relative): Don't crash
when no .toc section exists.

gold/ChangeLog
gold/powerpc.cc

index c50e1f8933281ac5964524658724ee94b6f53708..56fe9669dbf053a175351ed3e932e148b4ef3c3d 100644 (file)
@@ -1,3 +1,8 @@
+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-31  Cary Coutant  <ccoutant@gmail.com>
 
        PR gold/21090
index a67c33618bd5a28548213a9b3c2f459fe061960a..4abfcec16d6efa765310d71758beb0eba698b0ed 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
This page took 0.034059 seconds and 4 git commands to generate.