+ handle the call instruction in the wasm binary writer

This commit is contained in:
Nikolay Nikolov 2021-09-20 05:03:38 +03:00
parent ab0d7697c3
commit 3e2a9b6ceb
2 changed files with 36 additions and 0 deletions

View File

@ -112,6 +112,9 @@ interface
RELOC_ABSOLUTE_HI8,
RELOC_ABSOLUTE_LO8,
{$endif z80}
{$ifdef WASM32}
RELOC_FUNCTION_INDEX_LEB,
{$endif WASM32}
{ Relative relocation }
RELOC_RELATIVE,
{ PECoff (Windows) RVA relocation }

View File

@ -585,6 +585,22 @@ implementation
internalerror(2021092017);
end;
end;
a_call:
begin
if ops<>1 then
internalerror(2021092021);
with oper[0]^ do
case typ of
top_ref:
begin
if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
internalerror(2021092023);
result:=6;
end;
else
internalerror(2021092022);
end;
end;
else
Writeln('Warning! Not implemented opcode, pass1: ', opcode);
end;
@ -1037,6 +1053,23 @@ implementation
internalerror(2021092017);
end;
end;
a_call:
begin
if ops<>1 then
internalerror(2021092021);
with oper[0]^ do
case typ of
top_ref:
begin
if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then
internalerror(2021092023);
WriteByte($10);
objdata.writeReloc(0,5,ObjData.symbolref(ref^.symbol),RELOC_FUNCTION_INDEX_LEB);
end;
else
internalerror(2021092022);
end;
end;
else
Writeln('Warning! Not implemented opcode, pass2: ', opcode);
end;