浏览代码

+ added OpenBSD startup units for gprof support

git-svn-id: trunk@41757 -
nickysn 6 年之前
父节点
当前提交
e4ffeb2266
共有 6 个文件被更改,包括 153 次插入5 次删除
  1. 3 0
      .gitattributes
  2. 4 3
      rtl/openbsd/Makefile
  3. 5 2
      rtl/openbsd/Makefile.fpc
  4. 16 0
      rtl/openbsd/i386/si_g.inc
  5. 28 0
      rtl/openbsd/si_g.pp
  6. 97 0
      rtl/openbsd/x86_64/si_g.inc

+ 3 - 0
.gitattributes

@@ -10252,6 +10252,7 @@ rtl/openbsd/i386/openbsd_ident.inc svneol=native#text/plain
 rtl/openbsd/i386/prt0.as svneol=native#text/plain
 rtl/openbsd/i386/si_c.inc svneol=native#text/plain
 rtl/openbsd/i386/si_dll.inc svneol=native#text/plain
+rtl/openbsd/i386/si_g.inc svneol=native#text/plain
 rtl/openbsd/i386/si_prc.inc svneol=native#text/plain
 rtl/openbsd/i386/sighnd.inc svneol=native#text/plain
 rtl/openbsd/osdefs.inc svneol=native#text/plain
@@ -10262,6 +10263,7 @@ rtl/openbsd/rtldefs.inc svneol=native#text/plain
 rtl/openbsd/setsysnr.inc svneol=native#text/plain
 rtl/openbsd/si_c.pp svneol=native#text/plain
 rtl/openbsd/si_dll.pp svneol=native#text/plain
+rtl/openbsd/si_g.pp svneol=native#text/plain
 rtl/openbsd/si_impl.inc svneol=native#text/plain
 rtl/openbsd/si_intf.inc svneol=native#text/plain
 rtl/openbsd/si_prc.pp svneol=native#text/plain
@@ -10288,6 +10290,7 @@ rtl/openbsd/x86_64/openbsd_ident.inc svneol=native#text/plain
 rtl/openbsd/x86_64/prt0.as svneol=native#text/plain
 rtl/openbsd/x86_64/si_c.inc svneol=native#text/plain
 rtl/openbsd/x86_64/si_dll.inc svneol=native#text/plain
+rtl/openbsd/x86_64/si_g.inc svneol=native#text/plain
 rtl/openbsd/x86_64/si_prc.inc svneol=native#text/plain
 rtl/openbsd/x86_64/sighnd.inc svneol=native#text/plain
 rtl/os2/Makefile svneol=native#text/plain

+ 4 - 3
rtl/openbsd/Makefile

@@ -358,11 +358,11 @@ SYSINIT_UNITS=
 LOADERS=prt0 cprt0 dllprt0
 ifeq ($(ARCH),x86_64)
 CPU_UNITS=x86 ports cpu
-SYSINIT_UNITS=si_prc si_c si_dll
+SYSINIT_UNITS=si_prc si_c si_dll si_g
 endif
 ifeq ($(ARCH),i386)
 CPU_UNITS=x86 ports cpu mmx
-SYSINIT_UNITS=si_prc si_c si_dll
+SYSINIT_UNITS=si_prc si_c si_dll si_g
 endif
 OBJPASDIR=$(RTL)/objpas
 GRAPHDIR=$(INC)/graph
@@ -3104,7 +3104,6 @@ ifdef CLEAN_FILES
 	-$(DEL) $(CLEAN_FILES)
 endif
 	-$(DELTREE) units
-	-$(DELTREE) bin
 	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
 ifneq ($(PPUEXT),.ppu)
 	-$(DEL) *.o *.ppu *.a
