* WebAssembly threads internal linker: fix validation of R_WASM_GLOBAL_INDEX_LEB relocations in modules that support threads

This commit is contained in:
Nikolay Nikolov 2024-08-10 19:43:52 +03:00
parent 610f2bb3c9
commit 961042356c

View File

@ -2700,9 +2700,16 @@ implementation
InputError('R_WASM_SECTION_OFFSET_I32 must point to a SYMTAB_SECTION symbol');
exit;
end;
if (RelocType=R_WASM_GLOBAL_INDEX_LEB) and (SymbolTable[RelocIndex].SymKind<>SYMTAB_GLOBAL) then
if (RelocType=R_WASM_GLOBAL_INDEX_LEB) and
not ((SymbolTable[RelocIndex].SymKind=SYMTAB_GLOBAL) or
((ts_wasm_threads in current_settings.targetswitches) and
(SymbolTable[RelocIndex].SymKind=SYMTAB_DATA) and
((SymbolTable[RelocIndex].SymFlags and WASM_SYM_TLS)<>0))) then
begin
InputError('Relocation must point to a SYMTAB_GLOBAL symbol');
if ts_wasm_threads in current_settings.targetswitches then
InputError('Relocation must point to a SYMTAB_GLOBAL symbol or a SYMTAB_DATA symbol with the WASM_SYM_TLS flag set')
else
InputError('Relocation must point to a SYMTAB_GLOBAL symbol');
exit;
end;
if (RelocType=R_WASM_TAG_INDEX_LEB) and (SymbolTable[RelocIndex].SymKind<>SYMTAB_EVENT) then