:: commit 08bc777d17247ff96a45df060d23014a15f83080

Mintsuki <mintsuki@protonmail.com> — 2026-02-08 07:02

parents: c61c6dc236

lib/pe: Reject 32-bit relocations in higher-half PE images

diff --git a/common/lib/pe.c b/common/lib/pe.c
index e05b1ee4..7273a654 100644
--- a/common/lib/pe.c
+++ b/common/lib/pe.c
@@ -379,7 +379,12 @@ again:
 
                 size_t write_size;
                 switch (type) {
-                    case IMAGE_REL_BASED_HIGHLOW: write_size = 4; break;
+                    case IMAGE_REL_BASED_HIGHLOW:
+                        if (lower_to_higher) {
+                            panic(true, "pe: 32-bit relocations are incompatible with higher-half loading");
+                        }
+                        write_size = 4;
+                        break;
                     case IMAGE_REL_BASED_DIR64: write_size = 8; break;
                     default:
                         panic(true, "pe: Unsupported relocation type %u", type);
tab: 248 wrap: offon