@@ -3272,6 +3271,8 @@ si_c$(PPUEXT) : si_c.pp si_intf.inc si_impl.inc $(ARCH)/openbsd_ident.inc $(ARCH
 	$(COMPILER) $<
 si_dll$(PPUEXT) : si_dll.pp si_intf.inc si_impl.inc $(ARCH)/openbsd_ident.inc $(ARCH)/si_dll.inc $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $<
+si_g$(PPUEXT) : si_g.pp si_intf.inc si_impl.inc $(ARCH)/openbsd_ident.inc $(ARCH)/si_g.inc $(SYSTEMUNIT)$(PPUEXT)
+	$(COMPILER) $<
 $(SYSTEMUNIT)$(PPUEXT) : $(BSDINC)/$(SYSTEMUNIT).pp sysconst.inc systypes.inc syscalls.inc $(SYSDEPS)
 	$(COMPILER) $(FPC_SYSTEM_OPT) -Us -Sg $(BSDINC)/$(SYSTEMUNIT).pp
 uuchar$(PPUEXT): $(INC)/uuchar.pp $(SYSTEMUNIT)$(PPUEXT)

+ 5 - 2
rtl/openbsd/Makefile.fpc

@@ -89,11 +89,11 @@ LOADERS=prt0 cprt0 dllprt0
 
 ifeq ($(ARCH),x86_64)
 CPU_UNITS=x86 ports cpu
-SYSINIT_UNITS=si_prc si_c si_dll
+SYSINIT_UNITS=si_prc si_c si_dll si_g
 endif
 ifeq ($(ARCH),i386)
 CPU_UNITS=x86 ports cpu mmx
-SYSINIT_UNITS=si_prc si_c si_dll
+SYSINIT_UNITS=si_prc si_c si_dll si_g
 endif
 
 # Paths
@@ -154,6 +154,9 @@ si_c$(PPUEXT) : si_c.pp si_intf.inc si_impl.inc $(ARCH)/openbsd_ident.inc $(ARCH
 si_dll$(PPUEXT) : si_dll.pp si_intf.inc si_impl.inc $(ARCH)/openbsd_ident.inc $(ARCH)/si_dll.inc $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $<
 
+si_g$(PPUEXT) : si_g.pp si_intf.inc si_impl.inc $(ARCH)/openbsd_ident.inc $(ARCH)/si_g.inc $(SYSTEMUNIT)$(PPUEXT)
+	$(COMPILER) $<
+
 
 #
 # System Units (System, Objpas, Strings)

+ 16 - 0
rtl/openbsd/i386/si_g.inc

@@ -0,0 +1,16 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Free Pascal development team
+
+    This file implements parts of the startup code for OpenBSD
+    programs, compiled with gprof support.
+
+    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.
+
+ **********************************************************************}
+

+ 28 - 0
rtl/openbsd/si_g.pp

@@ -0,0 +1,28 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Free Pascal development team
+
+    This file implements parts of the startup code for OpenBSD
+    programs, compiled with gprof support.
+
+    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_g;
+
+interface
+
+{$i si_intf.inc}
+
+implementation
+
+{$i si_impl.inc}
+{$i si_g.inc}
+
+end.

+ 97 - 0
rtl/openbsd/x86_64/si_g.inc

@@ -0,0 +1,97 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Free Pascal development team
+
+    This file implements parts of the startup code for OpenBSD
+    programs, compiled with gprof support.
+
+    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.
+
+ **********************************************************************}
+
+{$asmmode gas}
+
+var
+  _etext: Byte; external name '_etext';
+  _eprol: Byte; external name '_eprol';
+
+procedure _mcleanup; cdecl; external name '_mcleanup';
+function atexit(proc: TCdeclProcedure): cint; cdecl; external name 'atexit';
+procedure monstartup(lowpc, highpc: u_long); cdecl; external name 'monstartup';
+procedure __init; cdecl; external name '__init';
+procedure c_exit(exit_code: cint); cdecl; noreturn; external name 'exit';
+
+procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord); forward;
+
+procedure _FPC_proc_start; assembler; nostackframe; public name '_start'; public name '__start';
+  asm
+    movq    %rbx,%r9
+    movq    %rcx,%r8
+    movq    %rdx,%rcx
+    movq    (%rsp),%rdi
+    leaq    16(%rsp,%rdi,8),%rdx
+    leaq    8(%rsp),%rsi
+    subq    $8,%rsp
+    andq    $0xFFFFFFFFFFFFFFF0,%rsp
+    addq    $8,%rsp
+    jmp     _FPC_proc___start
+  end;
+
+procedure _FPC_proc_haltproc; noreturn; forward;
+function _strrchr(str: PChar; character: LongInt): PChar; forward;
+
+procedure _FPC_proc___start(argc: LongInt; argv: PPChar; envp: Pointer; para1, para2, para3: QWord);
+  var
+    I: SizeUInt;
+  begin
+    environ:=envp;
+    operatingsystem_parameter_envp:=envp;
+    operatingsystem_parameter_argc:=argc;
+    operatingsystem_parameter_argv:=argv;
+    if argv[0]<>nil then
+      begin
+        __progname:=_strrchr(argv[0], Ord('/'));
+        if __progname<>nil then
+          Inc(__progname)
+        else
+          __progname:=argv[0];
+        I:=Low(__progname_storage);
+        while (I<High(__progname_storage)) and (__progname[I]<>#0) do
+          begin
+            __progname_storage[I]:=__progname[I-Low(__progname_storage)];
+            Inc(I);
+          end;
+        __progname_storage[I]:=#0;
+        __progname:=@__progname_storage;
+      end;
+    atexit(@_mcleanup);
+    monstartup(u_long(@_eprol),u_long(@_etext));
+    __init;
+    PascalMain;
+    c_exit(operatingsystem_result);
+  end;
+
+procedure _FPC_proc_haltproc; noreturn; public name '_haltproc';
+  begin
+    c_exit(operatingsystem_result);
+  end;
+
+function _strrchr(str: PChar; character: LongInt): PChar; public name '_strrchr';
+  begin
+    _strrchr:=nil;
+    repeat
+      if str^=Chr(character) then
+        _strrchr:=str;
+      if str^<>#0 then
+        Inc(str);
+    until str^=#0;
+  end;
+
+procedure MD_EPROL_LABEL; assembler; nostackframe; public name '_eprol';
+  asm
+  end;