* fixed the writing of the external functions in the import table

This commit is contained in:
Nikolay Nikolov 2021-09-25 00:39:03 +03:00
parent 54481d7218
commit 72a49b68ce

View File

@ -314,7 +314,7 @@ implementation
i: Integer; i: Integer;
begin begin
i:=AddFuncType(ft.functype); i:=AddFuncType(ft.functype);
FFuncTypeNames.Add(ft.funcname, @(FFuncTypes[i])); FFuncTypeNames.Add(ft.funcname, Pointer(i+1));
end; end;
{**************************************************************************** {****************************************************************************
@ -443,7 +443,7 @@ implementation
function TWasmObjOutput.IsExternalFunction(sym: TObjSymbol): Boolean; function TWasmObjOutput.IsExternalFunction(sym: TObjSymbol): Boolean;
begin begin
result:=(sym.bind=AB_EXTERNAL) and (TWasmObjData(sym.ObjData).FFuncTypeNames.Find(sym.Name)<>nil); result:=(sym.bind=AB_EXTERNAL) and (TWasmObjData(sym.ObjData).FFuncTypeNames.FindIndexOf(sym.Name)<>-1);
end; end;
function TWasmObjOutput.writeData(Data:TObjData):boolean; function TWasmObjOutput.writeData(Data:TObjData):boolean;
@ -536,7 +536,7 @@ implementation
WriteName(FWasmSections[wsiImport],'env'); WriteName(FWasmSections[wsiImport],'env');
WriteName(FWasmSections[wsiImport],objsym.Name); WriteName(FWasmSections[wsiImport],objsym.Name);
WriteByte(FWasmSections[wsiImport],$00); { func } WriteByte(FWasmSections[wsiImport],$00); { func }
WriteUleb(FWasmSections[wsiImport],PWasmFuncType(TWasmObjData(Data).FFuncTypeNames.Find(objsym.Name))-PWasmFuncType(TWasmObjData(Data).FFuncTypes[0])); WriteUleb(FWasmSections[wsiImport],PtrUInt(TWasmObjData(Data).FFuncTypeNames.Find(objsym.Name))-1);
end; end;
end; end;
{ import[imports_count-1] } { import[imports_count-1] }