Index: tools/spec2def/spec2def.c =================================================================== --- tools/spec2def/spec2def.c (版本 62320) +++ tools/spec2def/spec2def.c (工作副本) @@ -42,7 +42,6 @@ char *pszArchString = "i386"; char *pszArchString2; char *pszDllName = 0; -char *gpszUnderscore = ""; int gbDebug; #define DbgPrint(...) (!gbDebug || fprintf(stderr, __VA_ARGS__)) @@ -257,52 +256,99 @@ { fprintf(file, "; File generated automatically, do not edit! \n\n"); - if (giArch == ARCH_X86) - fprintf(file, ".586\n.model flat\n"); - - fprintf(file, ".code\n"); + switch (giArch) + { + case ARCH_X86: + { + fprintf(file, ".586\n.model flat\n.code\n"); + break; + } + case ARCH_AMD64: + { + fprintf(file, ".code\n"); + break; + } + case ARCH_ARM: + { + fprintf(file, " area .rdata, data, readonly\n"); + break; + } + } } int OutputLine_asmstub(FILE *fileDest, EXPORT *pexp) { - /* Handle autoname */ - if (pexp->strName.len == 1 && pexp->strName.buf[0] == '@') + switch (giArch) { - fprintf(fileDest, "PUBLIC %sordinal%d\n%sordinal%d: nop\n", - gpszUnderscore, pexp->nOrdinal, gpszUnderscore, pexp->nOrdinal); + case ARCH_X86: + { + /* Handle autoname */ + if (pexp->strName.len == 1 && pexp->strName.buf[0] == '@') + { + fprintf(fileDest, "PUBLIC _ordinal%d\n_ordinal%d: nop\n", + pexp->nOrdinal, pexp->nOrdinal); + } + else if (pexp->nCallingConvention == CC_STDCALL) + { + fprintf(fileDest, "PUBLIC __stub_%.*s@%d\n__stub_%.*s@%d: nop\n", + pexp->strName.len, pexp->strName.buf, pexp->nStackBytes, + pexp->strName.len, pexp->strName.buf, pexp->nStackBytes); + } + else if (pexp->nCallingConvention == CC_FASTCALL) + { + fprintf(fileDest, "PUBLIC @_stub_%.*s@%d\n@_stub_%.*s@%d: nop\n", + pexp->strName.len, pexp->strName.buf, pexp->nStackBytes, + pexp->strName.len, pexp->strName.buf, pexp->nStackBytes); + } + else if (pexp->nCallingConvention == CC_CDECL || + pexp->nCallingConvention == CC_STUB) + { + fprintf(fileDest, "PUBLIC __stub_%.*s\n__stub_%.*s: nop\n", + pexp->strName.len, pexp->strName.buf, + pexp->strName.len, pexp->strName.buf); + } + else if (pexp->nCallingConvention == CC_EXTERN) + { + fprintf(fileDest, "PUBLIC __stub_%.*s\n__stub_%.*s:\n", + pexp->strName.len, pexp->strName.buf, + pexp->strName.len, pexp->strName.buf); + } + break; + } + case ARCH_AMD64: + { + /* Handle autoname */ + if (pexp->strName.len == 1 && pexp->strName.buf[0] == '@') + { + fprintf(fileDest, "PUBLIC ordinal%d\nordinal%d: nop\n", + pexp->nOrdinal, pexp->nOrdinal); + } + else + { + fprintf(fileDest, "PUBLIC _stub_%.*s\n_stub_%.*s: nop\n", + pexp->strName.len, pexp->strName.buf, + pexp->strName.len, pexp->strName.buf); + } + break; + } + case ARCH_ARM: + { + /* Handle autoname */ + if (pexp->strName.len == 1 && pexp->strName.buf[0] == '@') + { + fprintf(fileDest, "ordinal%d nop\n EXPORT ordinal%d\n", + pexp->nOrdinal, pexp->nOrdinal); + } + else + { + fprintf(fileDest, "_stub_%.*s nop\n EXPORT _stub_%.*s\n", + pexp->strName.len, pexp->strName.buf, + pexp->strName.len, pexp->strName.buf); + } + break; + } } - else if (giArch != ARCH_X86) - { - fprintf(fileDest, "PUBLIC _stub_%.*s\n_stub_%.*s: nop\n", - pexp->strName.len, pexp->strName.buf, - pexp->strName.len, pexp->strName.buf); - } - else if (pexp->nCallingConvention == CC_STDCALL) - { - fprintf(fileDest, "PUBLIC __stub_%.*s@%d\n__stub_%.*s@%d: nop\n", - pexp->strName.len, pexp->strName.buf, pexp->nStackBytes, - pexp->strName.len, pexp->strName.buf, pexp->nStackBytes); - } - else if (pexp->nCallingConvention == CC_FASTCALL) - { - fprintf(fileDest, "PUBLIC @_stub_%.*s@%d\n@_stub_%.*s@%d: nop\n", - pexp->strName.len, pexp->strName.buf, pexp->nStackBytes, - pexp->strName.len, pexp->strName.buf, pexp->nStackBytes); - } - else if (pexp->nCallingConvention == CC_CDECL || - pexp->nCallingConvention == CC_STUB) - { - fprintf(fileDest, "PUBLIC __stub_%.*s\n__stub_%.*s: nop\n", - pexp->strName.len, pexp->strName.buf, - pexp->strName.len, pexp->strName.buf); - } - else if (pexp->nCallingConvention == CC_EXTERN) - { - fprintf(fileDest, "PUBLIC __stub_%.*s\n__stub_%.*s:\n", - pexp->strName.len, pexp->strName.buf, - pexp->strName.len, pexp->strName.buf); - } return 1; } @@ -899,11 +945,7 @@ } } - if (strcasecmp(pszArchString, "i386") == 0) - { - giArch = ARCH_X86; - gpszUnderscore = "_"; - } + if (strcasecmp(pszArchString, "i386") == 0) giArch = ARCH_X86; else if (strcasecmp(pszArchString, "x86_64") == 0) giArch = ARCH_AMD64; else if (strcasecmp(pszArchString, "ia64") == 0) giArch = ARCH_IA64; else if (strcasecmp(pszArchString, "arm") == 0) giArch = ARCH_ARM; @@ -1010,7 +1052,7 @@ OutputHeader_asmstub(file, pszDllName); result = ParseFile(pszSource, file, OutputLine_asmstub); - fprintf(file, "\nEND\n"); + fprintf(file, "\n END\n"); fclose(file); }