diff options
Diffstat (limited to 'lib/Target/ELFTargetAsmInfo.cpp')
-rw-r--r-- | lib/Target/ELFTargetAsmInfo.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp index bd2dd0a064..8ace00abd9 100644 --- a/lib/Target/ELFTargetAsmInfo.cpp +++ b/lib/Target/ELFTargetAsmInfo.cpp @@ -57,7 +57,13 @@ ELFTargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const { if (GVar->hasInitializer()) { Constant *C = GVar->getInitializer(); bool isConstant = GVar->isConstant(); - unsigned Reloc = RelocBehaviour(); + + + // By default - all relocations in PIC mode would force symbol to be + // placed in r/w section. + unsigned Reloc = (TM.getRelocationModel() != Reloc::Static ? + Reloc::LocalOrGlobal : Reloc::None); + if (Reloc != Reloc::None && C->ContainsRelocations(Reloc)) return (C->ContainsRelocations(Reloc::Global) ? (isConstant ? |