make SectionKindForGlobal target independent, and therefore non-virtual.

It's classifications now include elf-specific discriminators.  Targets
that don't have these features (like darwin and pecoff) simply treat
data.rel like data, etc.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76993 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-07-24 19:15:47 +00:00
parent 49f846805e
commit b303504a56
6 changed files with 73 additions and 54 deletions

View File

@@ -45,33 +45,6 @@ ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM)
SectionFlags::Writeable);
}
SectionKind::Kind
ELFTargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
SectionKind::Kind Kind = TargetAsmInfo::SectionKindForGlobal(GV);
if (Kind != SectionKind::Data)
return Kind;
// Decide, whether we need data.rel stuff
const GlobalVariable* GVar = dyn_cast<GlobalVariable>(GV);
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.
switch (C->getRelocationInfo()) {
default: break;
case Constant::LocalRelocation:
return isConstant ? SectionKind::DataRelROLocal :
SectionKind::DataRelLocal;
case Constant::GlobalRelocations:
return isConstant ? SectionKind::DataRelRO : SectionKind::DataRel;
}
}
return Kind;
}
const Section*
ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
@@ -91,6 +64,8 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
const GlobalVariable *GVar = cast<GlobalVariable>(GV);
switch (Kind) {
default: llvm_unreachable("Unsuported section kind for global");
case SectionKind::BSS:
return getBSSSection_();
case SectionKind::Data:
case SectionKind::DataRel:
return DataRelSection;
@@ -100,8 +75,6 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
return DataRelROSection;
case SectionKind::DataRelROLocal:
return DataRelROLocalSection;
case SectionKind::BSS:
return getBSSSection_();
case SectionKind::ROData:
return getReadOnlySection();
case SectionKind::RODataMergeStr: