[PATCH] D12423: MCAsmInfo: Allow targets to specify when the .section directive should be omitted

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 14:42:54 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL248618: MCAsmInfo: Allow targets to specify when the .section directive should be… (authored by tstellar).

Changed prior to commit:
  http://reviews.llvm.org/D12423?vs=34222&id=35765#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12423

Files:
  llvm/trunk/include/llvm/MC/MCAsmInfo.h
  llvm/trunk/lib/MC/MCAsmInfo.cpp
  llvm/trunk/lib/MC/MCSectionELF.cpp

Index: llvm/trunk/include/llvm/MC/MCAsmInfo.h
===================================================================
--- llvm/trunk/include/llvm/MC/MCAsmInfo.h
+++ llvm/trunk/include/llvm/MC/MCAsmInfo.h
@@ -414,6 +414,15 @@
   /// 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;
   }
Index: llvm/trunk/lib/MC/MCAsmInfo.cpp
===================================================================
--- llvm/trunk/lib/MC/MCAsmInfo.cpp
+++ llvm/trunk/lib/MC/MCAsmInfo.cpp
@@ -157,3 +157,9 @@
 
   return true;
 }
+
+bool MCAsmInfo::shouldOmitSectionDirective(StringRef SectionName) const {
+  // FIXME: Does .section .bss/.data/.text work everywhere??
+  return SectionName == ".text" || SectionName == ".data" ||
+        (SectionName == ".bss" && !usesELFSectionDirectiveForBSS());
+}
Index: llvm/trunk/lib/MC/MCSectionELF.cpp
===================================================================
--- llvm/trunk/lib/MC/MCSectionELF.cpp
+++ llvm/trunk/lib/MC/MCSectionELF.cpp
@@ -27,12 +27,7 @@
   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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12423.35765.patch
Type: text/x-patch
Size: 1808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150925/93e9701b/attachment.bin>


More information about the llvm-commits mailing list