Procházet zdrojové kódy

* working versions, untested

marco před 21 roky
rodič
revize
b12396f527
2 změnil soubory, kde provedl 262 přidání a 0 odebrání
  1. 170 0
      rtl/openbsd/i386/cprt0.as
  2. 92 0
      rtl/openbsd/i386/sighnd.inc

+ 170 - 0
rtl/openbsd/i386/cprt0.as

@@ -0,0 +1,170 @@
+	.file	"crt0.c"
+gcc2_compiled.:
+.data
+	.align 32
+	.type	 rcsid , @object
+	.size	rcsid , 58
+rcsid:
+	.string	"$OpenBSD: crt0.c,v 1.11 2003/06/27 22:30:38 deraadt Exp $"
+.globl __progname
+.section	.rodata
+.LC0:
+	.string	""
+.data
+	.align 4
+	.type	 __progname , @object
+	.size	__progname , 4
+__progname:
+	.long .LC0
+        .align  4
+___fpucw:
+        .long   0x1332
+
+        .globl  ___fpc_brk_addr         /* heap management */
+        .type   ___fpc_brk_addr,@object
+        .size   ___fpc_brk_addr,4
+___fpc_brk_addr:
+        .long   0
+
+#APP
+	
+	.text
+	.align  4
+	.globl  __start
+	.globl  _start
+_start:
+__start:
+	pushl	%ebx			#ps_strings
+	pushl   %ecx                    # obj
+	pushl   %edx                    # cleanup
+	movl    12(%esp),%eax
+	leal    20(%esp,%eax,4),%ecx
+	leal    16(%esp),%edx
+	pushl   %ecx
+	pushl   %edx
+	pushl   %eax
+	call    ___start
+
+#NO_APP
+.text
+	.align 4
+.globl ___start
+	.type	___start , @function
+___start:
+	pushl %ebp
+	movl %esp,%ebp
+	subl $16,%esp
+	pushl %esi
+	pushl %ebx
+	movl 12(%ebp),%esi
+	movl 16(%ebp),%eax
+	movl %eax,environ
+	movl %eax,U_SYSTEM_ENVP
+	movl (%esi),%ebx
+	testl %ebx,%ebx
+	je .L3
+	addl $-8,%esp
+	pushl $47
+	pushl %ebx
+	call _strrchr
+	movl %eax,__progname
+	addl $16,%esp
+	testl %eax,%eax
+	jne .L4
+	movl %ebx,__progname
+	jmp .L5
+	.p2align 4,,7
+.L4:
+	incl %eax
+	movl %eax,__progname
+.L5:
+	movl $__progname_storage,%edx
+	jmp .L12
+	.p2align 4,,7
+.L9:
+	movb (%eax),%al
+	movb %al,(%edx)
+	incl __progname
+	incl %edx
+.L12:
+	movl __progname,%eax
+	cmpb $0,(%eax)
+	je .L7
+	cmpl $__progname_storage+255,%edx
+	jb .L9
+.L7:
+	movb $0,(%edx)
+	movl $__progname_storage,__progname
+.L3:
+	call __init
+	subl $16,%esp
+	pushl %eax
+	movl 8(%ebp),%eax
+	movl %eax,U_SYSTEM_ARGC
+	movl %esi,U_SYSTEM_ARGV
+	popl %eax
+#	pushl environ
+#	pushl %esi
+#	pushl 8(%ebp)
+	finit
+	fwait
+	fldcw __fpucw
+	xorl  %ebp,%ebp
+	call main
+	pushl %eax
+	call exit
+        .p2align 2,0x90
+
+.globl _haltproc
+.type _haltproc,@function
+
+_haltproc:
+           mov $1,%eax 
+           movzwl U_SYSTEM_EXITCODE,%ebx
+           pushl %ebx
+           call .Lactualsyscall
+           addl  $4,%esp
+           jmp   _haltproc
+
+.Lactualsyscall:
+         int $0x80
+         jb .LErrorcode
+         xor %ebx,%ebx
+         ret
+.LErrorcode:
+         mov %eax,%ebx
+         mov $-1,%eax
+         ret
+        .p2align 2,0x90
+.Lfe1:
+
+	.size	___start , . - ___start
+	.align 4
+	.type	_strrchr , @function
+_strrchr:
+	pushl %ebp
+	movl %esp,%ebp
+	pushl %ebx
+	movl 8(%ebp),%eax
+	movb 12(%ebp),%bl
+	xorl %ecx,%ecx
+	.p2align 4,,7
+.L14:
+	movb (%eax),%dl
+	cmpb %bl,%dl
+	jne .L17
+	movl %eax,%ecx
+.L17:
+	testb %dl,%dl
+	je .L16
+	incl %eax
+	jmp .L14
+	.p2align 4,,7
+.L16:
+	movl %ecx,%eax
+	popl %ebx
+	leave
+	ret
+	.size	_strrchr , . - _strrchr
+	.comm	environ,4,4
+	.comm	__progname_storage,256,32

+ 92 - 0
rtl/openbsd/i386/sighnd.inc

@@ -0,0 +1,92 @@
+{  
+   $Id$
+   This file is part of the Free Pascal run time library.
+   (c) 2000-2003 by Marco van de Voort
+   member of the Free Pascal development team.
+
+   See the file COPYING.FPC, included in this distribution,
+   for details about the copyright.
+
+   Signalhandler for FreeBSD/i386
+
+   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.
+}
+
+CONST FPU_ALL=$7F;
+
+function getfpustate(const Sigcontext:sigcontextRec):longint; {inline;}
+begin
+  getfpustate:=0;
+end;
+procedure SignalToRunerror(Sig: longint;code:longint; var SigContext: SigContextRec); cdecl;
+
+var
+  res,fpustate : word;
+begin
+  res:=0;
+{$ifdef BSD}
+{$ifdef I386}
+  fpustate:=0;
+  asm
+    fnstsw fpustate
+  end;
+{$endif I386}
+{$endif BSD}
+  case sig of
+    SIGFPE :
+          begin
+    { this is not allways necessary but I don't know yet
+      how to tell if it is or not PM }
+          res:=200;
+          fpustate:=GetFPUState(SigContext);
+
+          if (FpuState and FPU_All) <> 0 then
+            begin
+              { first check the more precise options }
+              if (FpuState and FPU_DivisionByZero)<>0 then
+                res:=200
+              else if (FpuState and FPU_Overflow)<>0 then
+                res:=205
+              else if (FpuState and FPU_Underflow)<>0 then
+                res:=206
+              else if (FpuState and FPU_Denormal)<>0 then
+                res:=216
+              else if (FpuState and (FPU_StackOverflow or FPU_StackUnderflow))<>0 then
+                res:=207
+              else if (FpuState and FPU_Invalid)<>0 then
+                res:=216
+              else
+                res:=207;  {'Coprocessor Error'}
+            end;
+          SysResetFPU;
+        end;
+    SIGILL,
+    SIGBUS,
+    SIGSEGV :
+        res:=216;
+  end;
+  reenable_signal(sig);
+{ give runtime error at the position where the signal was raised }
+  if res<>0 then
+   begin
+{$ifdef I386}
+      HandleErrorAddrFrame(res,pointer(SigContext.sc_eip),pointer(SigContext.sc_ebp));
+{$endif}
+   end;
+end;
+
+
+{
+  $Log$
+  Revision 1.1  2004-01-20 17:01:42  marco
+   * working versions, untested
+
+  Revision 1.1  2004/01/04 15:30:19  marco
+   * working version
+
+  Revision 1.1  2004/01/03 12:29:36  marco
+   * now separately.
+
+}