From 76df56def326c3cdc19d63371d99389ce1e49510 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Tue, 25 Aug 2026 09:25:10 -0400 Subject: [PATCH] Fix MIPS HI16 relocation overflow --- arch/mips/arch_mips.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/mips/arch_mips.cpp b/arch/mips/arch_mips.cpp index 0e4dc9ad7b..e45f31ed6d 100644 --- a/arch/mips/arch_mips.cpp +++ b/arch/mips/arch_mips.cpp @@ -3503,10 +3503,8 @@ class MipsElfRelocationHandler: public RelocationHandler uint32_t ahl = ((inst & 0xffff) << 16) + immediate; // ((AHL + S) – (short)(AHL + S)) >> 16 - dest32[0] = swap((uint32_t)( - (inst & ~0xffff) | - (((ahl + target) - (short)(ahl + target)) >> 16) - )); + uint32_t hi = ((ahl + target) - (short)(ahl + target)) >> 16; + dest32[0] = swap((inst & ~0xffff) | (hi & 0xffff)); } else {