Fix MinGW names for naked functions.

This commit is contained in:
David Nadlinger
2013-02-13 00:02:40 +01:00
parent 8fd3eda728
commit 6449d5dea2

View File

@@ -151,20 +151,21 @@ void DtoDefineNakedFunction(FuncDeclaration* fd)
}
else
{
std::string fullMangle;
if (global.params.targetTriple.getOS() == llvm::Triple::MinGW32)
{
fullMangle = "_";
}
fullMangle += mangle;
const char* linkage = "globl";
std::string section = "text";
if (DtoIsTemplateInstance(fd))
{
linkage = "weak";
tmpstr << "section\t.gnu.linkonce.t.";
if (isWin)
{
tmpstr << "_" << mangle << ",\"ax\"";
}
else
{
tmpstr << mangle << ",\"ax\",@progbits";
}
tmpstr << "section\t.gnu.linkonce.t." << fullMangle << ",\"ax\"";
if (!isWin)
tmpstr << ",@progbits";
section = tmpstr.str();
}
asmstr << "\t." << section << std::endl;
@@ -172,18 +173,18 @@ void DtoDefineNakedFunction(FuncDeclaration* fd)
if (isWin)
{
asmstr << "\t.def\t" << mangle << ";";
asmstr << "\t.def\t" << fullMangle << ";";
// hard code these two numbers for now since gas ignores .scl and llvm
// is defaulting to .type 32 for everything I have seen
asmstr << "\t.scl 2; .type 32;\t.endef" << std::endl;
}
else
{
asmstr << "\t." << linkage << "\t" << mangle << std::endl;
asmstr << "\t.type\t" << mangle << ",@function" << std::endl;
asmstr << "\t.type\t" << fullMangle << ",@function" << std::endl;
}
asmstr << mangle << ":" << std::endl;
asmstr << "\t." << linkage << "\t" << fullMangle << std::endl;
asmstr << fullMangle << ":" << std::endl;
}