diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp index 10fcf2ecbf46a..9d1b18005f400 100644 --- a/lib/IRGen/GenDecl.cpp +++ b/lib/IRGen/GenDecl.cpp @@ -3699,13 +3699,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)