diff options
author | Alan Modra <amodra@gmail.com> | 2017-02-03 19:18:37 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-02-22 09:40:25 +1030 |
commit | d29655b6c3564dc00ff538822c3d383e74697425 (patch) | |
tree | 739f127441974040793cc6e92f7491bafa6ea430 | |
parent | c8dbc58e0a9be82937b5875fe53412e260a6cc42 (diff) | |
download | binutils-gdb-d29655b6c3564dc00ff538822c3d383e74697425.tar.gz |
[GOLD] PowerPC64 TOC indirect to TOC relative segfault
* powerpc.cc (Powerpc_relobj::make_toc_relative): Don't crash
when no .toc section exists.
-rw-r--r-- | gold/ChangeLog | 4 | ||||
-rw-r--r-- | gold/powerpc.cc | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index 0aeff82535f..30d3244f744 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -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): diff --git a/gold/powerpc.cc b/gold/powerpc.cc index fec18cdbb9d..81f9bff1c5d 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 |