summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/MC/MCAsmInfo.h9
-rw-r--r--llvm/lib/MC/MCAsmInfo.cpp6
-rw-r--r--llvm/lib/MC/MCSectionELF.cpp7
3 files changed, 16 insertions, 6 deletions
diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h
index 9bb0fa63c52..384584ef4ef 100644
--- a/llvm/include/llvm/MC/MCAsmInfo.h
+++ b/llvm/include/llvm/MC/MCAsmInfo.h
@@ -414,6 +414,15 @@ public:
/// syntactically correct.
virtual bool isValidUnquotedName(StringRef Name) const;
+ /// Return true if the .section directive should be omitted when
+ /// emitting \p SectionName. For example:
+ ///
+ /// shouldOmitSectionDirective(".text")
+ ///
+ /// returns false => .section .text,#alloc,#execinstr
+ /// returns true => .text
+ virtual bool shouldOmitSectionDirective(StringRef SectionName) const;
+
bool usesSunStyleELFSectionSwitchSyntax() const {
return SunStyleELFSectionSwitchSyntax;
}
diff --git a/llvm/lib/MC/MCAsmInfo.cpp b/llvm/lib/MC/MCAsmInfo.cpp
index 100dc7c3dc6..36e10b3c6a0 100644
--- a/llvm/lib/MC/MCAsmInfo.cpp
+++ b/llvm/lib/MC/MCAsmInfo.cpp
@@ -157,3 +157,9 @@ bool MCAsmInfo::isValidUnquotedName(StringRef Name) const {
return true;
}
+
+bool MCAsmInfo::shouldOmitSectionDirective(StringRef SectionName) const {
+ // FIXME: Does .section .bss/.data/.text work everywhere??
+ return SectionName == ".text" || SectionName == ".data" ||
+ (SectionName == ".bss" && !usesELFSectionDirectiveForBSS());
+}
diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp
index b4448d79a2d..92d2b9667c8 100644
--- a/llvm/lib/MC/MCSectionELF.cpp
+++ b/llvm/lib/MC/MCSectionELF.cpp
@@ -27,12 +27,7 @@ bool MCSectionELF::ShouldOmitSectionDirective(StringRef Name,
if (isUnique())
return false;
- // FIXME: Does .section .bss/.data/.text work everywhere??
- if (Name == ".text" || Name == ".data" ||
- (Name == ".bss" && !MAI.usesELFSectionDirectiveForBSS()))
- return true;
-
- return false;
+ return MAI.shouldOmitSectionDirective(Name);
}
static void printName(raw_ostream &OS, StringRef Name) {
OpenPOWER on IntegriCloud