Browse Source

[PATCH 074/188] update generation of symbols

From 148f4b6a764fd44237304d06ae3d2ef2f704e3af Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Thu, 5 Mar 2020 10:25:56 -0500

git-svn-id: branches/wasm@46070 -
nickysn 5 years ago
parent
commit
707c3803df
2 changed files with 4 additions and 11 deletions
  1. 3 10
      utils/wasmbin/wasmbinwriter.pas
  2. 1 1
      utils/wasmbin/wasmmodule.pas

+ 3 - 10
utils/wasmbin/wasmbinwriter.pas

@@ -176,15 +176,7 @@ begin
       // the function MUST HAVE a symbol information available
       // if it doesn't have a symbol then "wasm-objdump" would fail to read it
       f:=module.GetFunc(index);
-      if not f.hasSym then begin
-        so:=AddSymbolObject;
-        so.syminfo.kind:=SYMTAB_FUNCTION;
-        so.syminfo.flags:=0; // WASM_SYM_EXPLICIT_NAME or WASM_SYM_BINDING_LOCAL;
-        so.syminfo.symname:=f.id;
-        so.syminfo.symindex:=index;
-        so.syminfo.hasSymIndex:=true;
-        f.hasSym:=true;
-      end;
+      inc(f.codeRefCount);
     end;
   end;
 end;
@@ -550,7 +542,8 @@ var
 begin
   for i:=0 to m.FuncCount-1 do begin
     f := m.GetFunc(i);
-    if isFuncLinkSym(f.LinkInfo) then begin
+    if isFuncLinkSym(f.LinkInfo) or (f.codeRefCount>0) then begin
+      if f.LinkInfo.Name ='' then f.LinkInfo.Name := f.id;
       so:=AddSymbolObject;
       LinkInfoToBin(f.linkInfo, so.syminfo, SYMTAB_FUNCTION, i);
     end;

+ 1 - 1
utils/wasmbin/wasmmodule.pas

@@ -96,7 +96,7 @@ type
     instr    : TWasmInstrList;
     functype : TWasmFuncType;
 
-    hasSym   : Boolean;
+    codeRefCount : Integer; // number of times the function was referenced from the code
     constructor Create;
     destructor Destroy; override;
     function AddLocal: TWasmParam;