diff --git a/compiler/ogwasm.pas b/compiler/ogwasm.pas index 7253d63ddb..33be3bf656 100644 --- a/compiler/ogwasm.pas +++ b/compiler/ogwasm.pas @@ -4270,10 +4270,11 @@ implementation procedure TWasmExeOutput.PrepareFunctions; var - i: Integer; + i, j: Integer; exesec: TExeSection; objsec: TWasmObjSection; fsym: TWasmObjSymbol; + objdata: TObjData; begin if assigned(exemap) then begin @@ -4302,6 +4303,21 @@ implementation exemap.Add(' Function[' + tostr(fsym.LinkingData.ExeFunctionIndex) + '] ' + fsym.Name + fsym.LinkingData.FuncType.ToString); end; end; + { set ExeFunctionIndex to the alias symbols as well } + for i:=0 to ObjDataList.Count-1 do + begin + objdata:=TObjData(ObjDataList[i]); + for j:=0 to objdata.ObjSymbolList.Count-1 do + begin + fsym:=TWasmObjSymbol(objdata.ObjSymbolList[j]); + if assigned(fsym.objsection) and fsym.objsection.USed and (fsym.typ=AT_FUNCTION) and (fsym.LinkingData.ExeFunctionIndex=-1) then + begin + fsym.LinkingData.ExeFunctionIndex:=TWasmObjSection(fsym.objsection).MainFuncSymbol.LinkingData.ExeFunctionIndex; + if fsym.LinkingData.ExeFunctionIndex=-1 then + internalerror(2024010102); + end; + end; + end; end;