Преглед изворни кода

+ added startup code for WASI

git-svn-id: branches/wasm@48304 -
nickysn пре 4 година
родитељ
комит
f5f15e3dbf
4 измењених фајлова са 46 додато и 1 уклоњено
  1. 1 0
      .gitattributes
  2. 2 1
      compiler/systems.pas
  3. 7 0
      compiler/systems/t_wasi.pas
  4. 36 0
      rtl/wasi/si_prc.pp

+ 1 - 0
.gitattributes

@@ -12193,6 +12193,7 @@ rtl/unix/x86.pp svneol=native#text/plain
 rtl/wasi/Makefile svneol=native#text/plain
 rtl/wasi/Makefile.fpc svneol=native#text/plain
 rtl/wasi/rtldefs.inc svneol=native#text/plain
+rtl/wasi/si_prc.pp svneol=native#text/plain
 rtl/wasi/sysdir.inc svneol=native#text/plain
 rtl/wasi/sysfile.inc svneol=native#text/plain
 rtl/wasi/sysheap.inc svneol=native#text/plain

+ 2 - 1
compiler/systems.pas

@@ -393,7 +393,8 @@ interface
                                    system_i386_openbsd,system_x86_64_openbsd,
                                    system_riscv32_linux,system_riscv64_linux,
                                    system_aarch64_win64,
-                                   system_z80_zxspectrum,system_z80_msxdos
+                                   system_z80_zxspectrum,system_z80_msxdos,
+                                   system_wasm32_wasi
                                   ]+systems_darwin+systems_amigalike;
 
        { all systems that use the PE+ header in the PE/COFF file

+ 7 - 0
compiler/systems/t_wasi.pas

@@ -66,6 +66,8 @@ type
     constructor Create;override;
     procedure SetDefaultInfo;override;
 
+    procedure InitSysInitUnitName;override;
+
     function  MakeExecutable:boolean;override;
     function  MakeSharedLibrary:boolean;override;
   end;
@@ -96,6 +98,11 @@ begin
   //Info.DllCmd[2] := 'wasmtool --exportrename $INPUT $EXE';
 end;
 
+procedure tlinkerwasi.InitSysInitUnitName;
+begin
+  sysinitunit:='si_prc';
+end;
+
 function tlinkerwasi.MakeExecutable:boolean;
 var
   GCSectionsStr  : ansistring;

+ 36 - 0
rtl/wasi/si_prc.pp

@@ -0,0 +1,36 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2021 by Free Pascal development team
+
+    This file implements the startup code for WebAssembly programs that
+    don't link to the C library.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+unit si_prc;
+
+interface
+
+procedure _start;
+
+implementation
+
+procedure PASCALMAIN; external 'PASCALMAIN';
+
+procedure _start;
+begin
+  PASCALMAIN;
+end;
+
+exports
+  _start;
+
+end.