diff --git a/gen/asm-x86-32.h b/gen/asm-x86-32.h index f33fa3af..0edbe613 100644 --- a/gen/asm-x86-32.h +++ b/gen/asm-x86-32.h @@ -2165,8 +2165,8 @@ namespace AsmParserx8632 { use_star = false; // simply write out the mangle - // on osx, prepend extra _ - if ( global.params.os == OSMacOSX ) + // on osx and mingw, prepend extra _ + if ( global.params.os == OSMacOSX || global.params.os == OSWindows ) insnTemplate << "_"; insnTemplate << decl->mangle(); // addOperand2("${", ":c}", Arg_Pointer, e, asmcode); diff --git a/gen/asm-x86-64.h b/gen/asm-x86-64.h index cfab461d..3fef6e05 100644 --- a/gen/asm-x86-64.h +++ b/gen/asm-x86-64.h @@ -1656,7 +1656,7 @@ namespace AsmParserx8664 } // osx needs an extra underscore - if ( global.params.os == OSMacOSX ) + if ( global.params.os == OSMacOSX || global.params.os == OSWindows ) insnTemplate << "_"; // print out the mangle @@ -2287,8 +2287,8 @@ namespace AsmParserx8664 { use_star = false; // simply write out the mangle - // on osx, prepend extra _ - if ( global.params.os == OSMacOSX ) + // on osx and windows, prepend extra _ + if ( global.params.os == OSMacOSX || global.params.os == OSWindows ) insnTemplate << "_"; insnTemplate << decl->mangle(); // addOperand2("${", ":c}", Arg_Pointer, e, asmcode); diff --git a/gen/naked.cpp b/gen/naked.cpp index 773f446f..4b72d974 100644 --- a/gen/naked.cpp +++ b/gen/naked.cpp @@ -144,7 +144,14 @@ void DtoDefineNakedFunction(FuncDeclaration* fd) if (DtoIsTemplateInstance(fd)) { linkage = "weak"; - tmpstr << "section\t.gnu.linkonce.t." << mangle << ",\"ax\",@progbits"; + tmpstr << "section\t.gnu.linkonce.t."; + if (global.params.os != OSWindows) + { + tmpstr << mangle << ",\"ax\",@progbits"; + } else + { + tmpstr << "_" << mangle << ",\"ax\""; + } section = tmpstr.str(); } asmstr << "\t." << section << std::endl; @@ -154,10 +161,11 @@ void DtoDefineNakedFunction(FuncDeclaration* fd) { std::string def = "def"; std::string endef = "endef"; - asmstr << "\t." << def << "\t" << mangle << ";"; + asmstr << "\t." << def << "\t_" << mangle << ";"; // 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; + asmstr << "_"; } else { asmstr << "\t." << linkage << "\t" << mangle << std::endl;