Skip to content

Commit ff98ef5

Browse files
committed
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.
1 parent c46b10d commit ff98ef5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

core/iwasm/aot/aot_loader.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3868,11 +3868,12 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
38683868
read_uint64(buf, buf_end, relocation->relocation_addend);
38693869
}
38703870
else {
3871-
uint32 offset32, addend32;
3871+
uint32 offset32;
3872+
int32 addend32;
38723873
read_uint32(buf, buf_end, offset32);
38733874
relocation->relocation_offset = (uint64)offset32;
38743875
read_uint32(buf, buf_end, addend32);
3875-
relocation->relocation_addend = (uint64)addend32;
3876+
relocation->relocation_addend = (int64)addend32;
38763877
}
38773878
read_uint32(buf, buf_end, relocation->relocation_type);
38783879
read_uint32(buf, buf_end, symbol_index);

0 commit comments

Comments
 (0)