mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-19 17:06:04 -07:00
winebuild: Always use .balign for alignment.
It seems to be portable enough nowadays.
This commit is contained in:
parent
7773139261
commit
9a4e41c45d
7 changed files with 32 additions and 80 deletions
|
@ -284,7 +284,6 @@ extern const char *get_stub_name( const ORDDEF *odp, const DLLSPEC *spec );
|
|||
extern const char *get_abi_name( const ORDDEF *odp, const char *name );
|
||||
extern const char *get_link_name( const ORDDEF *odp );
|
||||
extern int sort_func_list( ORDDEF **list, int count, int (*compare)(const void *, const void *) );
|
||||
extern unsigned int get_alignment(unsigned int align);
|
||||
extern unsigned int get_page_size(void);
|
||||
extern unsigned int get_args_size( const ORDDEF *odp );
|
||||
extern const char *asm_name( const char *func );
|
||||
|
|
|
@ -830,7 +830,7 @@ static void output_immediate_imports(void)
|
|||
|
||||
output( "\n/* import table */\n" );
|
||||
output( "\n\t.data\n" );
|
||||
output( "\t.align %d\n", get_alignment(4) );
|
||||
output( "\t.balign 4\n" );
|
||||
output( ".L__wine_spec_imports:\n" );
|
||||
|
||||
/* list of dlls */
|
||||
|
@ -851,7 +851,7 @@ static void output_immediate_imports(void)
|
|||
output( "\t.long 0\n" ); /* Name */
|
||||
output( "\t.long 0\n" ); /* FirstThunk */
|
||||
|
||||
output( "\n\t.align %d\n", get_alignment(get_ptr_size()) );
|
||||
output( "\n\t.balign %u\n", get_ptr_size() );
|
||||
/* output the names twice, once for OriginalFirstThunk and once for FirstThunk */
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
|
@ -880,7 +880,7 @@ static void output_immediate_imports(void)
|
|||
{
|
||||
struct import_func *func = &import->imports[j];
|
||||
if (!func->name) continue;
|
||||
output( "\t.align %d\n", get_alignment(2) );
|
||||
output( "\t.balign 2\n" );
|
||||
output( ".L__wine_spec_import_data_%s_%s:\n", import->c_name, func->name );
|
||||
output( "\t.short %d\n", func->hint );
|
||||
output( "\t%s \"%s\"\n", get_asm_string_keyword(), func->name );
|
||||
|
@ -905,7 +905,7 @@ static void output_immediate_import_thunks(void)
|
|||
|
||||
output( "\n/* immediate import thunks */\n\n" );
|
||||
output( "\t.text\n" );
|
||||
output( "\t.align %d\n", get_alignment(8) );
|
||||
output( "\t.balign 8\n" );
|
||||
output( "%s:\n", asm_name(import_thunks));
|
||||
|
||||
pos = 0;
|
||||
|
@ -932,7 +932,7 @@ static void output_delayed_imports( const DLLSPEC *spec )
|
|||
|
||||
output( "\n/* delayed imports */\n\n" );
|
||||
output( "\t.data\n" );
|
||||
output( "\t.align %d\n", get_alignment(get_ptr_size()) );
|
||||
output( "\t.balign %u\n", get_ptr_size() );
|
||||
output( ".L__wine_spec_delay_imports:\n" );
|
||||
|
||||
/* list of dlls */
|
||||
|
@ -998,7 +998,7 @@ static void output_delayed_imports( const DLLSPEC *spec )
|
|||
{
|
||||
struct import_func *func = &import->imports[j];
|
||||
if (!func->name) continue;
|
||||
output( "\t.align %d\n", get_alignment(2) );
|
||||
output( "\t.balign 2\n" );
|
||||
output( ".L__wine_delay_data_%s_%s:\n", import->c_name, func->name );
|
||||
output( "\t.short %d\n", func->hint );
|
||||
output( "\t%s \"%s\"\n", get_asm_string_keyword(), func->name );
|
||||
|
@ -1018,7 +1018,7 @@ static void output_delayed_import_thunks( const DLLSPEC *spec )
|
|||
|
||||
output( "\n/* delayed import thunks */\n\n" );
|
||||
output( "\t.text\n" );
|
||||
output( "\t.align %d\n", get_alignment(8) );
|
||||
output( "\t.balign 8\n" );
|
||||
output( "%s:\n", asm_name(delayed_import_loaders));
|
||||
|
||||
pos = iat_pos = 0;
|
||||
|
@ -1177,7 +1177,7 @@ static void output_delayed_import_thunks( const DLLSPEC *spec )
|
|||
}
|
||||
output_function_size( delayed_import_loaders );
|
||||
|
||||
output( "\n\t.align %d\n", get_alignment(get_ptr_size()) );
|
||||
output( "\n\t.balign %u\n", get_ptr_size() );
|
||||
output( "%s:\n", asm_name(delayed_import_thunks));
|
||||
pos = 0;
|
||||
LIST_FOR_EACH_ENTRY( import, &dll_delayed, struct import, entry )
|
||||
|
@ -1210,13 +1210,13 @@ static void output_external_link_imports( DLLSPEC *spec )
|
|||
|
||||
output( "\n/* external link thunks */\n\n" );
|
||||
output( "\t.data\n" );
|
||||
output( "\t.align %d\n", get_alignment(get_ptr_size()) );
|
||||
output( "\t.balign %u\n", get_ptr_size() );
|
||||
output( ".L__wine_spec_external_links:\n" );
|
||||
for (i = 0; i < ext_link_imports.count; i++)
|
||||
output( "\t%s %s\n", get_asm_ptr_keyword(), asm_name(ext_link_imports.str[i]) );
|
||||
|
||||
output( "\n\t.text\n" );
|
||||
output( "\t.align %d\n", get_alignment(get_ptr_size()) );
|
||||
output( "\t.balign %u\n", get_ptr_size() );
|
||||
output( "%s:\n", asm_name("__wine_spec_external_link_thunks") );
|
||||
|
||||
for (i = pos = 0; i < ext_link_imports.count; i++)
|
||||
|
@ -1513,7 +1513,7 @@ void output_syscalls( DLLSPEC *spec )
|
|||
break;
|
||||
}
|
||||
output( "\t.data\n" );
|
||||
output( "\t.align %d\n", get_alignment( get_ptr_size() ) );
|
||||
output( "\t.balign %u\n", get_ptr_size() );
|
||||
output( "%s\n", asm_globl("__wine_syscall_dispatcher") );
|
||||
output( "\t%s 0\n", get_asm_ptr_keyword() ); /* dispatcher */
|
||||
output( "\t.long 0xca110001\n" ); /* version */
|
||||
|
|
|
@ -590,7 +590,7 @@ void output_asm_relays16(void)
|
|||
output_function_size( "__wine_spec_thunk_text_16" );
|
||||
|
||||
/* Declare the return address and data selector variables */
|
||||
output( "\n\t.data\n\t.align %d\n", get_alignment(4) );
|
||||
output( "\n\t.data\n\t.balign 4\n" );
|
||||
output( "%s\n\t.long 0\n", asm_globl("CallTo16_DataSelector") );
|
||||
output( "%s\n\t.long 0\n", asm_globl("CallTo16_TebSelector") );
|
||||
}
|
||||
|
|
|
@ -419,7 +419,7 @@ void output_resources( DLLSPEC *spec )
|
|||
|
||||
output( "\n/* resources */\n\n" );
|
||||
output( "\t%s\n", get_asm_rsrc_section() );
|
||||
output( "\t.align %d\n", get_alignment(get_ptr_size()) );
|
||||
output( "\t.balign %u\n", get_ptr_size() );
|
||||
output( ".L__wine_spec_resources:\n" );
|
||||
|
||||
for (i = nb_id_types = 0, type = tree->types; i < tree->nb_types; i++, type++)
|
||||
|
@ -471,7 +471,7 @@ void output_resources( DLLSPEC *spec )
|
|||
|
||||
for (i = 0, res = spec->resources; i < spec->nb_resources; i++, res++)
|
||||
{
|
||||
output( "\n\t.align %d\n", get_alignment(4) );
|
||||
output( "\n\t.balign 4\n" );
|
||||
output( ".L__wine_spec_res_%d:\n", i );
|
||||
output( "\t.incbin \"%s\",%d,%d\n", res->input_name, res->input_offset, res->data_size );
|
||||
}
|
||||
|
|
|
@ -543,7 +543,7 @@ static void output_module16( DLLSPEC *spec )
|
|||
|
||||
output( "\n/* module data */\n\n" );
|
||||
output( "\t.data\n" );
|
||||
output( "\t.align %d\n", get_alignment(16) );
|
||||
output( "\t.balign 16\n" );
|
||||
output( ".L__wine_spec_dos_header:\n" );
|
||||
output( "\t.short 0x5a4d\n" ); /* e_magic */
|
||||
output( "\t.short 0\n" ); /* e_cblp */
|
||||
|
@ -567,7 +567,7 @@ static void output_module16( DLLSPEC *spec )
|
|||
output( "\t.long .L__wine_spec_ne_header-.L__wine_spec_dos_header\n" );/* e_lfanew */
|
||||
|
||||
output( "\t%s \"%s\"\n", get_asm_string_keyword(), fakedll_signature );
|
||||
output( "\t.align %d\n", get_alignment(16) );
|
||||
output( "\t.balign 16\n" );
|
||||
output( ".L__wine_spec_ne_header:\n" );
|
||||
output( "\t.short 0x454e\n" ); /* ne_magic */
|
||||
output( "\t.byte 0\n" ); /* ne_ver */
|
||||
|
@ -626,7 +626,7 @@ static void output_module16( DLLSPEC *spec )
|
|||
|
||||
/* resident names table */
|
||||
|
||||
output( "\n\t.align %d\n", get_alignment(2) );
|
||||
output( "\n\t.balign 2\n" );
|
||||
output( ".L__wine_spec_ne_restab:\n" );
|
||||
output_resident_name( spec->dll_name, 0 );
|
||||
for (i = 1; i <= spec->limit; i++)
|
||||
|
@ -640,7 +640,7 @@ static void output_module16( DLLSPEC *spec )
|
|||
|
||||
/* imported names table */
|
||||
|
||||
output( "\n\t.align %d\n", get_alignment(2) );
|
||||
output( "\n\t.balign 2\n" );
|
||||
output( ".L__wine_spec_ne_modtab:\n" );
|
||||
output( ".L__wine_spec_ne_imptab:\n" );
|
||||
output( "\t.byte 0,0\n" );
|
||||
|
@ -653,7 +653,7 @@ static void output_module16( DLLSPEC *spec )
|
|||
|
||||
/* code segment */
|
||||
|
||||
output( "\n\t.align %d\n", get_alignment(2) );
|
||||
output( "\n\t.balign 2\n" );
|
||||
output( ".L__wine_spec_code_segment:\n" );
|
||||
|
||||
for ( i = 0; i < nb_funcs; i++ )
|
||||
|
|
|
@ -222,7 +222,7 @@ static void output_relay_debug( DLLSPEC *spec )
|
|||
/* first the table of entry point offsets */
|
||||
|
||||
output( "\t%s\n", get_asm_rodata_section() );
|
||||
output( "\t.align %d\n", get_alignment(4) );
|
||||
output( "\t.balign 4\n" );
|
||||
output( ".L__wine_spec_relay_entry_point_offsets:\n" );
|
||||
|
||||
for (i = spec->base; i <= spec->limit; i++)
|
||||
|
@ -256,7 +256,7 @@ static void output_relay_debug( DLLSPEC *spec )
|
|||
switch (target.cpu)
|
||||
{
|
||||
case CPU_i386:
|
||||
output( "\t.align %d\n", get_alignment(4) );
|
||||
output( "\t.balign 4\n" );
|
||||
output( "\t.long 0x90909090,0x90909090\n" );
|
||||
output( "__wine_spec_relay_entry_point_%d:\n", i );
|
||||
output_cfi( ".cfi_startproc" );
|
||||
|
@ -298,7 +298,7 @@ static void output_relay_debug( DLLSPEC *spec )
|
|||
for (j = 0; j < odp->u.func.nb_args && !has_float; j++)
|
||||
has_float = is_float_arg( odp, j );
|
||||
|
||||
output( "\t.align %d\n", get_alignment(4) );
|
||||
output( "\t.balign 4\n" );
|
||||
output( "__wine_spec_relay_entry_point_%d:\n", i );
|
||||
output( "\tpush {r0-r3}\n" );
|
||||
output( "\tmov r2, SP\n");
|
||||
|
@ -330,7 +330,7 @@ static void output_relay_debug( DLLSPEC *spec )
|
|||
{
|
||||
int stack_size = 16 * ((min(odp->u.func.nb_args, 8) + 1) / 2);
|
||||
|
||||
output( "\t.align %d\n", get_alignment(4) );
|
||||
output( "\t.balign 4\n" );
|
||||
output( "__wine_spec_relay_entry_point_%d:\n", i );
|
||||
output_seh( ".seh_proc __wine_spec_relay_entry_point_%d", i );
|
||||
output( "\tstp x29, x30, [sp, #-%u]!\n", stack_size + 16 );
|
||||
|
@ -366,7 +366,7 @@ static void output_relay_debug( DLLSPEC *spec )
|
|||
}
|
||||
|
||||
case CPU_x86_64:
|
||||
output( "\t.align %d\n", get_alignment(4) );
|
||||
output( "\t.balign 4\n" );
|
||||
output( "\t.long 0x90909090,0x90909090\n" );
|
||||
output( "__wine_spec_relay_entry_point_%d:\n", i );
|
||||
output_seh( ".seh_proc __wine_spec_relay_entry_point_%d", i );
|
||||
|
@ -414,7 +414,7 @@ void output_exports( DLLSPEC *spec )
|
|||
|
||||
output( "\n/* export table */\n\n" );
|
||||
output( "\t%s\n", get_asm_export_section() );
|
||||
output( "\t.align %d\n", get_alignment(4) );
|
||||
output( "\t.balign 4\n" );
|
||||
output( ".L__wine_spec_exports:\n" );
|
||||
|
||||
/* export directory header */
|
||||
|
@ -541,11 +541,11 @@ void output_exports( DLLSPEC *spec )
|
|||
if (is_pe())
|
||||
{
|
||||
output( "\t.data\n" );
|
||||
output( "\t.align %d\n", get_alignment(get_ptr_size()) );
|
||||
output( "\t.balign %u\n", get_ptr_size() );
|
||||
}
|
||||
else
|
||||
{
|
||||
output( "\t.align %d\n", get_alignment(get_ptr_size()) );
|
||||
output( "\t.balign %u\n", get_ptr_size() );
|
||||
output( ".L__wine_spec_exports_end:\n" );
|
||||
}
|
||||
|
||||
|
@ -561,7 +561,7 @@ void output_exports( DLLSPEC *spec )
|
|||
}
|
||||
else if (!is_pe())
|
||||
{
|
||||
output( "\t.align %d\n", get_alignment(get_ptr_size()) );
|
||||
output( "\t.balign %u\n", get_ptr_size() );
|
||||
output( ".L__wine_spec_exports_end:\n" );
|
||||
output( "\t%s 0\n", get_asm_ptr_keyword() );
|
||||
}
|
||||
|
@ -578,7 +578,7 @@ void output_exports( DLLSPEC *spec )
|
|||
|
||||
name = odp->name ? odp->name : odp->export_name;
|
||||
|
||||
output( "\t.align %d\n", get_alignment(4) );
|
||||
output( "\t.balign 4\n" );
|
||||
output( "\t.long 0x90909090,0x90909090\n" );
|
||||
if (name) output( "%s_%s:\n", asm_name("__wine_spec_imp"), name );
|
||||
else output( "%s_%u:\n", asm_name("__wine_spec_imp"), i );
|
||||
|
@ -627,7 +627,7 @@ void output_module( DLLSPEC *spec )
|
|||
return; /* nothing to do */
|
||||
case PLATFORM_APPLE:
|
||||
output( "\t.text\n" );
|
||||
output( "\t.align %d\n", get_alignment(page_size) );
|
||||
output( "\t.balign %u\n", page_size );
|
||||
output( "__wine_spec_pe_header:\n" );
|
||||
output( "\t.space 65536\n" );
|
||||
break;
|
||||
|
@ -662,7 +662,7 @@ void output_module( DLLSPEC *spec )
|
|||
/* Output the NT header */
|
||||
|
||||
output( "\n\t.data\n" );
|
||||
output( "\t.align %d\n", get_alignment(get_ptr_size()) );
|
||||
output( "\t.balign %u\n", get_ptr_size() );
|
||||
output( "\t.globl %s\n", asm_name("__wine_spec_nt_header") );
|
||||
output( "%s:\n", asm_name("__wine_spec_nt_header") );
|
||||
output( ".L__wine_spec_rva_base:\n" );
|
||||
|
|
|
@ -770,53 +770,6 @@ int sort_func_list( ORDDEF **list, int count, int (*compare)(const void *, const
|
|||
}
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
* Function: get_alignment
|
||||
*
|
||||
* Description:
|
||||
* According to the info page for gas, the .align directive behaves
|
||||
* differently on different systems. On some architectures, the
|
||||
* argument of a .align directive is the number of bytes to pad to, so
|
||||
* to align on an 8-byte boundary you'd say
|
||||
* .align 8
|
||||
* On other systems, the argument is "the number of low-order zero bits
|
||||
* that the location counter must have after advancement." So to
|
||||
* align on an 8-byte boundary you'd say
|
||||
* .align 3
|
||||
*
|
||||
* The reason gas is written this way is that it's trying to mimic
|
||||
* native assemblers for the various architectures it runs on. gas
|
||||
* provides other directives that work consistently across
|
||||
* architectures, but of course we want to work on all arches with or
|
||||
* without gas. Hence this function.
|
||||
*
|
||||
*
|
||||
* Parameters:
|
||||
* align -- the number of bytes to align to. Must be a power of 2.
|
||||
*/
|
||||
unsigned int get_alignment(unsigned int align)
|
||||
{
|
||||
unsigned int n;
|
||||
|
||||
assert( !(align & (align - 1)) );
|
||||
|
||||
switch (target.cpu)
|
||||
{
|
||||
case CPU_i386:
|
||||
case CPU_x86_64:
|
||||
if (target.platform != PLATFORM_APPLE) return align;
|
||||
/* fall through */
|
||||
case CPU_ARM:
|
||||
case CPU_ARM64:
|
||||
n = 0;
|
||||
while ((1u << n) != align) n++;
|
||||
return n;
|
||||
}
|
||||
/* unreached */
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* return the page size for the target CPU */
|
||||
unsigned int get_page_size(void)
|
||||
{
|
||||
|
@ -910,7 +863,7 @@ void output_function_header( const char *func, int global )
|
|||
if (global) output( "\t.globl %s\n\t.hidden %s\n", name, name );
|
||||
break;
|
||||
}
|
||||
output( "\t.align %u\n", get_alignment(4) );
|
||||
output( "\t.balign 4\n" );
|
||||
output( "%s:\n", name );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue