diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp index 83c2662cb663c..4fd5cc0827a91 100644 --- a/lib/IRGen/GenDecl.cpp +++ b/lib/IRGen/GenDecl.cpp @@ -3736,13 +3736,15 @@ static llvm::GlobalVariable *createGOTEquivalent(IRGenModule &IGM, llvm::GlobalValue::PrivateLinkage, global, llvm::Twine("got.") + globalName); - + // rdar://problem/53836960: i386 ld64 also mis-links relative references // to GOT entries. // rdar://problem/59782487: issue with on-device JITd expressions. // The JIT gets confused by private vars accessed across object files. + // rdar://148168098: ELF x86 GOTPCREL relaxation can break metadata. if (!IGM.getOptions().UseJIT && - (!IGM.Triple.isOSDarwin() || IGM.Triple.getArch() != llvm::Triple::x86)) { + (!IGM.Triple.isOSDarwin() || IGM.Triple.getArch() != llvm::Triple::x86) && + (!IGM.Triple.isOSBinFormatELF() || !IGM.Triple.isX86())) { gotEquivalent->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global); } else { ApplyIRLinkage(IRLinkage::InternalLinkOnceODR)