Skip to content

Commit e69c5d6

Browse files
authored
Merge pull request #82231 from al45tair/eng/PR-148168098-6.1
[IRGen] Don't use GOTPCREL relocations for x86 ELF.
2 parents e55f033 + a1585b6 commit e69c5d6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,13 +3699,15 @@ static llvm::GlobalVariable *createGOTEquivalent(IRGenModule &IGM,
36993699
llvm::GlobalValue::PrivateLinkage,
37003700
global,
37013701
llvm::Twine("got.") + globalName);
3702-
3702+
37033703
// rdar://problem/53836960: i386 ld64 also mis-links relative references
37043704
// to GOT entries.
37053705
// rdar://problem/59782487: issue with on-device JITd expressions.
37063706
// The JIT gets confused by private vars accessed across object files.
3707+
// rdar://148168098: ELF x86 GOTPCREL relaxation can break metadata.
37073708
if (!IGM.getOptions().UseJIT &&
3708-
(!IGM.Triple.isOSDarwin() || IGM.Triple.getArch() != llvm::Triple::x86)) {
3709+
(!IGM.Triple.isOSDarwin() || IGM.Triple.getArch() != llvm::Triple::x86) &&
3710+
(!IGM.Triple.isOSBinFormatELF() || !IGM.Triple.isX86())) {
37093711
gotEquivalent->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
37103712
} else {
37113713
ApplyIRLinkage(IRLinkage::InternalLinkOnceODR)

0 commit comments

Comments
 (0)