Merge commit d3aeac8e2 from llvm git (by Justin Hibbits)

[PowerPC] Only use PLT annotations if using PIC relocation model

  Summary:
  The default static (non-PIC, non-PIE) model for 32-bit powerpc does
  not use @PLT annotations and relocations in GCC.  LLVM shouldn't use
  @PLT annotations either, because it breaks secure-PLT linking with
  (some versions of?) GNU LD.

  Update the available-externally.ll test to reflect that default mode
  should be the same as the static relocation, by using the same check
  prefix.

  Reviewed by:    sfertile
  Differential Revision: https://reviews.llvm.org/D70570

Reviewed by:	jhibbits
Differential Revision: https://reviews.freebsd.org/D22913
This commit is contained in:
Dimitry Andric 2019-12-26 21:20:45 +00:00
parent 57fd4aa7e4
commit 4f58713dcc

View File

@ -4952,7 +4952,12 @@ PrepareCall(SelectionDAG &DAG, SDValue &Callee, SDValue &InFlag, SDValue &Chain,
if (auto *G = dyn_cast<GlobalAddressSDNode>(Callee))
GV = G->getGlobal();
bool Local = TM.shouldAssumeDSOLocal(*Mod, GV);
bool UsePlt = !Local && Subtarget.isTargetELF() && !isPPC64;
// The PLT is only used in 32-bit ELF PIC mode. Attempting to use the PLT in
// a static relocation model causes some versions of GNU LD (2.17.50, at
// least) to force BSS-PLT, instead of secure-PLT, even if all objects are
// built with secure-PLT.
bool UsePlt = !Local && Subtarget.isTargetELF() && !isPPC64 &&
Subtarget.getTargetMachine().getRelocationModel() == Reloc::PIC_;
// If the callee is a GlobalAddress/ExternalSymbol node (quite common,
// every direct call is) turn it into a TargetGlobalAddress /