Alexandre Julliard : winebuild: Add a helper for generating RVA pointers.
Alexandre Julliard
julliard at winehq.org
Wed Mar 6 15:29:40 CST 2019
Module: wine
Branch: master
Commit: 7555fd57e3956d7cfc0fa5a43b87bd7d20101087
URL: https://source.winehq.org/git/wine.git/?a=commit;h=7555fd57e3956d7cfc0fa5a43b87bd7d20101087
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Mar 6 10:13:45 2019 +0100
winebuild: Add a helper for generating RVA pointers.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
tools/winebuild/build.h | 2 ++
tools/winebuild/import.c | 9 +++------
tools/winebuild/res32.c | 6 ++++--
tools/winebuild/spec32.c | 31 ++++++++++++++++++-------------
tools/winebuild/utils.c | 22 ++++++++++++++++++++++
5 files changed, 49 insertions(+), 21 deletions(-)
diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h
index e76a87a..44fa317 100644
--- a/tools/winebuild/build.h
+++ b/tools/winebuild/build.h
@@ -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);
diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c
index 5c4de1c..984bffd 100644
--- a/tools/winebuild/import.c
+++ b/tools/winebuild/import.c
@@ -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 */
diff --git a/tools/winebuild/res32.c b/tools/winebuild/res32.c
index b20dfb4..16e5c65 100644
--- a/tools/winebuild/res32.c
+++ b/tools/winebuild/res32.c
@@ -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 */
diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c
index 69b6d2f..ee38702 100644
--- a/tools/winebuild/spec32.c
+++ b/tools/winebuild/spec32.c
@@ -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" );
diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c
index 63be3af..87761c2 100644
--- a/tools/winebuild/utils.c
+++ b/tools/winebuild/utils.c
@@ -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)
{
More information about the wine-cvs
mailing list