llvm-mc: Support -n, useful for comparing -integrated-as output since the
authorDaniel Dunbar <daniel@zuster.org>
Sat, 13 Mar 2010 02:20:57 +0000 (02:20 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 13 Mar 2010 02:20:57 +0000 (02:20 +0000)
compiler may not lead with the text section.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98418 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCParser/AsmParser.h
lib/MC/MCParser/AsmParser.cpp
tools/llvm-mc/llvm-mc.cpp

index 66b6dac23a59b96a4fbc08fbcc77059fe3fda657..06e0920950d4d32c83c4ed7ba81fcc7a3592879c 100644 (file)
@@ -64,7 +64,7 @@ public:
             const MCAsmInfo &MAI);
   ~AsmParser();
 
-  bool Run();
+  bool Run(bool NoInitialTextSection);
 
   
   void AddDirectiveHandler(StringRef Directive,
index 50964aea42b1b41ca039a9c2e228a13a4dae7e5e..a241106465a0c7b661eed1f7c59f0880dba3758e 100644 (file)
@@ -138,15 +138,14 @@ const AsmToken &AsmParser::Lex() {
   return *tok;
 }
 
-bool AsmParser::Run() {
-  // Create the initial section.
+bool AsmParser::Run(bool NoInitialTextSection) {
+  // Create the initial section, if requested.
   //
-  // FIXME: Support -n.
   // FIXME: Target hook & command line option for initial section.
-  Out.SwitchSection(getMachOSection("__TEXT", "__text",
-                                    MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
-                                    0, SectionKind::getText()));
-
+  if (!NoInitialTextSection)
+    Out.SwitchSection(getMachOSection("__TEXT", "__text",
+                                      MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
+                                      0, SectionKind::getText()));
 
   // Prime the lexer.
   Lex();
index 48e0d3d6b54487b29206d6b88953291cb31e7934..666f0babf329d4808b16eae4d05d4c27960578d1 100644 (file)
@@ -84,6 +84,10 @@ static cl::opt<std::string>
 TripleName("triple", cl::desc("Target triple to assemble for, "
                               "see -version for available targets"));
 
+static cl::opt<bool>
+NoInitialTextSection("n", cl::desc(
+                   "Don't assume assembly file starts in the text section"));
+
 enum ActionType {
   AC_AsLex,
   AC_Assemble,
@@ -303,7 +307,7 @@ static int AssembleInput(const char *ProgName) {
 
   Parser.setTargetParser(*TAP.get());
 
-  int Res = Parser.Run();
+  int Res = Parser.Run(NoInitialTextSection);
   if (Out != &fouts())
     delete Out;