Browse Source

+ wasm internal object reader: check that relocations that should point to a SYMTAB_DATA symbol, actually point to such symbol

Nikolay Nikolov 1 year ago
parent
commit
dc16426790
1 changed files with 8 additions and 0 deletions
  1. 8 0
      compiler/ogwasm.pas

+ 8 - 0
compiler/ogwasm.pas

@@ -2687,6 +2687,14 @@ implementation
                         InputError('Relocation must point to a SYMTAB_FUNCTION symbol');
                         exit;
                       end;
+                    if (RelocType in [
+                          R_WASM_MEMORY_ADDR_LEB,
+                          R_WASM_MEMORY_ADDR_SLEB,
+                          R_WASM_MEMORY_ADDR_I32]) and (SymbolTable[RelocIndex].SymKind<>SYMTAB_DATA) then
+                      begin
+                        InputError('Relocation must point to a SYMTAB_DATA symbol');
+                        exit;
+                      end;
                   end;
               if AReader.Pos<>(SectionStart+SectionSize) then
                 begin