[GOLD] PowerPC64 TOC indirect to TOC relative segfault

* powerpc.cc (Powerpc_relobj::make_toc_relative): Don't crash
	when no .toc section exists.
This commit is contained in:
Alan Modra 2017-02-03 19:18:37 +10:30
parent 1b7e3d2fb7
commit e666304ec6
2 changed files with 11 additions and 0 deletions

View 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

View 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