Browse Source

+ wasm internal linker: internally define the '__stack_pointer' global symbol

Nikolay Nikolov 1 year ago
parent
commit
408e388af3
1 changed files with 10 additions and 0 deletions
  1. 10 0
      compiler/ogwasm.pas

+ 10 - 0
compiler/ogwasm.pas

@@ -254,6 +254,7 @@ interface
         procedure GenerateLibraryImports(ImportLibraryList:TFPHashObjectList);override;
         procedure AfterUnusedSectionRemoval;override;
         procedure MemPos_ExeSection(const aname:string);override;
+        procedure Load_Start;override;
       end;
 
       { TWasmAssembler }
@@ -4467,6 +4468,15 @@ implementation
         inherited MemPos_ExeSection(aname);
       end;
 
+    procedure TWasmExeOutput.Load_Start;
+      const
+        aname='__stack_pointer';
+      begin
+        inherited Load_Start;
+        internalObjData.createsection('*'+aname,0,[]);
+        internalObjData.SymbolDefine(aname,AB_GLOBAL,AT_WASM_GLOBAL);
+      end;
+
     procedure TWasmExeOutput.PrepareImports;
 
       function AddFunctionImport(const libname,symname:TCmdStr; functype: TWasmFuncType): Integer;