Commit 89cf0ae1 authored by Patrik Stridvall's avatar Patrik Stridvall Committed by Alexandre Julliard

- Fixed some Solaris specific assembler problems

- Fixed some missing .type @function (helps debugging with dbx) - Fixed code needing __attribute__((constructor))__ for non-GCC ELF compilers - Fixed use of zero width arrays (ANSI C violation) - @GOTOFF on Solaris doesn't work - use @GOT and redirection instead
parent ea4f831d
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
#ifdef __i386__ #ifdef __i386__
extern WORD __get_cs(void); extern WORD __get_cs(void);
extern WORD __get_ds(void); extern WORD __get_ds(void);
__ASM_GLOBAL_FUNC( __get_cs, "movl %cs,%eax\n\tret" ); __ASM_GLOBAL_FUNC( __get_cs, "movw %cs,%ax\n\tret" );
__ASM_GLOBAL_FUNC( __get_ds, "movl %ds,%eax\n\tret" ); __ASM_GLOBAL_FUNC( __get_ds, "movw %ds,%ax\n\tret" );
#else #else
static inline WORD __get_cs(void) { return 0; } static inline WORD __get_cs(void) { return 0; }
static inline WORD __get_ds(void) { return 0; } static inline WORD __get_ds(void) { return 0; }
...@@ -1084,18 +1084,18 @@ static int BuildSpec32File( FILE *outfile ) ...@@ -1084,18 +1084,18 @@ static int BuildSpec32File( FILE *outfile )
if ( have_regs ) if ( have_regs )
{ {
fprintf( outfile, "#ifndef __GNUC__\n" ); fprintf( outfile, "#ifndef __GNUC__\n" );
fprintf( outfile, "static void __asm__dummy() {\n" ); fprintf( outfile, "static void __asm__dummy(void) {\n" );
fprintf( outfile, "#endif /* !defined(__GNUC__) */\n" ); fprintf( outfile, "#endif /* !defined(__GNUC__) */\n" );
for (i = 0, odp = EntryPoints; i < nb_entry_points; i++, odp++) for (i = 0, odp = EntryPoints; i < nb_entry_points; i++, odp++)
{ {
if (odp->type != TYPE_REGISTER) continue; if (odp->type != TYPE_REGISTER) continue;
fprintf( outfile, fprintf( outfile,
"__asm__(\".align 4\\n\\t\"\n" "asm(\".align 4\\n\\t\"\n"
" \".type " PREFIX "__regs_%d,@function\\n\\t\"\n" " \".type " PREFIX "__regs_%d,@function\\n\\t\"\n"
" \"" PREFIX "__regs_%d:\\n\\t\"\n" " \"" PREFIX "__regs_%d:\\n\\t\"\n"
" \"call " PREFIX "CALL32_Regs\\n\\t\"\n" " \"call " PREFIX "CALL32_Regs\\n\\t\"\n"
" \".long " PREFIX "%s\\n\\t\"\n" " \".long " PREFIX "%s\\n\\t\"\n"
" \".byte %d,%d\");\n", " \".byte %d,%d\");\n",
odp->ordinal, odp->ordinal, odp->u.func.link_name, odp->ordinal, odp->ordinal, odp->u.func.link_name,
4 * strlen(odp->u.func.arg_types), 4 * strlen(odp->u.func.arg_types),
4 * strlen(odp->u.func.arg_types) ); 4 * strlen(odp->u.func.arg_types) );
...@@ -1105,111 +1105,117 @@ static int BuildSpec32File( FILE *outfile ) ...@@ -1105,111 +1105,117 @@ static int BuildSpec32File( FILE *outfile )
fprintf( outfile, "#endif /* !defined(__GNUC__) */\n" ); fprintf( outfile, "#endif /* !defined(__GNUC__) */\n" );
} }
/* Output the DLL functions table */ if (nb_names)
fprintf( outfile, "\nstatic const ENTRYPOINT32 Functions[%d] =\n{\n",
nr_exports );
for (i = Base; i <= Limit; i++)
{ {
ORDDEF *odp = Ordinals[i]; /* Output the DLL names table */
if (!odp) fprintf( outfile, " 0" );
else switch(odp->type) fprintf( outfile, "static const char * const FuncNames[%d] =\n{\n", nb_names );
for (i = 0; i < nb_names; i++)
{ {
case TYPE_EXTERN: if (i) fprintf( outfile, ",\n" );
fprintf( outfile, " %s", odp->u.ext.link_name ); fprintf( outfile, " \"%s\"", Names[i]->name );
break;
case TYPE_STDCALL:
case TYPE_VARARGS:
case TYPE_CDECL:
fprintf( outfile, " %s", odp->u.func.link_name);
break;
case TYPE_STUB:
fprintf( outfile, " __stub_%d", i );
break;
case TYPE_REGISTER:
fprintf( outfile, " __regs_%d", i );
break;
case TYPE_FORWARD:
fprintf( outfile, " (ENTRYPOINT32)\"%s\"", odp->u.fwd.link_name );
break;
default:
return -1;
} }
if (i < Limit) fprintf( outfile, ",\n" ); fprintf( outfile, "\n};\n\n" );
}
fprintf( outfile, "\n};\n\n" );
/* Output the DLL names table */ /* Output the DLL ordinals table */
fprintf( outfile, "static const char * const FuncNames[%d] =\n{\n", nb_names ); fprintf( outfile, "static const unsigned short FuncOrdinals[%d] =\n{\n", nb_names );
for (i = 0; i < nb_names; i++) for (i = 0; i < nb_names; i++)
{ {
if (i) fprintf( outfile, ",\n" ); if (i) fprintf( outfile, ",\n" );
fprintf( outfile, " \"%s\"", Names[i]->name ); fprintf( outfile, " %d", Names[i]->ordinal - Base );
}
fprintf( outfile, "\n};\n\n" );
} }
fprintf( outfile, "\n};\n\n" );
/* Output the DLL ordinals table */ if (nr_exports)
fprintf( outfile, "static const unsigned short FuncOrdinals[%d] =\n{\n", nb_names );
for (i = 0; i < nb_names; i++)
{ {
if (i) fprintf( outfile, ",\n" ); /* Output the DLL functions table */
fprintf( outfile, " %d", Names[i]->ordinal - Base );
}
fprintf( outfile, "\n};\n\n" );
/* Output the DLL argument types */ fprintf( outfile, "\nstatic const ENTRYPOINT32 Functions[%d] =\n{\n",
nr_exports );
fprintf( outfile, "static const unsigned int ArgTypes[%d] =\n{\n", for (i = Base; i <= Limit; i++)
nr_exports ); {
for (i = Base; i <= Limit; i++) ORDDEF *odp = Ordinals[i];
{ if (!odp) fprintf( outfile, " 0" );
ORDDEF *odp = Ordinals[i]; else switch(odp->type)
unsigned int j, mask = 0;
if (odp &&
((odp->type == TYPE_STDCALL) || (odp->type == TYPE_CDECL) ||
(odp->type == TYPE_REGISTER)))
for (j = 0; odp->u.func.arg_types[j]; j++)
{ {
if (odp->u.func.arg_types[j] == 't') mask |= 1<< (j*2); case TYPE_EXTERN:
if (odp->u.func.arg_types[j] == 'W') mask |= 2<< (j*2); fprintf( outfile, " %s", odp->u.ext.link_name );
} break;
fprintf( outfile, " %d", mask ); case TYPE_STDCALL:
if (i < Limit) fprintf( outfile, ",\n" ); case TYPE_VARARGS:
} case TYPE_CDECL:
fprintf( outfile, "\n};\n\n" ); fprintf( outfile, " %s", odp->u.func.link_name);
break;
case TYPE_STUB:
fprintf( outfile, " __stub_%d", i );
break;
case TYPE_REGISTER:
fprintf( outfile, " __regs_%d", i );
break;
case TYPE_FORWARD:
fprintf( outfile, " (ENTRYPOINT32)\"%s\"", odp->u.fwd.link_name );
break;
default:
return -1;
}
if (i < Limit) fprintf( outfile, ",\n" );
}
fprintf( outfile, "\n};\n\n" );
/* Output the DLL functions arguments */ /* Output the DLL argument types */
fprintf( outfile, "static const unsigned char FuncArgs[%d] =\n{\n", fprintf( outfile, "static const unsigned int ArgTypes[%d] =\n{\n",
nr_exports ); nr_exports );
for (i = Base; i <= Limit; i++) for (i = Base; i <= Limit; i++)
{
unsigned char args = 0xff;
ORDDEF *odp = Ordinals[i];
if (odp) switch(odp->type)
{ {
case TYPE_STDCALL: ORDDEF *odp = Ordinals[i];
args = (unsigned char)strlen(odp->u.func.arg_types); unsigned int j, mask = 0;
break; if (odp &&
case TYPE_CDECL: ((odp->type == TYPE_STDCALL) || (odp->type == TYPE_CDECL) ||
args = 0x80 | (unsigned char)strlen(odp->u.func.arg_types); (odp->type == TYPE_REGISTER)))
break; for (j = 0; odp->u.func.arg_types[j]; j++)
case TYPE_REGISTER: {
args = 0x40 | (unsigned char)strlen(odp->u.func.arg_types); if (odp->u.func.arg_types[j] == 't') mask |= 1<< (j*2);
break; if (odp->u.func.arg_types[j] == 'W') mask |= 2<< (j*2);
case TYPE_FORWARD: }
args = 0xfd; fprintf( outfile, " %d", mask );
break; if (i < Limit) fprintf( outfile, ",\n" );
default: }
args = 0xff; fprintf( outfile, "\n};\n\n" );
break;
/* Output the DLL functions arguments */
fprintf( outfile, "static const unsigned char FuncArgs[%d] =\n{\n",
nr_exports );
for (i = Base; i <= Limit; i++)
{
unsigned char args = 0xff;
ORDDEF *odp = Ordinals[i];
if (odp) switch(odp->type)
{
case TYPE_STDCALL:
args = (unsigned char)strlen(odp->u.func.arg_types);
break;
case TYPE_CDECL:
args = 0x80 | (unsigned char)strlen(odp->u.func.arg_types);
break;
case TYPE_REGISTER:
args = 0x40 | (unsigned char)strlen(odp->u.func.arg_types);
break;
case TYPE_FORWARD:
args = 0xfd;
break;
default:
args = 0xff;
break;
}
fprintf( outfile, " 0x%02x", args );
if (i < Limit) fprintf( outfile, ",\n" );
} }
fprintf( outfile, " 0x%02x", args ); fprintf( outfile, "\n};\n\n" );
if (i < Limit) fprintf( outfile, ",\n" );
} }
fprintf( outfile, "\n};\n\n" );
/* Output the DLL imports */ /* Output the DLL imports */
...@@ -1237,12 +1243,11 @@ static int BuildSpec32File( FILE *outfile ) ...@@ -1237,12 +1243,11 @@ static int BuildSpec32File( FILE *outfile )
fprintf( outfile, " %d,\n", nb_names ); fprintf( outfile, " %d,\n", nb_names );
fprintf( outfile, " %d,\n", nb_imports ); fprintf( outfile, " %d,\n", nb_imports );
fprintf( outfile, " %d,\n", (fwd_size + 3) & ~3 ); fprintf( outfile, " %d,\n", (fwd_size + 3) & ~3 );
fprintf( outfile, fprintf( outfile, " %s,\n", nr_exports ? "Functions" : "0" );
" Functions,\n" fprintf( outfile, " %s,\n", nb_names ? "FuncNames" : "0" );
" FuncNames,\n" fprintf( outfile, " %s,\n", nb_names ? "FuncOrdinals" : "0" );
" FuncOrdinals,\n" fprintf( outfile, " %s,\n", nr_exports ? "FuncArgs" : "0" );
" FuncArgs,\n" fprintf( outfile, " %s,\n", nr_exports ? "ArgTypes" : "0" );
" ArgTypes,\n");
fprintf( outfile, " %s,\n", nb_imports ? "Imports" : "0" ); fprintf( outfile, " %s,\n", nb_imports ? "Imports" : "0" );
fprintf( outfile, " %s,\n", DLLInitFunc[0] ? DLLInitFunc : "0" ); fprintf( outfile, " %s,\n", DLLInitFunc[0] ? DLLInitFunc : "0" );
fprintf( outfile, " %d,\n", SpecMode == SPEC_MODE_DLL ? IMAGE_FILE_DLL : 0 ); fprintf( outfile, " %d,\n", SpecMode == SPEC_MODE_DLL ? IMAGE_FILE_DLL : 0 );
...@@ -1251,9 +1256,18 @@ static int BuildSpec32File( FILE *outfile ) ...@@ -1251,9 +1256,18 @@ static int BuildSpec32File( FILE *outfile )
/* Output the DLL constructor */ /* Output the DLL constructor */
fprintf( outfile, "static void dll_init(void) __attribute__((constructor));\n" ); fprintf( outfile, "#ifdef __GNUC__\n" );
fprintf( outfile, "static void dll_init(void) { BUILTIN32_RegisterDLL( &%s_Descriptor ); }\n", fprintf( outfile, "static void %s_init(void) __attribute__((constructor));\n", DLLName );
DLLName ); fprintf( outfile, "#else /* defined(__GNUC__) */\n" );
fprintf( outfile, "static void __asm__dummy_dll_init(void) {\n" );
fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" );
fprintf( outfile, " \"\\tcall %s_init\\n\"\n", DLLName );
fprintf( outfile, " \"\\t.previous\\n\");\n" );
fprintf( outfile, "}\n" );
fprintf( outfile, "#endif /* defined(__GNUC__) */\n" );
fprintf( outfile, "static void %s_init(void) { BUILTIN32_RegisterDLL( &%s_Descriptor ); }\n",
DLLName, DLLName );
return 0; return 0;
} }
...@@ -1505,9 +1519,18 @@ static int BuildSpec16File( FILE *outfile ) ...@@ -1505,9 +1519,18 @@ static int BuildSpec16File( FILE *outfile )
/* Output the DLL constructor */ /* Output the DLL constructor */
fprintf( outfile, "static void dll_init(void) __attribute__((constructor));\n" ); fprintf( outfile, "#ifdef __GNUC__\n" );
fprintf( outfile, "static void dll_init(void) { BUILTIN_RegisterDLL( &%s_Descriptor ); }\n", fprintf( outfile, "static void %s_init(void) __attribute__((constructor));\n", DLLName );
DLLName ); fprintf( outfile, "#else /* defined(__GNUC__) */\n" );
fprintf( outfile, "static void __asm__dummy_dll_init(void) {\n" );
fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" );
fprintf( outfile, " \"\\tcall %s_init\\n\"\n", DLLName );
fprintf( outfile, " \"\\t.previous\\n\");\n" );
fprintf( outfile, "}\n" );
fprintf( outfile, "#endif /* defined(__GNUC__) */\n" );
fprintf( outfile, "static void %s_init(void) { BUILTIN_RegisterDLL( &%s_Descriptor ); }\n",
DLLName, DLLName );
return 0; return 0;
} }
...@@ -2178,6 +2201,7 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func ) ...@@ -2178,6 +2201,7 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
fprintf( outfile, ".stabs \"CallTo16%s:F1\",36,0,0," PREFIX "CallTo16%s\n", fprintf( outfile, ".stabs \"CallTo16%s:F1\",36,0,0," PREFIX "CallTo16%s\n",
name, name); name, name);
#endif #endif
fprintf( outfile, "\t.type " PREFIX "CallTo16%s,@function\n", name );
fprintf( outfile, "\t.globl " PREFIX "CallTo16%s\n", name ); fprintf( outfile, "\t.globl " PREFIX "CallTo16%s\n", name );
fprintf( outfile, PREFIX "CallTo16%s:\n", name ); fprintf( outfile, PREFIX "CallTo16%s:\n", name );
...@@ -2225,7 +2249,10 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func ) ...@@ -2225,7 +2249,10 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
/* Get return address */ /* Get return address */
if ( UsePIC ) if ( UsePIC )
fprintf( outfile, "\tmovl " PREFIX "CallTo16_RetAddr@GOTOFF(%%ebx), %%ecx\n" ); {
fprintf( outfile, "\tmovl " PREFIX "CallTo16_RetAddr@GOT(%%ebx), %%ecx\n" );
fprintf( outfile, "\tmovl " PREFIX "(%%ecx), %%ecx\n" );
}
else else
fprintf( outfile, "\tmovl " PREFIX "CallTo16_RetAddr, %%ecx\n" ); fprintf( outfile, "\tmovl " PREFIX "CallTo16_RetAddr, %%ecx\n" );
...@@ -2381,7 +2408,8 @@ static void BuildRet16Func( FILE *outfile ) ...@@ -2381,7 +2408,8 @@ static void BuildRet16Func( FILE *outfile )
* run-time relocation of the SYSLEVEL_Win16CurrentTeb symbol * run-time relocation of the SYSLEVEL_Win16CurrentTeb symbol
*/ */
fprintf( outfile, "\n\t.globl " PREFIX "CallTo16_Ret\n" ); fprintf( outfile, "\n\t.type " PREFIX "CallTo16_Ret,@function\n" );
fprintf( outfile, "\t.globl " PREFIX "CallTo16_Ret\n" );
fprintf( outfile, PREFIX "CallTo16_Ret:\n" ); fprintf( outfile, PREFIX "CallTo16_Ret:\n" );
/* Restore 32-bit segment registers */ /* Restore 32-bit segment registers */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment