|
@@ -126,11 +126,12 @@ type
|
|
|
|
|
|
TWasmElement = class(TObject)
|
|
TWasmElement = class(TObject)
|
|
tableIdx : Integer;
|
|
tableIdx : Integer;
|
|
- offset : Integer;
|
|
|
|
|
|
+ offset : TWasmInstrList; // offset expression
|
|
funcCount : Integer;
|
|
funcCount : Integer;
|
|
funcs : array of TWasmId;
|
|
funcs : array of TWasmId;
|
|
function AddFunc(idx: integer): integer;
|
|
function AddFunc(idx: integer): integer;
|
|
constructor Create;
|
|
constructor Create;
|
|
|
|
+ destructor Destroy; override;
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TWasmExport }
|
|
{ TWasmExport }
|
|
@@ -277,7 +278,7 @@ end;
|
|
|
|
|
|
{ TWasmElement }
|
|
{ TWasmElement }
|
|
|
|
|
|
-function TWasmElement.AddFunc(idx: integer): Integer;
|
|
|
|
|
|
+function TWasmElement.AddFunc(idx: integer): integer;
|
|
begin
|
|
begin
|
|
if funcCount = length(funcs) then begin
|
|
if funcCount = length(funcs) then begin
|
|
if funcCount=0 then SetLength(funcs, 4)
|
|
if funcCount=0 then SetLength(funcs, 4)
|
|
@@ -290,7 +291,14 @@ end;
|
|
|
|
|
|
constructor TWasmElement.Create;
|
|
constructor TWasmElement.Create;
|
|
begin
|
|
begin
|
|
- offset:=-1;
|
|
|
|
|
|
+ inherited Create;
|
|
|
|
+ offset := TWasmInstrList.Create;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+destructor TWasmElement.Destroy;
|
|
|
|
+begin
|
|
|
|
+ offset.Free;
|
|
|
|
+ inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TWasmImport }
|
|
{ TWasmImport }
|
|
@@ -862,10 +870,12 @@ const
|
|
// Finally, when processing table relocations for symbols which
|
|
// Finally, when processing table relocations for symbols which
|
|
// have neither an import nor a definition (namely, weakly-undefined
|
|
// have neither an import nor a definition (namely, weakly-undefined
|
|
// function symbols), the value 0 is written out as the value of the relocation.
|
|
// function symbols), the value 0 is written out as the value of the relocation.
|
|
|
|
+ NON_ZEROFFSET_STR = '1';
|
|
begin
|
|
begin
|
|
if m.ElementCount=0 then begin
|
|
if m.ElementCount=0 then begin
|
|
el := m.AddElement;
|
|
el := m.AddElement;
|
|
- el.offset := NON_ZEROFFSET;
|
|
|
|
|
|
+ el.offset.AddInstr(INST_i32_const).operandText:=NON_ZEROFFSET_STR;
|
|
|
|
+ el.offset.AddInstr(INST_END);
|
|
end else
|
|
end else
|
|
el := m.GetElement(0);
|
|
el := m.GetElement(0);
|
|
Result:=-1;
|
|
Result:=-1;
|
|
@@ -875,7 +885,7 @@ begin
|
|
end;
|
|
end;
|
|
if Result<0 then
|
|
if Result<0 then
|
|
Result := el.AddFunc(func);
|
|
Result := el.AddFunc(func);
|
|
- Result := Result + el.offset;
|
|
|
|
|
|
+ Result := Result + NON_ZEROFFSET; // todo: THIS IS WRONG
|
|
end;
|
|
end;
|
|
|
|
|
|
function RegisterFuncInElem(m: TWasmModule; const funcId: string): integer;
|
|
function RegisterFuncInElem(m: TWasmModule; const funcId: string): integer;
|