From a1bdf11d993f03f0d2c4d0f3955b5d9435ee1e38 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Thu, 28 Dec 2023 16:09:03 +0200 Subject: [PATCH] + check for supported relocation types, report an error if an unsupported type is found --- compiler/ogwasm.pas | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/compiler/ogwasm.pas b/compiler/ogwasm.pas index 4489d27406..86679c820f 100644 --- a/compiler/ogwasm.pas +++ b/compiler/ogwasm.pas @@ -2380,6 +2380,21 @@ implementation InputError('Error reading the relocation type of a relocation entry'); exit; end; + if not (TWasmRelocationType(RelocType) in [R_WASM_FUNCTION_INDEX_LEB, + R_WASM_MEMORY_ADDR_LEB, + R_WASM_TABLE_INDEX_SLEB, + R_WASM_MEMORY_ADDR_SLEB, + R_WASM_SECTION_OFFSET_I32, + R_WASM_TABLE_INDEX_I32, + R_WASM_FUNCTION_OFFSET_I32, + R_WASM_MEMORY_ADDR_I32, + R_WASM_TYPE_INDEX_LEB, + R_WASM_GLOBAL_INDEX_LEB, + R_WASM_TAG_INDEX_LEB]) then + begin + InputError('Unsupported relocation type: ' + tostr(RelocType)); + exit; + end; if not ReadUleb32(RelocOffset) then begin InputError('Error reading the relocation offset of a relocation entry');