Commit 7555fd57 authored by Alexandre Julliard's avatar Alexandre Julliard

winebuild: Add a helper for generating RVA pointers.

parent ef9bda4c
......@@ -248,6 +248,8 @@ extern int output( const char *format, ... )
__attribute__ ((__format__ (__printf__, 1, 2)));
extern void output_cfi( const char *format, ... )
__attribute__ ((__format__ (__printf__, 1, 2)));
extern void output_rva( const char *format, ... )
__attribute__ ((__format__ (__printf__, 1, 2)));
extern void spawn( struct strarray array );
extern struct strarray find_tool( const char *name, const char * const *names );
extern struct strarray get_as_command(void);
......
......@@ -722,14 +722,11 @@ static void output_immediate_imports(void)
j = 0;
LIST_FOR_EACH_ENTRY( import, &dll_imports, struct import, entry )
{
output( "\t.long .L__wine_spec_import_data_names+%d-.L__wine_spec_rva_base\n", /* OriginalFirstThunk */
j * get_ptr_size() );
output_rva( ".L__wine_spec_import_data_names + %d", j * get_ptr_size() ); /* OriginalFirstThunk */
output( "\t.long 0\n" ); /* TimeDateStamp */
output( "\t.long 0\n" ); /* ForwarderChain */
output( "\t.long .L__wine_spec_import_name_%s-.L__wine_spec_rva_base\n", /* Name */
import->c_name );
output( "\t.long .L__wine_spec_import_data_ptrs+%d-.L__wine_spec_rva_base\n", /* FirstThunk */
j * get_ptr_size() );
output_rva( ".L__wine_spec_import_name_%s", import->c_name ); /* Name */
output_rva( ".L__wine_spec_import_data_ptrs + %d", j * get_ptr_size() ); /* FirstThunk */
j += import->nb_imports + 1;
}
output( "\t.long 0\n" ); /* OriginalFirstThunk */
......
......@@ -476,8 +476,10 @@ void output_resources( DLLSPEC *spec )
/* dump the resource data entries */
for (i = 0, res = spec->resources; i < spec->nb_resources; i++, res++)
output( "\t.long .L__wine_spec_res_%d-.L__wine_spec_rva_base,%u,0,0\n",
i, res->data_size );
{
output_rva( ".L__wine_spec_res_%d", i );
output( "\t.long %u,0,0\n", res->data_size );
}
/* dump the name strings */
......
......@@ -378,15 +378,15 @@ void output_exports( DLLSPEC *spec )
output( "\t.long 0\n" ); /* Characteristics */
output( "\t.long 0\n" ); /* TimeDateStamp */
output( "\t.long 0\n" ); /* MajorVersion/MinorVersion */
output( "\t.long .L__wine_spec_exp_names-.L__wine_spec_rva_base\n" ); /* Name */
output_rva( ".L__wine_spec_exp_names" ); /* Name */
output( "\t.long %u\n", spec->base ); /* Base */
output( "\t.long %u\n", nr_exports ); /* NumberOfFunctions */
output( "\t.long %u\n", spec->nb_names ); /* NumberOfNames */
output( "\t.long .L__wine_spec_exports_funcs-.L__wine_spec_rva_base\n" ); /* AddressOfFunctions */
output_rva( ".L__wine_spec_exports_funcs " ); /* AddressOfFunctions */
if (spec->nb_names)
{
output( "\t.long .L__wine_spec_exp_name_ptrs-.L__wine_spec_rva_base\n" ); /* AddressOfNames */
output( "\t.long .L__wine_spec_exp_ordinals-.L__wine_spec_rva_base\n" ); /* AddressOfNameOrdinals */
output_rva( ".L__wine_spec_exp_name_ptrs" ); /* AddressOfNames */
output_rva( ".L__wine_spec_exp_ordinals" ); /* AddressOfNameOrdinals */
}
else
{
......@@ -440,7 +440,7 @@ void output_exports( DLLSPEC *spec )
output( "\n.L__wine_spec_exp_name_ptrs:\n" );
for (i = 0; i < spec->nb_names; i++)
{
output( "\t.long .L__wine_spec_exp_names+%u-.L__wine_spec_rva_base\n", namepos );
output_rva( ".L__wine_spec_exp_names + %u", namepos );
namepos += strlen(spec->names[i]->name) + 1;
}
......@@ -636,8 +636,7 @@ void output_module( DLLSPEC *spec )
output( "\t.short %u,%u\n", /* Major/MinorSubsystemVersion */
spec->subsystem_major, spec->subsystem_minor );
output( "\t.long 0\n" ); /* Win32VersionValue */
output( "\t.long %s-.L__wine_spec_rva_base\n", /* SizeOfImage */
asm_name("_end") );
output_rva( "%s", asm_name("_end") ); /* SizeOfImage */
output( "\t.long %u\n", page_size ); /* SizeOfHeaders */
output( "\t.long 0\n" ); /* CheckSum */
output( "\t.short 0x%04x\n", /* Subsystem */
......@@ -652,20 +651,26 @@ void output_module( DLLSPEC *spec )
output( "\t.long 16\n" ); /* NumberOfRvaAndSizes */
if (spec->base <= spec->limit) /* DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT] */
output( "\t.long .L__wine_spec_exports-.L__wine_spec_rva_base,"
".L__wine_spec_exports_end-.L__wine_spec_exports\n" );
{
output_rva( ".L__wine_spec_exports" );
output( "\t.long .L__wine_spec_exports_end-.L__wine_spec_exports\n" );
}
else
output( "\t.long 0,0\n" );
if (has_imports()) /* DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT] */
output( "\t.long .L__wine_spec_imports-.L__wine_spec_rva_base,"
".L__wine_spec_imports_end-.L__wine_spec_imports\n" );
{
output_rva( ".L__wine_spec_imports" );
output( "\t.long .L__wine_spec_imports_end-.L__wine_spec_imports\n" );
}
else
output( "\t.long 0,0\n" );
if (spec->nb_resources) /* DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE] */
output( "\t.long .L__wine_spec_resources-.L__wine_spec_rva_base,"
".L__wine_spec_resources_end-.L__wine_spec_resources\n" );
{
output_rva( ".L__wine_spec_resources" );
output( "\t.L__wine_spec_resources_end-.L__wine_spec_resources\n" );
}
else
output( "\t.long 0,0\n" );
......
......@@ -1107,6 +1107,28 @@ void output_cfi( const char *format, ... )
va_end( valist );
}
/* output an RVA pointer */
void output_rva( const char *format, ... )
{
va_list valist;
va_start( valist, format );
switch (target_platform)
{
case PLATFORM_WINDOWS:
output( "\t.rva " );
vfprintf( output_file, format, valist );
fputc( '\n', output_file );
break;
default:
output( "\t.long " );
vfprintf( output_file, format, valist );
output( " - .L__wine_spec_rva_base\n" );
break;
}
va_end( valist );
}
/* output the GNU note for non-exec stack */
void output_gnu_stack_note(void)
{
......
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