From ef796906e9faba606b8a6280c1dc97a88846c71d Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Mon, 1 Jan 2024 18:03:02 +0200 Subject: [PATCH] + wasm internal obj reader: add globals to a '.wasm_globals' object section --- compiler/ogwasm.pas | 5 ++--- compiler/systems/t_wasi.pas | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/ogwasm.pas b/compiler/ogwasm.pas index d88a5b2f9c..c7c990ab0f 100644 --- a/compiler/ogwasm.pas +++ b/compiler/ogwasm.pas @@ -3851,6 +3851,7 @@ implementation CurrSec.Size:=Len; end; ReadSectionContent(ObjData); + ObjData.createsection('.wasm_globals',1,[]); for i:=low(SymbolTable) to high(SymbolTable) do with SymbolTable[i] do @@ -3966,9 +3967,7 @@ implementation objsym:=TWasmObjSymbol(ObjData.CreateSymbol(SymName)); objsym.bind:=AB_GLOBAL; objsym.typ:=AT_WASM_GLOBAL; - objsym.objsection:=nil; - //if (SymFlags and WASM_SYM_EXPLICIT_NAME)=0 then - // TWasmObjSection(ObjData.ObjSectionList[SymIndex-FuncTypeImportsCount]).MainFuncSymbol:=objsym; + objsym.objsection:=ObjData.findsection('.wasm_globals'); objsym.offset:=0; objsym.size:=0; end; diff --git a/compiler/systems/t_wasi.pas b/compiler/systems/t_wasi.pas index 8d5d358adb..8a5e8f6e8a 100644 --- a/compiler/systems/t_wasi.pas +++ b/compiler/systems/t_wasi.pas @@ -299,6 +299,7 @@ begin LinkScript.Concat('EXESECTION .wasm_globals'); LinkScript.Concat(' SYMBOL __stack_pointer'); + LinkScript.Concat(' OBJSECTION .wasm_globals'); LinkScript.Concat('ENDEXESECTION'); LinkScript.Concat('EXESECTION .text');