mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-22 23:24:59 +00:00
Do not propagate ELF-specific stuff (data.rel) into other targets. This simplifies code and also ensures correctness.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68032 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -25,6 +25,7 @@ namespace llvm {
|
|||||||
struct ELFTargetAsmInfo: public TargetAsmInfo {
|
struct ELFTargetAsmInfo: public TargetAsmInfo {
|
||||||
explicit ELFTargetAsmInfo(const TargetMachine &TM);
|
explicit ELFTargetAsmInfo(const TargetMachine &TM);
|
||||||
|
|
||||||
|
SectionKind::Kind SectionKindForGlobal(const GlobalValue *GV) const;
|
||||||
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;
|
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;
|
||||||
virtual std::string printSectionFlags(unsigned flags) const;
|
virtual std::string printSectionFlags(unsigned flags) const;
|
||||||
const Section* MergeableConstSection(const GlobalVariable *GV) const;
|
const Section* MergeableConstSection(const GlobalVariable *GV) const;
|
||||||
|
@@ -85,9 +85,6 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
|||||||
else
|
else
|
||||||
return TextSection;
|
return TextSection;
|
||||||
case SectionKind::Data:
|
case SectionKind::Data:
|
||||||
case SectionKind::DataRel:
|
|
||||||
case SectionKind::DataRelRO:
|
|
||||||
case SectionKind::DataRelROLocal:
|
|
||||||
case SectionKind::ThreadData:
|
case SectionKind::ThreadData:
|
||||||
case SectionKind::BSS:
|
case SectionKind::BSS:
|
||||||
case SectionKind::ThreadBSS:
|
case SectionKind::ThreadBSS:
|
||||||
|
@@ -44,6 +44,30 @@ ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM)
|
|||||||
SectionFlags::Writeable);
|
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()) {
|
||||||
|
Constant *C = GVar->getInitializer();
|
||||||
|
bool isConstant = GVar->isConstant();
|
||||||
|
unsigned Reloc = RelocBehaviour();
|
||||||
|
if (Reloc != Reloc::None && C->ContainsRelocations(Reloc))
|
||||||
|
return (C->ContainsRelocations(Reloc::Local) ?
|
||||||
|
(isConstant ?
|
||||||
|
SectionKind::DataRelROLocal : SectionKind::DataRelLocal) :
|
||||||
|
(isConstant ?
|
||||||
|
SectionKind::DataRelRO : SectionKind::DataRel));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Kind;
|
||||||
|
}
|
||||||
|
|
||||||
const Section*
|
const Section*
|
||||||
ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
||||||
SectionKind::Kind Kind = SectionKindForGlobal(GV);
|
SectionKind::Kind Kind = SectionKindForGlobal(GV);
|
||||||
|
@@ -220,18 +220,14 @@ TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
|
|||||||
unsigned Reloc = RelocBehaviour();
|
unsigned Reloc = RelocBehaviour();
|
||||||
|
|
||||||
// We already did a query for 'all' relocs, thus - early exits.
|
// We already did a query for 'all' relocs, thus - early exits.
|
||||||
if (Reloc == Reloc::LocalOrGlobal) {
|
if (Reloc == Reloc::LocalOrGlobal)
|
||||||
return (C->ContainsRelocations(Reloc::Local) ?
|
return SectionKind::Data;
|
||||||
SectionKind::DataRelROLocal : SectionKind::DataRelRO);
|
else if (Reloc == Reloc::None)
|
||||||
} else if (Reloc == Reloc::None)
|
|
||||||
return SectionKind::ROData;
|
return SectionKind::ROData;
|
||||||
else {
|
else {
|
||||||
// Ok, target wants something funny. Honour it.
|
// Ok, target wants something funny. Honour it.
|
||||||
if (C->ContainsRelocations(Reloc)) {
|
return (C->ContainsRelocations(Reloc) ?
|
||||||
return (Reloc == Reloc::Local ?
|
SectionKind::Data : SectionKind::ROData);
|
||||||
SectionKind::DataRelROLocal : SectionKind::DataRelRO);
|
|
||||||
} else
|
|
||||||
return SectionKind::ROData;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Check, if initializer is a null-terminated string
|
// Check, if initializer is a null-terminated string
|
||||||
@@ -243,18 +239,7 @@ TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Variable either is not constant or thread-local - output to data section.
|
// Variable either is not constant or thread-local - output to data section.
|
||||||
if (isThreadLocal)
|
return (isThreadLocal ? SectionKind::ThreadData : SectionKind::Data);
|
||||||
return SectionKind::ThreadData;
|
|
||||||
|
|
||||||
if (GVar->hasInitializer()) {
|
|
||||||
Constant *C = GVar->getInitializer();
|
|
||||||
unsigned Reloc = RelocBehaviour();
|
|
||||||
if (Reloc != Reloc::None && C->ContainsRelocations(Reloc))
|
|
||||||
return (C->ContainsRelocations(Reloc::Local) ?
|
|
||||||
SectionKind::DataRelLocal : SectionKind::DataRel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return SectionKind::Data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
|
@@ -305,12 +305,17 @@ X86COFFTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
|
|||||||
switch (kind) {
|
switch (kind) {
|
||||||
case SectionKind::Text:
|
case SectionKind::Text:
|
||||||
return ".text$linkonce" + GV->getName();
|
return ".text$linkonce" + GV->getName();
|
||||||
|
case SectionKind::Data:
|
||||||
|
case SectionKind::BSS:
|
||||||
|
case SectionKind::ThreadData:
|
||||||
|
case SectionKind::ThreadBSS:
|
||||||
|
return ".data$linkonce" + GV->getName();
|
||||||
case SectionKind::ROData:
|
case SectionKind::ROData:
|
||||||
case SectionKind::RODataMergeConst:
|
case SectionKind::RODataMergeConst:
|
||||||
case SectionKind::RODataMergeStr:
|
case SectionKind::RODataMergeStr:
|
||||||
return ".rdata$linkonce" + GV->getName();
|
return ".rdata$linkonce" + GV->getName();
|
||||||
default:
|
default:
|
||||||
return ".data$linkonce" + GV->getName();
|
assert(0 && "Unknown section kind");
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user