From 0a1f260b1b078888ca511c2a020c066da59409c3 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 60b0566b07..1644b0a8ca 100644 --- a/arch/mips/arch_mips.cpp +++ b/arch/mips/arch_mips.cpp @@ -3747,10 +3747,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 {