:: commit 99c94dddfc7474872aeecc771c5873095db1b5c4

monkuous <84319635+monkuous@users.noreply.github.com> — 2024-09-17 20:35

parents: 6bdf6c3e58

protos/multiboot2: use unsigned relocated_base

diff --git a/common/protos/multiboot2.c b/common/protos/multiboot2.c
index 49f99ca0..0c0afe82 100644
--- a/common/protos/multiboot2.c
+++ b/common/protos/multiboot2.c
@@ -318,20 +318,20 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
 
     if (has_reloc_header) {
         bool reloc_ascend;
-        int64_t relocated_base;
+        uint64_t relocated_base;
 
         switch (reloc_tag.preference) {
             default:
             case 0: case 1: // Prefer lowest to highest
                 reloc_ascend = true;
-                relocated_base = (int64_t)ALIGN_UP(reloc_tag.min_addr, reloc_tag.align);
+                relocated_base = ALIGN_UP(reloc_tag.min_addr, reloc_tag.align);
                 if (relocated_base + ranges->length > reloc_tag.max_addr) {
                     goto reloc_fail;
                 }
                 break;
             case 2: // Prefer highest to lowest
                 reloc_ascend = false;
-                relocated_base = (int64_t)ALIGN_DOWN(reloc_tag.max_addr - ranges->length, reloc_tag.align);
+                relocated_base = ALIGN_DOWN(reloc_tag.max_addr - ranges->length, reloc_tag.align);
                 if (relocated_base < reloc_tag.min_addr) {
                     goto reloc_fail;
                 }
@@ -356,7 +356,7 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
             }
         }
 
-        reloc_slide = relocated_base - ranges->target;
+        reloc_slide = (int64_t)relocated_base - ranges->target;
 
         entry_point += reloc_slide;
 
tab: 248 wrap: offon