Browse Source

+ add tag names to the WebAssembly name section

Nikolay Nikolov 10 months ago
parent
commit
1ea876b517
1 changed files with 10 additions and 0 deletions
  1. 10 0
      compiler/ogwasm.pas

+ 10 - 0
compiler/ogwasm.pas

@@ -299,10 +299,12 @@ interface
         FFunctionNameMap: TCustomSectionNameMap;
         FGlobalNameMap: TCustomSectionNameMap;
         FDataNameMap: TCustomSectionNameMap;
+        FTagNameMap: TCustomSectionNameMap;
         procedure AddToNameMap(var nm: TCustomSectionNameMap; aidx: UInt32; const aname: string);
         procedure AddToFunctionNameMap(aidx: UInt32; const aname: string);
         procedure AddToGlobalNameMap(aidx: UInt32; const aname: string);
         procedure AddToDataNameMap(aidx: UInt32; const aname: string);
+        procedure AddToTagNameMap(aidx: UInt32; const aname: string);
         procedure WriteWasmSection(wsid: TWasmSectionID);
         procedure WriteWasmSectionIfNotEmpty(wsid: TWasmSectionID);
         procedure WriteWasmCustomSection(wcst: TWasmCustomSectionType);
@@ -4805,6 +4807,11 @@ implementation
         AddToNameMap(FDataNameMap,aidx,aname);
       end;
 
+    procedure TWasmExeOutput.AddToTagNameMap(aidx: UInt32; const aname: string);
+      begin
+        AddToNameMap(FTagNameMap,aidx,aname);
+      end;
+
     procedure TWasmExeOutput.WriteWasmSection(wsid: TWasmSectionID);
       var
         b: byte;
@@ -5072,6 +5079,7 @@ implementation
               objsec:=TWasmObjSection(exesec.ObjSectionList[i]);
               WriteByte(FWasmSections[wsiTag],0);
               WriteUleb(FWasmSections[wsiTag],objsec.MainFuncSymbol.LinkingData.ExeTypeIndex);
+              AddToTagNameMap(i,objsec.MainFuncSymbol.Name);
             end;
         end;
 
@@ -5159,11 +5167,13 @@ implementation
           WriteNameMap(FFunctionNameMap,FWasmNameSubsections[wnstFunctionNames]);
           WriteNameMap(FGlobalNameMap,FWasmNameSubsections[wnstGlobalNames]);
           WriteNameMap(FDataNameMap,FWasmNameSubsections[wnstDataNames]);
+          WriteNameMap(FTagNameMap,FWasmNameSubsections[wnstTagNames]);
 
           WriteNameSubsection(wnstModuleName);
           WriteNameSubsection(wnstFunctionNames);
           WriteNameSubsection(wnstGlobalNames);
           WriteNameSubsection(wnstDataNames);
+          WriteNameSubsection(wnstTagNames);
         end;
 
       var