:: commit 3a2b335e4213a7dc987e9f851c28e3e69a2a2d4a

mintsuki <mintsuki@protonmail.com> — 2022-08-25 19:50

parents: c15c6fa31c

entry/uefi: Abort if loaded above 4GiB. Fix #206

diff --git a/common/entry.s3.c b/common/entry.s3.c
index f3e7f2c3..c527c6d1 100644
--- a/common/entry.s3.c
+++ b/common/entry.s3.c
@@ -46,6 +46,8 @@ EFI_STATUS efi_main(
 #endif
 }
 
+extern symbol __image_base;
+
 noreturn void uefi_entry(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
     gST = SystemTable;
     gBS = SystemTable->BootServices;
@@ -67,6 +69,10 @@ noreturn void uefi_entry(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
 
     init_gdt();
 
+    if ((uintptr_t)__image_base > 0x100000000) {
+        panic(false, "Limine does not support being loaded above 4GiB");
+    }
+
     disk_create_index();
 
     boot_volume = NULL;
tab: 248 wrap: offon