diff options
-rw-r--r-- | src/boot/efi/meson.build | 9 | ||||
-rw-r--r-- | src/boot/efi/util.h | 12 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build index e6e7eed3bc..67ce00838d 100644 --- a/src/boot/efi/meson.build +++ b/src/boot/efi/meson.build @@ -213,15 +213,16 @@ efi_c_args_alt = [efi_c_args, '-DEFI_MACHINE_TYPE_NAME="' + efi_arch_alt + '"'] efi_c_ld_args_primary = efi_c_ld_args efi_c_ld_args_alt = efi_c_ld_args -efi_c_args_primary += { +efi_arch_c_args = { 'aarch64' : ['-mgeneral-regs-only'], 'arm' : ['-mgeneral-regs-only'], 'x86_64' : ['-march=x86-64', '-mno-red-zone', '-mgeneral-regs-only'], - 'x86' : ['-march=i686', '-mgeneral-regs-only'], -}.get(host_machine.cpu_family(), []) + 'x86' : ['-march=i686', '-mgeneral-regs-only', '-malign-double'], +} +efi_c_args_primary += efi_arch_c_args.get(host_machine.cpu_family(), []) if efi_arch_alt == 'ia32' - efi_c_args_alt += ['-m32', '-march=i686', '-mgeneral-regs-only'] + efi_c_args_alt += ['-m32', efi_arch_c_args['x86']] efi_c_ld_args_alt += '-m32' endif diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index c321062996..9df7b4a2d4 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -168,10 +168,22 @@ void hexdump(const char16_t *prefix, const void *data, size_t size); # define notify_debugger(i, w) #endif +/* On x86 the compiler assumes a different incoming stack alignment than what we get. + * This will cause long long variables to be misaligned when building with + * '-mlong-double' (for correct struct layouts). Normally, the compiler realigns the + * stack itself on entry, but we have to do this ourselves here as the compiler does + * not know that this is our entry point. */ +#ifdef __i386__ +# define _realign_stack_ __attribute__((force_align_arg_pointer)) +#else +# define _realign_stack_ +#endif + #define DEFINE_EFI_MAIN_FUNCTION(func, identity, wait_for_debugger) \ EFI_SYSTEM_TABLE *ST; \ EFI_BOOT_SERVICES *BS; \ EFI_RUNTIME_SERVICES *RT; \ + _realign_stack_ \ EFIAPI EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *system_table); \ EFIAPI EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *system_table) { \ ST = system_table; \ |