[PATCH 147/188] giving an option not to write relocation information

From 407b608d27b470c208e30f55d8ea7dff5deedcc3 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <skalogryz.lists@gmail.com>
Date: Wed, 25 Mar 2020 15:02:17 -0400

git-svn-id: branches/wasm@46143 -
This commit is contained in:
nickysn 2020-08-03 13:01:40 +00:00
parent b828875a43
commit dd9cff6845

View File

@ -19,20 +19,20 @@ begin
end;
end;
procedure WriteBin(const fndst: string; m: TWasmModule);
procedure WriteBin(const fndst: string; m: TWasmModule; WriteReloc: Boolean);
var
f : TFileStream;
begin
f := TFileStream.Create(fndst, fmCreate);
try
Normalize(m);
WriteModule(m, f, true, true);
WriteModule(m, f, WriteReloc, WriteReloc);
finally
f.Free;
end;
end;
procedure Run(const fn: string; const doTraverse: Boolean);
procedure Run(const fn: string; const doTraverse: Boolean; doReloc: Boolean);
var
st : TFileStream;
s : string;
@ -55,7 +55,7 @@ begin
if not ParseModule(p, m, err) then
writeln('Error: ', err)
else
WriteBin( ChangeFileExt(fn,'.wasm'), m);
WriteBin( ChangeFileExt(fn,'.wasm'), m, doReloc);
finally
m.Free;
end;
@ -68,18 +68,24 @@ end;
var
gFn : string;
gCommand : string = '';
gReloc : Boolean = true;
gCatch : Boolean = false;
procedure ParseParams;
var
i : integer;
s : string;
ls : string;
begin
i:=1;
while i<=ParamCount do begin
s := ParamStr(i);
if (s<>'') and (s[1]='-') then
gCommand:=AnsiLowerCase(s)
else
if (s<>'') and (s[1]='-') then begin
ls := AnsiLowerCase(s);
if ls = '-noreloc' then gReloc := false
else if ls = '-catch' then gCatch := true
else gCommand:=ls;
end else
gFn := s;
inc(i);
end;
@ -91,6 +97,7 @@ begin
writeln('please sepcify the input .wat file');
writeln('other use:');
writeln(' -compile %inpfn%');
writeln(' -noreloc - prevents relocation information from being written');
writeln(' -traverse %inpfn%');
exit;
end;
@ -98,11 +105,16 @@ begin
writeln('file doesn''t exist: ', gFn);
exit;
end;
try
Run(gFn, gCommand = '-traverse');
except
on e: exception do
writeln(e.message);
end;
if gCatch then
try
Run(gFn, gCommand = '-traverse', gReloc);
except
on e: exception do
writeln(e.message);
end
else
Run(gFn, gCommand = '-traverse', gReloc);
end.