Lorenz Brun | 5d40c67 | 2021-09-28 15:06:37 +0200 | [diff] [blame^] | 1 | From d725d3cd472434c52e3c4bebbd7b242329d7a1b4 Mon Sep 17 00:00:00 2001 |
| 2 | From: Lorenz Brun <lorenz@monogon.tech> |
| 3 | Date: Tue, 28 Sep 2021 05:21:10 +0200 |
| 4 | Subject: [PATCH] Use the SysV ABI calling into the kernel |
| 5 | |
| 6 | The original code expected to be compiled into a PE binary but |
| 7 | internally still using the SysV ABI. Lots of trampolines are used to |
| 8 | make that work as everything outside is using the MSVC ABI. |
| 9 | The kernel also exposes the MSVC ABI using trampolines, but only for |
| 10 | direct PE entrypoints. The EFI handover jump target does not do ABI |
| 11 | conversion and thus matches the kernel's internal ABI, which is SysV. |
| 12 | |
| 13 | This means this call needs to be annotated as otherwise we'd call into |
| 14 | the Kernel's EFI code using the MSVC ABI which is expecting SysV. |
| 15 | Sigh. |
| 16 | --- |
| 17 | src/boot/efi/linux.c | 2 +- |
| 18 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 19 | |
| 20 | diff --git a/src/boot/efi/linux.c b/src/boot/efi/linux.c |
| 21 | index 5232a3ba40..0d58f39ff6 100644 |
| 22 | --- a/src/boot/efi/linux.c |
| 23 | +++ b/src/boot/efi/linux.c |
| 24 | @@ -12,7 +12,7 @@ |
| 25 | #define __regparm0__ |
| 26 | #endif |
| 27 | |
| 28 | -typedef VOID(*handover_f)(VOID *image, EFI_SYSTEM_TABLE *table, struct boot_params *params) __regparm0__; |
| 29 | +typedef __attribute__((sysv_abi)) VOID(*handover_f)(VOID *image, EFI_SYSTEM_TABLE *table, struct boot_params *params) __regparm0__; |
| 30 | |
| 31 | static VOID linux_efi_handover(EFI_HANDLE image, struct boot_params *params) { |
| 32 | handover_f handover; |
| 33 | -- |
| 34 | 2.25.1 |
| 35 | |