[ELF][PPC] Don't relax ifunc toc-indirect accesses to toc-relative
authorFangrui Song <maskray@google.com>
Tue, 6 Aug 2019 16:57:54 +0000 (16:57 +0000)
committerFangrui Song <maskray@google.com>
Tue, 6 Aug 2019 16:57:54 +0000 (16:57 +0000)
commitc55c0598f915da2fe1cd637ade1d985beb6a7c84
tree65c288f270ad2d614da56ca74c3a45792458e4a3
parent9c52f66f48226e58f5e811e01add6c246209fea4
[ELF][PPC] Don't relax ifunc toc-indirect accesses to toc-relative

Fixes PR42759.

```
// If ifunc is taken address in -fPIC code, it may have a toc entry
.section .toc,"aw",@progbits
  .quad ifunc

// ifunc may be defined as STT_GNU_IFUNC in another object file
.type ifunc, %gnu_indirect_function
```

If ifunc is non-preemptable (e.g. when linking an executable), the toc
entry will be relocated by R_PPC64_IRELATIVE.

R_*_IRELATIVE represents the symbolic value of a
non-preemptable ifunc (not associated with a canonical PLT) in a writable location. It has an unknown value at
link time, so we cannot apply toc-indirect to toc-relative relaxation.

Reviewed By: luporl, sfertile

Differential Revision: https://reviews.llvm.org/D65755

llvm-svn: 368057
lld/ELF/Arch/PPC64.cpp
lld/test/ELF/ppc64-toc-relax-ifunc.s [new file with mode: 0644]