mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-18 06:38:41 +00:00
move ELF-specific code into ELFTargetAsmInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76976 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e5ca0ac36b
commit
2dcafe4b8f
@ -31,6 +31,11 @@ namespace llvm {
|
|||||||
virtual const Section *
|
virtual const Section *
|
||||||
getSectionForMergableConstant(uint64_t Size, unsigned ReloInfo) const;
|
getSectionForMergableConstant(uint64_t Size, unsigned ReloInfo) const;
|
||||||
|
|
||||||
|
/// getFlagsForNamedSection - If this target wants to be able to infer
|
||||||
|
/// section flags based on the name of the section specified for a global
|
||||||
|
/// variable, it can implement this. This is used on ELF systems so that
|
||||||
|
/// ".tbss" gets the TLS bit set etc.
|
||||||
|
virtual unsigned getFlagsForNamedSection(const char *Section) const;
|
||||||
|
|
||||||
SectionKind::Kind SectionKindForGlobal(const GlobalValue *GV) const;
|
SectionKind::Kind SectionKindForGlobal(const GlobalValue *GV) const;
|
||||||
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;
|
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;
|
||||||
|
@ -586,7 +586,13 @@ namespace llvm {
|
|||||||
virtual const char *
|
virtual const char *
|
||||||
getSectionPrefixForUniqueGlobal(SectionKind::Kind Kind) const;
|
getSectionPrefixForUniqueGlobal(SectionKind::Kind Kind) const;
|
||||||
|
|
||||||
|
/// getFlagsForNamedSection - If this target wants to be able to infer
|
||||||
|
/// section flags based on the name of the section specified for a global
|
||||||
|
/// variable, it can implement this. This is used on ELF systems so that
|
||||||
|
/// ".tbss" gets the TLS bit set etc.
|
||||||
|
virtual unsigned getFlagsForNamedSection(const char *Section) const {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// SectionKindForGlobal - This hook allows the target to select proper
|
/// SectionKindForGlobal - This hook allows the target to select proper
|
||||||
|
@ -145,6 +145,33 @@ ELFTargetAsmInfo::getSectionForMergableConstant(uint64_t Size,
|
|||||||
return getReadOnlySection(); // .rodata
|
return getReadOnlySection(); // .rodata
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getFlagsForNamedSection - If this target wants to be able to infer
|
||||||
|
/// section flags based on the name of the section specified for a global
|
||||||
|
/// variable, it can implement this.
|
||||||
|
unsigned ELFTargetAsmInfo::getFlagsForNamedSection(const char *Name) const {
|
||||||
|
unsigned Flags = 0;
|
||||||
|
if (Name[0] != '.') return 0;
|
||||||
|
|
||||||
|
// Some lame default implementation based on some magic section names.
|
||||||
|
if (strncmp(Name, ".gnu.linkonce.b.", 16) == 0 ||
|
||||||
|
strncmp(Name, ".llvm.linkonce.b.", 17) == 0 ||
|
||||||
|
strncmp(Name, ".gnu.linkonce.sb.", 17) == 0 ||
|
||||||
|
strncmp(Name, ".llvm.linkonce.sb.", 18) == 0)
|
||||||
|
Flags |= SectionFlags::BSS;
|
||||||
|
else if (strcmp(Name, ".tdata") == 0 ||
|
||||||
|
strncmp(Name, ".tdata.", 7) == 0 ||
|
||||||
|
strncmp(Name, ".gnu.linkonce.td.", 17) == 0 ||
|
||||||
|
strncmp(Name, ".llvm.linkonce.td.", 18) == 0)
|
||||||
|
Flags |= SectionFlags::TLS;
|
||||||
|
else if (strcmp(Name, ".tbss") == 0 ||
|
||||||
|
strncmp(Name, ".tbss.", 6) == 0 ||
|
||||||
|
strncmp(Name, ".gnu.linkonce.tb.", 17) == 0 ||
|
||||||
|
strncmp(Name, ".llvm.linkonce.tb.", 18) == 0)
|
||||||
|
Flags |= SectionFlags::BSS | SectionFlags::TLS;
|
||||||
|
|
||||||
|
return Flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const Section*
|
const Section*
|
||||||
ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
|
ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
|
||||||
|
@ -224,30 +224,6 @@ static unsigned SectionFlagsForGlobal(const GlobalValue *GV,
|
|||||||
return Flags;
|
return Flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned GetSectionFlagsForNamedELFSection(const char *Name) {
|
|
||||||
unsigned Flags = 0;
|
|
||||||
// Some lame default implementation based on some magic section names.
|
|
||||||
if (strncmp(Name, ".gnu.linkonce.b.", 16) == 0 ||
|
|
||||||
strncmp(Name, ".llvm.linkonce.b.", 17) == 0 ||
|
|
||||||
strncmp(Name, ".gnu.linkonce.sb.", 17) == 0 ||
|
|
||||||
strncmp(Name, ".llvm.linkonce.sb.", 18) == 0)
|
|
||||||
Flags |= SectionFlags::BSS;
|
|
||||||
else if (strcmp(Name, ".tdata") == 0 ||
|
|
||||||
strncmp(Name, ".tdata.", 7) == 0 ||
|
|
||||||
strncmp(Name, ".gnu.linkonce.td.", 17) == 0 ||
|
|
||||||
strncmp(Name, ".llvm.linkonce.td.", 18) == 0)
|
|
||||||
Flags |= SectionFlags::TLS;
|
|
||||||
else if (strcmp(Name, ".tbss") == 0 ||
|
|
||||||
strncmp(Name, ".tbss.", 6) == 0 ||
|
|
||||||
strncmp(Name, ".gnu.linkonce.tb.", 17) == 0 ||
|
|
||||||
strncmp(Name, ".llvm.linkonce.tb.", 18) == 0)
|
|
||||||
Flags |= SectionFlags::BSS | SectionFlags::TLS;
|
|
||||||
|
|
||||||
return Flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SectionKind::Kind
|
SectionKind::Kind
|
||||||
TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
|
TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
|
||||||
// Early exit - functions should be always in text sections.
|
// Early exit - functions should be always in text sections.
|
||||||
@ -298,7 +274,7 @@ const Section *TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
|
|||||||
// If the target has magic semantics for certain section names, make sure to
|
// If the target has magic semantics for certain section names, make sure to
|
||||||
// pick up the flags. This allows the user to write things with attribute
|
// pick up the flags. This allows the user to write things with attribute
|
||||||
// section and still get the appropriate section flags printed.
|
// section and still get the appropriate section flags printed.
|
||||||
Flags |= GetSectionFlagsForNamedELFSection(GV->getSection().c_str());
|
Flags |= getFlagsForNamedSection(GV->getSection().c_str());
|
||||||
|
|
||||||
return getNamedSection(GV->getSection().c_str(), Flags);
|
return getNamedSection(GV->getSection().c_str(), Flags);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user