OSDN Git Service

Fix the MASM asmprinter's lies. It does not want to emit code to .text/.data
authorChris Lattner <sabre@nondot.org>
Tue, 9 May 2006 05:12:53 +0000 (05:12 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 9 May 2006 05:12:53 +0000 (05:12 +0000)
it wants it emitted to _text/_data.

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

lib/Target/X86/X86ATTAsmPrinter.cpp
lib/Target/X86/X86AsmPrinter.cpp
lib/Target/X86/X86AsmPrinter.h
lib/Target/X86/X86IntelAsmPrinter.cpp

index b674f15..7adc1c5 100755 (executable)
@@ -46,11 +46,11 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   switch (F->getLinkage()) {
   default: assert(0 && "Unknown linkage type!");
   case Function::InternalLinkage:  // Symbols default to internal.
-    SwitchToTextSection(".text", F);
+    SwitchToTextSection(DefaultTextSection, F);
     EmitAlignment(4, F);     // FIXME: This should be parameterized somewhere.
     break;
   case Function::ExternalLinkage:
-    SwitchToTextSection(".text", F);
+    SwitchToTextSection(DefaultTextSection, F);
     EmitAlignment(4, F);     // FIXME: This should be parameterized somewhere.
     O << "\t.globl\t" << CurrentFnName << "\n";
     break;
index 0e2bab7..dceade4 100644 (file)
@@ -50,6 +50,8 @@ bool X86SharedAsmPrinter::doInitialization(Module &M) {
   
   forDarwin = false;
   PrivateGlobalPrefix = ".L";
+  DefaultTextSection = ".text";
+  DefaultDataSection = ".data";
   
   switch (Subtarget->TargetType) {
   case X86Subtarget::isDarwin:
@@ -119,7 +121,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
           O << "\t.zerofill __DATA__, __common, " << name << ", "
             << Size << ", " << Align;
       } else {
-        SwitchToDataSection(".data", I);
+        SwitchToDataSection(DefaultDataSection, I);
         if (LCOMMDirective != NULL) {
           if (I->hasInternalLinkage()) {
             O << LCOMMDirective << name << "," << Size;
@@ -157,7 +159,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
         O << "\t.globl " << name << "\n";
         // FALL THROUGH
       case GlobalValue::InternalLinkage:
-        SwitchToDataSection(".data", I);
+        SwitchToDataSection(DefaultDataSection, I);
         break;
       default:
         assert(0 && "Unknown linkage type!");
index c4d67b6..b653b34 100755 (executable)
@@ -69,6 +69,10 @@ struct X86SharedAsmPrinter : public AsmPrinter {
   }
 
   bool forDarwin;  // FIXME: eliminate.
+  
+  const char *DefaultTextSection;   // "_text" for MASM, ".text" for others.
+  const char *DefaultDataSection;   // "_data" for MASM, ".data" for others.
+  
 
   // Necessary for Darwin to print out the apprioriate types of linker stubs
   std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
index d33cb8c..4bc0e10 100755 (executable)
@@ -37,7 +37,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   EmitConstantPool(MF.getConstantPool());
 
   // Print out labels for the function.
-  SwitchToTextSection(".code", MF.getFunction());
+  SwitchToTextSection("_text", MF.getFunction());
   EmitAlignment(4);
   if (MF.getFunction()->getLinkage() == GlobalValue::ExternalLinkage)
     O << "\tpublic " << CurrentFnName << "\n";
@@ -302,6 +302,9 @@ bool X86IntelAsmPrinter::doInitialization(Module &M) {
   Data64bitsDirective = "\tdq\t";
   HasDotTypeDotSizeDirective = false;
   Mang->markCharUnacceptable('.');
+  
+  DefaultTextSection = "_text";
+  DefaultDataSection = "_data";
 
   O << "\t.686\n\t.model flat\n\n";
 
@@ -359,7 +362,7 @@ bool X86IntelAsmPrinter::doFinalization(Module &M) {
       O << "\tpublic " << name << "\n";
       // FALL THROUGH
     case GlobalValue::InternalLinkage:
-      SwitchToDataSection(".data", I);
+      SwitchToDataSection(DefaultDataSection, I);
       break;
     default:
       assert(0 && "Unknown linkage type!");
@@ -378,7 +381,8 @@ bool X86IntelAsmPrinter::doFinalization(Module &M) {
   
   // Bypass X86SharedAsmPrinter::doFinalization().
   AsmPrinter::doFinalization(M);
-  SwitchToDataSection("", 0);
+  SwitchToDataSection("_data", 0);
+  O << "_data\tends\n";
   O << "\tend\n";
   return false; // success
 }