Fix the MASM asmprinter's lies. It does not want to emit code to .text/.data

it wants it emitted to _text/_data.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28185 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-05-09 05:12:53 +00:00
parent 4632d7a570
commit dad9c5a14f
4 changed files with 17 additions and 7 deletions

View File

@ -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;

View 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!");

View File

@ -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;

View File

@ -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
}