From ff98ef5d4d90cd883c53986d9b0e5fe28a0420f6 Mon Sep 17 00:00:00 2001 From: Yi LIU Date: Wed, 25 Feb 2026 23:05:49 +0800 Subject: [PATCH 1/3] Fix relocation addend sign extension on 32-bit platforms When loading relocations on 32-bit platforms, the addend is read as uint32 and zero-extended to uint64, which corrupts negative addends. For example, -4 (0xFFFFFFFC) becomes 4294967292 instead of remaining -4. Use int32 with sign extension to int64, matching the Windows code path which already handles this correctly. --- core/iwasm/aot/aot_loader.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index b77ecfab88..c22eea17ba 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -3868,11 +3868,12 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end, read_uint64(buf, buf_end, relocation->relocation_addend); } else { - uint32 offset32, addend32; + uint32 offset32; + int32 addend32; read_uint32(buf, buf_end, offset32); relocation->relocation_offset = (uint64)offset32; read_uint32(buf, buf_end, addend32); - relocation->relocation_addend = (uint64)addend32; + relocation->relocation_addend = (int64)addend32; } read_uint32(buf, buf_end, relocation->relocation_type); read_uint32(buf, buf_end, symbol_index); From ecb5cfe340c8bb879e73bdebbb46b3ca7a389313 Mon Sep 17 00:00:00 2001 From: Yi LIU Date: Tue, 3 Mar 2026 15:44:26 +0800 Subject: [PATCH 2/3] Address review: keep addend32 as uint32, sign-extend via cast --- core/iwasm/aot/aot_loader.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index c22eea17ba..19985444d5 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -3868,12 +3868,11 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end, read_uint64(buf, buf_end, relocation->relocation_addend); } else { - uint32 offset32; - int32 addend32; + uint32 offset32, addend32; read_uint32(buf, buf_end, offset32); relocation->relocation_offset = (uint64)offset32; read_uint32(buf, buf_end, addend32); - relocation->relocation_addend = (int64)addend32; + relocation->relocation_addend = (int64)(int32)addend32; } read_uint32(buf, buf_end, relocation->relocation_type); read_uint32(buf, buf_end, symbol_index); From 09a05ad15a63f45361110f45e035b590cc4d7c61 Mon Sep 17 00:00:00 2001 From: Yi LIU Date: Tue, 3 Mar 2026 16:31:52 +0800 Subject: [PATCH 3/3] Retrigger CI