aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-02-03 19:18:37 +1030
committerAlan Modra <amodra@gmail.com>2017-02-03 20:06:53 +1030
commite666304ec603bb3249f80bac97200f2b4520ab0f (patch)
treedf1e7832c00fe5f7518d52a6994e76611cc3dc98 /gold/powerpc.cc
parentFix compile time warning messages when compiling binutils with gcc 7.0.1. (diff)
downloadbinutils-gdb-e666304ec603bb3249f80bac97200f2b4520ab0f.tar.gz
binutils-gdb-e666304ec603bb3249f80bac97200f2b4520ab0f.tar.bz2
binutils-gdb-e666304ec603bb3249f80bac97200f2b4520ab0f.zip
[GOLD] PowerPC64 TOC indirect to TOC relative segfault
* powerpc.cc (Powerpc_relobj::make_toc_relative): Don't crash when no .toc section exists.
Diffstat (limited to 'gold/powerpc.cc')
-rw-r--r--gold/powerpc.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/gold/powerpc.cc b/gold/powerpc.cc
index a67c33618bd..4abfcec16d6 100644
--- a/gold/powerpc.cc
+++ b/gold/powerpc.cc
@@ -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