diff --git a/gen/naked.cpp b/gen/naked.cpp index 711e5b76..786d5e8b 100644 --- a/gen/naked.cpp +++ b/gen/naked.cpp @@ -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; }