summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ELFTargetAsmInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/ELFTargetAsmInfo.cpp')
-rw-r--r--llvm/lib/Target/ELFTargetAsmInfo.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/Target/ELFTargetAsmInfo.cpp b/llvm/lib/Target/ELFTargetAsmInfo.cpp
index 5deabee0ba2..1bcfaf91ad0 100644
--- a/llvm/lib/Target/ELFTargetAsmInfo.cpp
+++ b/llvm/lib/Target/ELFTargetAsmInfo.cpp
@@ -54,20 +54,20 @@ ELFTargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
// Decide, whether we need data.rel stuff
const GlobalVariable* GVar = dyn_cast<GlobalVariable>(GV);
- if (GVar->hasInitializer()) {
+ if (GVar->hasInitializer() && TM.getRelocationModel() != Reloc::Static) {
Constant *C = GVar->getInitializer();
bool isConstant = GVar->isConstant();
-
// By default - all relocations in PIC mode would force symbol to be
// placed in r/w section.
- if (TM.getRelocationModel() != Reloc::Static &&
- C->ContainsRelocations(Reloc::LocalOrGlobal))
- return (C->ContainsRelocations(Reloc::Global) ?
- (isConstant ?
- SectionKind::DataRelRO : SectionKind::DataRel) :
- (isConstant ?
- SectionKind::DataRelROLocal : SectionKind::DataRelLocal));
+ switch (C->getRelocationInfo()) {
+ default: break;
+ case 1:
+ return isConstant ? SectionKind::DataRelROLocal :
+ SectionKind::DataRelLocal;
+ case 2:
+ return isConstant ? SectionKind::DataRelRO : SectionKind::DataRel;
+ }
}
return Kind;
OpenPOWER on IntegriCloud