summaryrefslogtreecommitdiff
path: root/fpcsrc/rtl/openbsd/i386
diff options
context:
space:
mode:
authorAbou Al Montacir <abou.almontacir@sfr.fr>2013-10-14 18:34:04 +0200
committerAbou Al Montacir <abou.almontacir@sfr.fr>2013-10-14 18:34:04 +0200
commite613d5c357aebc41ca83e7e3beea3441e61299af (patch)
treed75f294045eb040eda0a17671995bd6492a4e37a /fpcsrc/rtl/openbsd/i386
parente36b5ea6c1e2551c5bad449e6b729d8ee195d62d (diff)
downloadfpc-e613d5c357aebc41ca83e7e3beea3441e61299af.tar.gz
Imported Upstream version 2.6.2upstream/2.6.2
Diffstat (limited to 'fpcsrc/rtl/openbsd/i386')
-rw-r--r--fpcsrc/rtl/openbsd/i386/bsyscall.inc14
-rw-r--r--fpcsrc/rtl/openbsd/i386/cprt0.as178
-rw-r--r--fpcsrc/rtl/openbsd/i386/prt0.as175
-rw-r--r--fpcsrc/rtl/openbsd/i386/sighnd.inc110
4 files changed, 477 insertions, 0 deletions
diff --git a/fpcsrc/rtl/openbsd/i386/bsyscall.inc b/fpcsrc/rtl/openbsd/i386/bsyscall.inc
new file mode 100644
index 00000000..624654ec
--- /dev/null
+++ b/fpcsrc/rtl/openbsd/i386/bsyscall.inc
@@ -0,0 +1,14 @@
+{
+ This file is part of the Free Pascal run time library.
+ Copyright (c) 2005 by Michael Van Canneyt,
+ member of the Free Pascal development team.
+
+ 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.
+
+ **********************************************************************}
+
diff --git a/fpcsrc/rtl/openbsd/i386/cprt0.as b/fpcsrc/rtl/openbsd/i386/cprt0.as
new file mode 100644
index 00000000..b447e400
--- /dev/null
+++ b/fpcsrc/rtl/openbsd/i386/cprt0.as
@@ -0,0 +1,178 @@
+ .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
+.global __progname_storage
+ .type __progname_storage, @ object
+ .size __progname_storage, 256
+
+ .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,operatingsystem_parameter_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,operatingsystem_parameter_argc
+ movl %esi,operatingsystem_parameter_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 operatingsystem_result,%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
+ .comm operatingsystem_parameter_envp,4,4
+ .comm operatingsystem_parameter_argc,4,4
+ .comm operatingsystem_parameter_argv,4,4
+
diff --git a/fpcsrc/rtl/openbsd/i386/prt0.as b/fpcsrc/rtl/openbsd/i386/prt0.as
new file mode 100644
index 00000000..56defa2d
--- /dev/null
+++ b/fpcsrc/rtl/openbsd/i386/prt0.as
@@ -0,0 +1,175 @@
+ .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,operatingsystem_parameter_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,operatingsystem_parameter_argc
+ movl %esi,operatingsystem_parameter_argv
+ popl %eax
+# pushl environ
+# pushl %esi
+# pushl 8(%ebp)
+ finit
+ fwait
+ fldcw ___fpucw
+ xorl %ebp,%ebp
+ call main
+# pushl %eax
+# call exit
+ jmp _haltproc
+ .p2align 2,0x90
+
+.globl _haltproc
+.type _haltproc,@function
+
+_haltproc:
+ mov $1,%eax
+ movzwl operatingsystem_result,%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
+ .comm operatingsystem_parameter_envp,4,4
+ .comm operatingsystem_parameter_argc,4,4
+ .comm operatingsystem_parameter_argv,4,4
+
diff --git a/fpcsrc/rtl/openbsd/i386/sighnd.inc b/fpcsrc/rtl/openbsd/i386/sighnd.inc
new file mode 100644
index 00000000..c9a9da50
--- /dev/null
+++ b/fpcsrc/rtl/openbsd/i386/sighnd.inc
@@ -0,0 +1,110 @@
+{
+ 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;
+
+{$ifdef cpui386}
+function getfpustate(sininfo:psiginfo):longint; {inline;}
+begin
+ if ptruint(sininfo)> high(word) then
+ getfpustate:=sininfo^.si_code
+ else
+ getfpustate:=word(ptruint(sininfo));
+end;
+
+function getaltfpustate(sigcontext:psigcontextrec):longint; {inline;}
+begin
+ if assigned(sigcontext) then
+ begin
+ if mmx_support then
+ getaltfpustate:=sigcontext^.sc_fpustate^.xmmState.fx_fsw
+ else
+ getaltfpustate:=sigcontext^.sc_fpustate^.x87state.en_sw
+ end
+ else
+ getaltfpustate:=0;
+end;
+{$endif}
+
+procedure SignalToRunerror(Sig: longint;sininfo:psiginfo; SigContext: PSigContextRec); public name '_FPC_DEFAULTSIGHANDLER'; cdecl;
+
+var
+ res,fpustate : word;
+ oldact: SigActionRec;
+begin
+ res:=0;
+{$ifdef BSD}
+{$ifdef cpui386}
+ fpustate:=0;
+ asm
+ fnstsw fpustate
+ end;
+{$endif cpui386}
+{$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;
+{$ifdef cpui386}
+ fpustate:=GetaltFPUState(sigcontext);
+{$else}
+ fpustate:=0;
+{$endif}
+ 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;
+ SIGINT:
+ res:=217;
+ SIGQUIT:
+ res:=233;
+ end;
+{$ifdef DEBUG_SIGNAL_HANDLER}
+ InstallDefaultSignalHandler(sig,oldact);
+ InstallDefaultSignalHandler(sig,oldact);
+{$endif}
+ reenable_signal(sig);
+{ give runtime error at the position where the signal was raised }
+ if res<>0 then
+ begin
+{$ifdef cpui386}
+ HandleErrorAddrFrame(res,pointer(SigContext^.sc_eip),pointer(SigContext^.sc_ebp));
+{$endif}
+ end;
+end;
+
+