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,13 +1084,13 @@ static int BuildSpec32File( FILE *outfile ) ...@@ -1084,13 +1084,13 @@ 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"
...@@ -1105,6 +1105,31 @@ static int BuildSpec32File( FILE *outfile ) ...@@ -1105,6 +1105,31 @@ static int BuildSpec32File( FILE *outfile )
fprintf( outfile, "#endif /* !defined(__GNUC__) */\n" ); fprintf( outfile, "#endif /* !defined(__GNUC__) */\n" );
} }
if (nb_names)
{
/* Output the DLL names table */
fprintf( outfile, "static const char * const FuncNames[%d] =\n{\n", nb_names );
for (i = 0; i < nb_names; i++)
{
if (i) fprintf( outfile, ",\n" );
fprintf( outfile, " \"%s\"", Names[i]->name );
}
fprintf( outfile, "\n};\n\n" );
/* Output the DLL ordinals table */
fprintf( outfile, "static const unsigned short FuncOrdinals[%d] =\n{\n", nb_names );
for (i = 0; i < nb_names; i++)
{
if (i) fprintf( outfile, ",\n" );
fprintf( outfile, " %d", Names[i]->ordinal - Base );
}
fprintf( outfile, "\n};\n\n" );
}
if (nr_exports)
{
/* Output the DLL functions table */ /* Output the DLL functions table */
fprintf( outfile, "\nstatic const ENTRYPOINT32 Functions[%d] =\n{\n", fprintf( outfile, "\nstatic const ENTRYPOINT32 Functions[%d] =\n{\n",
...@@ -1139,26 +1164,6 @@ static int BuildSpec32File( FILE *outfile ) ...@@ -1139,26 +1164,6 @@ static int BuildSpec32File( FILE *outfile )
} }
fprintf( outfile, "\n};\n\n" ); fprintf( outfile, "\n};\n\n" );
/* Output the DLL names table */
fprintf( outfile, "static const char * const FuncNames[%d] =\n{\n", nb_names );
for (i = 0; i < nb_names; i++)
{
if (i) fprintf( outfile, ",\n" );
fprintf( outfile, " \"%s\"", Names[i]->name );
}
fprintf( outfile, "\n};\n\n" );
/* Output the DLL ordinals table */
fprintf( outfile, "static const unsigned short FuncOrdinals[%d] =\n{\n", nb_names );
for (i = 0; i < nb_names; i++)
{
if (i) fprintf( outfile, ",\n" );
fprintf( outfile, " %d", Names[i]->ordinal - Base );
}
fprintf( outfile, "\n};\n\n" );
/* Output the DLL argument types */ /* Output the DLL argument types */
fprintf( outfile, "static const unsigned int ArgTypes[%d] =\n{\n", fprintf( outfile, "static const unsigned int ArgTypes[%d] =\n{\n",
...@@ -1210,6 +1215,7 @@ static int BuildSpec32File( FILE *outfile ) ...@@ -1210,6 +1215,7 @@ static int BuildSpec32File( FILE *outfile )
if (i < Limit) fprintf( outfile, ",\n" ); if (i < Limit) fprintf( outfile, ",\n" );
} }
fprintf( outfile, "\n};\n\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