mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 02:19:27 +02:00
* first 1.1 netbsd rtl, basically freebsd copy and paste with 1.0.10 netbsd structures
This commit is contained in:
parent
d3e862638f
commit
736861f26e
438
rtl/netbsd/i386/cprt0.as
Normal file
438
rtl/netbsd/i386/cprt0.as
Normal file
@ -0,0 +1,438 @@
|
|||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
# This file is part of the Free Pascal run time library.
|
||||||
|
# Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
|
||||||
|
# and Peter Vreman
|
||||||
|
# members 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.
|
||||||
|
#
|
||||||
|
#**********************************************************************}
|
||||||
|
#
|
||||||
|
# NetBSD standard (shared) ELF/i386 startup code for Free Pascal
|
||||||
|
#
|
||||||
|
|
||||||
|
.file "crt0.c"
|
||||||
|
.version "01.01"
|
||||||
|
gcc2_compiled.:
|
||||||
|
.globl __progname
|
||||||
|
.section .rodata
|
||||||
|
.LC0:
|
||||||
|
.ascii "\0"
|
||||||
|
.data
|
||||||
|
.align 4
|
||||||
|
.type __progname,@object
|
||||||
|
.size __progname,4
|
||||||
|
__progname:
|
||||||
|
.long .LC0
|
||||||
|
.globl __ps_strings
|
||||||
|
.align 4
|
||||||
|
.type __ps_strings,@object
|
||||||
|
.size __ps_strings,4
|
||||||
|
__ps_strings:
|
||||||
|
.long 0
|
||||||
|
.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
|
||||||
|
.weak _DYNAMIC
|
||||||
|
|
||||||
|
.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
|
||||||
|
movl %eax,U_SYSTEM_ARGC
|
||||||
|
movl %edx,U_SYSTEM_ARGV
|
||||||
|
call ___start
|
||||||
|
|
||||||
|
#NO_APP
|
||||||
|
.text
|
||||||
|
.align 4
|
||||||
|
.globl ___start
|
||||||
|
.type ___start,@function
|
||||||
|
___start:
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp,%ebp
|
||||||
|
pushl %edi
|
||||||
|
pushl %esi
|
||||||
|
pushl %ebx
|
||||||
|
call .L12
|
||||||
|
.L12:
|
||||||
|
popl %ebx
|
||||||
|
addl $_GLOBAL_OFFSET_TABLE_+[.-.L12],%ebx
|
||||||
|
movl 12(%ebp),%esi
|
||||||
|
movl 16(%ebp),%edx
|
||||||
|
movl 28(%ebp),%edi
|
||||||
|
movl environ@GOT(%ebx),%eax
|
||||||
|
movl %edx,(%eax)
|
||||||
|
movl %edx,U_SYSTEM_ENVP
|
||||||
|
movl __progname@GOT(%ebx),%edx
|
||||||
|
movl (%esi),%eax
|
||||||
|
movl %eax,(%edx)
|
||||||
|
testl %eax,%eax
|
||||||
|
je .L6
|
||||||
|
pushl $47
|
||||||
|
movl __progname@GOT(%ebx),%eax
|
||||||
|
pushl (%eax)
|
||||||
|
call _strrchr@PLT
|
||||||
|
movl %eax,%edx
|
||||||
|
movl __progname@GOT(%ebx),%eax
|
||||||
|
movl %edx,(%eax)
|
||||||
|
addl $8,%esp
|
||||||
|
testl %edx,%edx
|
||||||
|
jne .L7
|
||||||
|
movl __progname@GOT(%ebx),%edx
|
||||||
|
movl (%esi),%eax
|
||||||
|
movl %eax,(%edx)
|
||||||
|
jmp .L6
|
||||||
|
.align 4
|
||||||
|
.L7:
|
||||||
|
movl __progname@GOT(%ebx),%eax
|
||||||
|
incl %edx
|
||||||
|
movl %edx,(%eax)
|
||||||
|
.L6:
|
||||||
|
testl %edi,%edi
|
||||||
|
je .L9
|
||||||
|
movl __ps_strings@GOT(%ebx),%eax
|
||||||
|
movl %edi,(%eax)
|
||||||
|
.L9:
|
||||||
|
cmpl $0,_DYNAMIC@GOT(%ebx)
|
||||||
|
je .L10
|
||||||
|
pushl 24(%ebp)
|
||||||
|
pushl 20(%ebp)
|
||||||
|
call _rtld_setup@PLT
|
||||||
|
addl $8,%esp
|
||||||
|
.L10:
|
||||||
|
pushl _fini@GOT(%ebx)
|
||||||
|
call atexit@PLT
|
||||||
|
call _init@PLT
|
||||||
|
# movl environ@GOT(%ebx),%eax
|
||||||
|
# pushl (%eax)
|
||||||
|
# pushl %esi
|
||||||
|
# pushl 8(%ebp)
|
||||||
|
# call main@PLT
|
||||||
|
|
||||||
|
finit /* initialize fpu */
|
||||||
|
fwait
|
||||||
|
fldcw ___fpucw
|
||||||
|
|
||||||
|
// xorl %ebp,%ebp /* Detect main from nested */
|
||||||
|
/* procs/unwinding? */
|
||||||
|
pushl (%eax)
|
||||||
|
pushl (%esi)
|
||||||
|
pushl 8(%ebp)
|
||||||
|
call main
|
||||||
|
pushl %eax
|
||||||
|
pushl %eax
|
||||||
|
call exit@PLT
|
||||||
|
|
||||||
|
.p2align 2,0x90
|
||||||
|
.globl _haltproc
|
||||||
|
.type _haltproc,@function
|
||||||
|
|
||||||
|
_haltproc:
|
||||||
|
mov $1,%eax
|
||||||
|
movzwl U_SYSTEM_EXITCODE,%ebx
|
||||||
|
pushl %ebx
|
||||||
|
call _actualsyscall
|
||||||
|
addl $4,%esp
|
||||||
|
jmp _haltproc
|
||||||
|
|
||||||
|
_actualsyscall:
|
||||||
|
int $0x80
|
||||||
|
jb .LErrorcode
|
||||||
|
xor %ebx,%ebx
|
||||||
|
ret
|
||||||
|
.LErrorcode:
|
||||||
|
mov %eax,%ebx
|
||||||
|
mov $-1,%eax
|
||||||
|
ret
|
||||||
|
.p2align 2,0x90
|
||||||
|
|
||||||
|
|
||||||
|
.Lfe1:
|
||||||
|
.size ___start,.Lfe1-___start
|
||||||
|
.align 4
|
||||||
|
.type _strrchr,@function
|
||||||
|
_strrchr:
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp,%ebp
|
||||||
|
subl $4,%esp
|
||||||
|
pushl %esi
|
||||||
|
movl 8(%ebp),%eax
|
||||||
|
movb 12(%ebp),%cl
|
||||||
|
movb %cl,-1(%ebp)
|
||||||
|
xorl %esi,%esi
|
||||||
|
.align 4
|
||||||
|
.L14:
|
||||||
|
movb (%eax),%dl
|
||||||
|
cmpb -1(%ebp),%dl
|
||||||
|
jne .L17
|
||||||
|
movl %eax,%esi
|
||||||
|
.L17:
|
||||||
|
testb %dl,%dl
|
||||||
|
je .L16
|
||||||
|
incl %eax
|
||||||
|
jmp .L14
|
||||||
|
.align 4
|
||||||
|
.L16:
|
||||||
|
movl %esi,%eax
|
||||||
|
movl -8(%ebp),%esi
|
||||||
|
leave
|
||||||
|
ret
|
||||||
|
.Lfe2:
|
||||||
|
.size _strrchr,.Lfe2-_strrchr
|
||||||
|
.section .rodata
|
||||||
|
.align 32
|
||||||
|
.LC1:
|
||||||
|
.ascii "Corrupt Obj_Entry pointer in GOT\0"
|
||||||
|
.align 32
|
||||||
|
.LC2:
|
||||||
|
.ascii "Dynamic linker version mismatch\0"
|
||||||
|
.text
|
||||||
|
.align 4
|
||||||
|
.globl _rtld_setup
|
||||||
|
.type _rtld_setup,@function
|
||||||
|
_rtld_setup:
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp,%ebp
|
||||||
|
pushl %esi
|
||||||
|
pushl %ebx
|
||||||
|
call .L35
|
||||||
|
.L35:
|
||||||
|
popl %ebx
|
||||||
|
addl $_GLOBAL_OFFSET_TABLE_+[.-.L35],%ebx
|
||||||
|
movl 12(%ebp),%esi
|
||||||
|
testl %esi,%esi
|
||||||
|
je .L22
|
||||||
|
cmpl $-716130182,(%esi)
|
||||||
|
je .L21
|
||||||
|
.L22:
|
||||||
|
pushl $33
|
||||||
|
leal .LC1@GOTOFF(%ebx),%eax
|
||||||
|
pushl %eax
|
||||||
|
pushl $2
|
||||||
|
pushl $4
|
||||||
|
call __syscall@PLT
|
||||||
|
pushl $1
|
||||||
|
pushl $1
|
||||||
|
call __syscall@PLT
|
||||||
|
addl $24,%esp
|
||||||
|
.align 4
|
||||||
|
.L21:
|
||||||
|
cmpl $1,4(%esi)
|
||||||
|
je .L28
|
||||||
|
pushl $32
|
||||||
|
leal .LC2@GOTOFF(%ebx),%eax
|
||||||
|
pushl %eax
|
||||||
|
pushl $2
|
||||||
|
pushl $4
|
||||||
|
call __syscall@PLT
|
||||||
|
pushl $1
|
||||||
|
pushl $1
|
||||||
|
call __syscall@PLT
|
||||||
|
addl $24,%esp
|
||||||
|
.align 4
|
||||||
|
.L28:
|
||||||
|
pushl 8(%ebp)
|
||||||
|
call atexit@PLT
|
||||||
|
leal -8(%ebp),%esp
|
||||||
|
popl %ebx
|
||||||
|
popl %esi
|
||||||
|
leave
|
||||||
|
ret
|
||||||
|
.Lfe3:
|
||||||
|
.size _rtld_setup,.Lfe3-_rtld_setup
|
||||||
|
#APP
|
||||||
|
.weak dlopen ; dlopen = _dlopen
|
||||||
|
.weak dlclose ; dlclose = _dlclose
|
||||||
|
.weak dlsym ; dlsym = _dlsym
|
||||||
|
.weak dlerror ; dlerror = _dlerror
|
||||||
|
.weak dladdr ; dladdr = _dladdr
|
||||||
|
#NO_APP
|
||||||
|
.align 4
|
||||||
|
.globl _dlopen
|
||||||
|
.type _dlopen,@function
|
||||||
|
_dlopen:
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp,%ebp
|
||||||
|
pushl %ebx
|
||||||
|
call .L40
|
||||||
|
.L40:
|
||||||
|
popl %ebx
|
||||||
|
addl $_GLOBAL_OFFSET_TABLE_+[.-.L40],%ebx
|
||||||
|
movl __mainprog_obj@GOT(%ebx),%eax
|
||||||
|
movl (%eax),%eax
|
||||||
|
testl %eax,%eax
|
||||||
|
je .L37
|
||||||
|
pushl 12(%ebp)
|
||||||
|
pushl 8(%ebp)
|
||||||
|
movl 80(%eax),%eax
|
||||||
|
call *%eax
|
||||||
|
jmp .L38
|
||||||
|
.align 4
|
||||||
|
.L37:
|
||||||
|
xorl %eax,%eax
|
||||||
|
.L38:
|
||||||
|
movl -4(%ebp),%ebx
|
||||||
|
leave
|
||||||
|
ret
|
||||||
|
.Lfe4:
|
||||||
|
.size _dlopen,.Lfe4-_dlopen
|
||||||
|
.align 4
|
||||||
|
.globl _dlclose
|
||||||
|
.type _dlclose,@function
|
||||||
|
_dlclose:
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp,%ebp
|
||||||
|
pushl %ebx
|
||||||
|
call .L45
|
||||||
|
.L45:
|
||||||
|
popl %ebx
|
||||||
|
addl $_GLOBAL_OFFSET_TABLE_+[.-.L45],%ebx
|
||||||
|
movl __mainprog_obj@GOT(%ebx),%eax
|
||||||
|
movl (%eax),%eax
|
||||||
|
testl %eax,%eax
|
||||||
|
je .L42
|
||||||
|
pushl 8(%ebp)
|
||||||
|
movl 92(%eax),%eax
|
||||||
|
call *%eax
|
||||||
|
jmp .L43
|
||||||
|
.align 4
|
||||||
|
.L42:
|
||||||
|
movl $-1,%eax
|
||||||
|
.L43:
|
||||||
|
movl -4(%ebp),%ebx
|
||||||
|
leave
|
||||||
|
ret
|
||||||
|
.Lfe5:
|
||||||
|
.size _dlclose,.Lfe5-_dlclose
|
||||||
|
.align 4
|
||||||
|
.globl _dlsym
|
||||||
|
.type _dlsym,@function
|
||||||
|
_dlsym:
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp,%ebp
|
||||||
|
pushl %ebx
|
||||||
|
call .L50
|
||||||
|
.L50:
|
||||||
|
popl %ebx
|
||||||
|
addl $_GLOBAL_OFFSET_TABLE_+[.-.L50],%ebx
|
||||||
|
movl __mainprog_obj@GOT(%ebx),%eax
|
||||||
|
movl (%eax),%eax
|
||||||
|
testl %eax,%eax
|
||||||
|
je .L47
|
||||||
|
pushl 12(%ebp)
|
||||||
|
pushl 8(%ebp)
|
||||||
|
movl 84(%eax),%eax
|
||||||
|
call *%eax
|
||||||
|
jmp .L48
|
||||||
|
.align 4
|
||||||
|
.L47:
|
||||||
|
xorl %eax,%eax
|
||||||
|
.L48:
|
||||||
|
movl -4(%ebp),%ebx
|
||||||
|
leave
|
||||||
|
ret
|
||||||
|
.Lfe6:
|
||||||
|
.size _dlsym,.Lfe6-_dlsym
|
||||||
|
.section .rodata
|
||||||
|
.align 32
|
||||||
|
.LC3:
|
||||||
|
.ascii "Dynamic linker interface not available\0"
|
||||||
|
.text
|
||||||
|
.align 4
|
||||||
|
.globl _dlerror
|
||||||
|
.type _dlerror,@function
|
||||||
|
_dlerror:
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp,%ebp
|
||||||
|
pushl %ebx
|
||||||
|
call .L55
|
||||||
|
.L55:
|
||||||
|
popl %ebx
|
||||||
|
addl $_GLOBAL_OFFSET_TABLE_+[.-.L55],%ebx
|
||||||
|
movl __mainprog_obj@GOT(%ebx),%eax
|
||||||
|
movl (%eax),%eax
|
||||||
|
testl %eax,%eax
|
||||||
|
je .L52
|
||||||
|
movl 88(%eax),%eax
|
||||||
|
call *%eax
|
||||||
|
jmp .L53
|
||||||
|
.align 4
|
||||||
|
.L52:
|
||||||
|
leal .LC3@GOTOFF(%ebx),%eax
|
||||||
|
.L53:
|
||||||
|
movl -4(%ebp),%ebx
|
||||||
|
leave
|
||||||
|
ret
|
||||||
|
.Lfe7:
|
||||||
|
.size _dlerror,.Lfe7-_dlerror
|
||||||
|
.align 4
|
||||||
|
.globl _dladdr
|
||||||
|
.type _dladdr,@function
|
||||||
|
_dladdr:
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp,%ebp
|
||||||
|
pushl %ebx
|
||||||
|
call .L60
|
||||||
|
.L60:
|
||||||
|
popl %ebx
|
||||||
|
addl $_GLOBAL_OFFSET_TABLE_+[.-.L60],%ebx
|
||||||
|
movl __mainprog_obj@GOT(%ebx),%eax
|
||||||
|
movl (%eax),%eax
|
||||||
|
testl %eax,%eax
|
||||||
|
je .L57
|
||||||
|
pushl 12(%ebp)
|
||||||
|
pushl 8(%ebp)
|
||||||
|
movl 96(%eax),%eax
|
||||||
|
call *%eax
|
||||||
|
jmp .L58
|
||||||
|
.align 4
|
||||||
|
.L57:
|
||||||
|
movl $-1,%eax
|
||||||
|
.L58:
|
||||||
|
movl -4(%ebp),%ebx
|
||||||
|
leave
|
||||||
|
ret
|
||||||
|
.Lfe8:
|
||||||
|
.size _dladdr,.Lfe8-_dladdr
|
||||||
|
.comm environ,4,4
|
||||||
|
.comm __mainprog_obj,4,4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# This section is needed for NetBSD to recognize a NetBSD binary as such.
|
||||||
|
# otherwise it will be startup in Linux emulation mode.
|
||||||
|
|
||||||
|
.section ".note.netbsd.ident","a"
|
||||||
|
.p2align 2
|
||||||
|
|
||||||
|
.long 7
|
||||||
|
.long 4
|
||||||
|
# ELF NOTE TYPE NETBSD TAG
|
||||||
|
.long 1
|
||||||
|
.ascii "NetBSD\0\0"
|
||||||
|
.long 199905
|
204
rtl/netbsd/i386/prt0.as
Normal file
204
rtl/netbsd/i386/prt0.as
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
# This file is part of the Free Pascal run time library.
|
||||||
|
# Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
|
||||||
|
# and Peter Vreman
|
||||||
|
# members 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.
|
||||||
|
#
|
||||||
|
#**********************************************************************}
|
||||||
|
#
|
||||||
|
# NetBSD standard (static) ELF/i386 startup code for Free Pascal
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
.file "prt0.s"
|
||||||
|
.version "01.01"
|
||||||
|
gcc2_compiled.:
|
||||||
|
.globl __progname
|
||||||
|
|
||||||
|
.section .rodata
|
||||||
|
.LC0:
|
||||||
|
.ascii "\0"
|
||||||
|
.data
|
||||||
|
.align 4
|
||||||
|
.type __progname,@object
|
||||||
|
.size __progname,4
|
||||||
|
__progname:
|
||||||
|
.long .LC0
|
||||||
|
.globl __ps_strings
|
||||||
|
.align 4
|
||||||
|
.type __ps_strings,@object
|
||||||
|
.size __ps_strings,4
|
||||||
|
__ps_strings:
|
||||||
|
.long 0
|
||||||
|
.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
|
||||||
|
movl 16(%ebp),%eax
|
||||||
|
movl %eax,environ
|
||||||
|
movl %eax,U_SYSTEM_ENVP
|
||||||
|
movl 8(%ebp),%eax
|
||||||
|
movl %eax,U_SYSTEM_ARGC
|
||||||
|
movl 12(%ebp),%eax
|
||||||
|
movl %eax,U_SYSTEM_ARGV
|
||||||
|
movl (%eax),%edx
|
||||||
|
movl %edx,__progname
|
||||||
|
testl %edx,%edx
|
||||||
|
je .L2
|
||||||
|
pushl $47
|
||||||
|
movl __progname,%eax
|
||||||
|
pushl %eax
|
||||||
|
call _strrchr
|
||||||
|
addl $8,%esp
|
||||||
|
movl %eax,%eax
|
||||||
|
movl %eax,__progname
|
||||||
|
cmpl $0,__progname
|
||||||
|
jne .L3
|
||||||
|
movl 12(%ebp),%eax
|
||||||
|
movl (%eax),%edx
|
||||||
|
movl %edx,__progname
|
||||||
|
jmp .L2
|
||||||
|
.align 4
|
||||||
|
.L3:
|
||||||
|
incl __progname
|
||||||
|
.L4:
|
||||||
|
.L2:
|
||||||
|
cmpl $0,28(%ebp)
|
||||||
|
je .L5
|
||||||
|
movl 28(%ebp),%eax
|
||||||
|
movl %eax,__ps_strings
|
||||||
|
.L5:
|
||||||
|
# pushl $_fini
|
||||||
|
# call atexit
|
||||||
|
# addl $4,%esp
|
||||||
|
# call _init
|
||||||
|
# copied from linux
|
||||||
|
|
||||||
|
finit /* initialize fpu */
|
||||||
|
fwait
|
||||||
|
fldcw ___fpucw
|
||||||
|
|
||||||
|
xorl %ebp,%ebp
|
||||||
|
|
||||||
|
call _main
|
||||||
|
pushl %eax
|
||||||
|
jmp _haltproc
|
||||||
|
|
||||||
|
.p2align 2,0x90
|
||||||
|
.globl _haltproc
|
||||||
|
.type _haltproc,@function
|
||||||
|
|
||||||
|
_haltproc:
|
||||||
|
mov $1,%eax
|
||||||
|
movzwl U_SYSTEM_EXITCODE,%ebx
|
||||||
|
pushl %ebx
|
||||||
|
call _actualsyscall
|
||||||
|
addl $4,%esp
|
||||||
|
jmp _haltproc
|
||||||
|
|
||||||
|
_actualsyscall:
|
||||||
|
int $0x80
|
||||||
|
jb .LErrorcode
|
||||||
|
xor %ebx,%ebx
|
||||||
|
ret
|
||||||
|
.LErrorcode:
|
||||||
|
mov %eax,%ebx
|
||||||
|
mov $-1,%eax
|
||||||
|
ret
|
||||||
|
.p2align 2,0x90
|
||||||
|
|
||||||
|
.Lfe1:
|
||||||
|
.size ___start,.Lfe1-___start
|
||||||
|
.align 4
|
||||||
|
.type _strrchr,@function
|
||||||
|
_strrchr:
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp,%ebp
|
||||||
|
subl $8,%esp
|
||||||
|
movl 12(%ebp),%eax
|
||||||
|
movb %al,-1(%ebp)
|
||||||
|
movl $0,-8(%ebp)
|
||||||
|
.align 4
|
||||||
|
.L7:
|
||||||
|
movl 8(%ebp),%eax
|
||||||
|
movb (%eax),%dl
|
||||||
|
cmpb -1(%ebp),%dl
|
||||||
|
jne .L10
|
||||||
|
movl 8(%ebp),%eax
|
||||||
|
movl %eax,-8(%ebp)
|
||||||
|
.L10:
|
||||||
|
movl 8(%ebp),%eax
|
||||||
|
cmpb $0,(%eax)
|
||||||
|
jne .L9
|
||||||
|
movl -8(%ebp),%edx
|
||||||
|
movl %edx,%eax
|
||||||
|
jmp .L6
|
||||||
|
.align 4
|
||||||
|
.L11:
|
||||||
|
.L9:
|
||||||
|
incl 8(%ebp)
|
||||||
|
jmp .L7
|
||||||
|
.align 4
|
||||||
|
.L8:
|
||||||
|
.L6:
|
||||||
|
leave
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
.Lfe2:
|
||||||
|
.size _strrchr,.Lfe2-_strrchr
|
||||||
|
.comm environ,4,4
|
||||||
|
|
||||||
|
# This section is needed for NetBSD to recognize a NetBSD binary as such.
|
||||||
|
# otherwise it will be startup in Linux emulation mode.
|
||||||
|
|
||||||
|
.section ".note.netbsd.ident","a"
|
||||||
|
.p2align 2
|
||||||
|
|
||||||
|
.long 7
|
||||||
|
.long 4
|
||||||
|
# ELF NOTE TYPE NETBSD TAG
|
||||||
|
.long 1
|
||||||
|
.ascii "NetBSD\0\0"
|
||||||
|
.long 199905
|
204
rtl/netbsd/i386/prt0_10.as
Normal file
204
rtl/netbsd/i386/prt0_10.as
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
# This file is part of the Free Pascal run time library.
|
||||||
|
# Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
|
||||||
|
# and Peter Vreman
|
||||||
|
# members 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.
|
||||||
|
#
|
||||||
|
#**********************************************************************}
|
||||||
|
#
|
||||||
|
# NetBSD standard (static) ELF/i386 startup code for Free Pascal
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
.file "prt0.s"
|
||||||
|
.version "01.01"
|
||||||
|
gcc2_compiled.:
|
||||||
|
.globl __progname
|
||||||
|
|
||||||
|
.section .rodata
|
||||||
|
.LC0:
|
||||||
|
.ascii "\0"
|
||||||
|
.data
|
||||||
|
.align 4
|
||||||
|
.type __progname,@object
|
||||||
|
.size __progname,4
|
||||||
|
__progname:
|
||||||
|
.long .LC0
|
||||||
|
.globl __ps_strings
|
||||||
|
.align 4
|
||||||
|
.type __ps_strings,@object
|
||||||
|
.size __ps_strings,4
|
||||||
|
__ps_strings:
|
||||||
|
.long 0
|
||||||
|
.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
|
||||||
|
movl 16(%ebp),%eax
|
||||||
|
movl %eax,environ
|
||||||
|
movl %eax,U_SYSBSD_ENVP
|
||||||
|
movl 8(%ebp),%eax
|
||||||
|
movl %eax,U_SYSBSD_ARGC
|
||||||
|
movl 12(%ebp),%eax
|
||||||
|
movl %eax,U_SYSBSD_ARGV
|
||||||
|
movl (%eax),%edx
|
||||||
|
movl %edx,__progname
|
||||||
|
testl %edx,%edx
|
||||||
|
je .L2
|
||||||
|
pushl $47
|
||||||
|
movl __progname,%eax
|
||||||
|
pushl %eax
|
||||||
|
call _strrchr
|
||||||
|
addl $8,%esp
|
||||||
|
movl %eax,%eax
|
||||||
|
movl %eax,__progname
|
||||||
|
cmpl $0,__progname
|
||||||
|
jne .L3
|
||||||
|
movl 12(%ebp),%eax
|
||||||
|
movl (%eax),%edx
|
||||||
|
movl %edx,__progname
|
||||||
|
jmp .L2
|
||||||
|
.align 4
|
||||||
|
.L3:
|
||||||
|
incl __progname
|
||||||
|
.L4:
|
||||||
|
.L2:
|
||||||
|
cmpl $0,28(%ebp)
|
||||||
|
je .L5
|
||||||
|
movl 28(%ebp),%eax
|
||||||
|
movl %eax,__ps_strings
|
||||||
|
.L5:
|
||||||
|
# pushl $_fini
|
||||||
|
# call atexit
|
||||||
|
# addl $4,%esp
|
||||||
|
# call _init
|
||||||
|
# copied from linux
|
||||||
|
|
||||||
|
finit /* initialize fpu */
|
||||||
|
fwait
|
||||||
|
fldcw ___fpucw
|
||||||
|
|
||||||
|
xorl %ebp,%ebp
|
||||||
|
|
||||||
|
call main
|
||||||
|
pushl %eax
|
||||||
|
jmp _haltproc
|
||||||
|
|
||||||
|
.p2align 2,0x90
|
||||||
|
.globl _haltproc
|
||||||
|
.type _haltproc,@function
|
||||||
|
|
||||||
|
_haltproc:
|
||||||
|
mov $1,%eax
|
||||||
|
movzwl U_SYSBSD_EXITCODE,%ebx
|
||||||
|
pushl %ebx
|
||||||
|
call _actualsyscall
|
||||||
|
addl $4,%esp
|
||||||
|
jmp _haltproc
|
||||||
|
|
||||||
|
_actualsyscall:
|
||||||
|
int $0x80
|
||||||
|
jb .LErrorcode
|
||||||
|
xor %ebx,%ebx
|
||||||
|
ret
|
||||||
|
.LErrorcode:
|
||||||
|
mov %eax,%ebx
|
||||||
|
mov $-1,%eax
|
||||||
|
ret
|
||||||
|
.p2align 2,0x90
|
||||||
|
|
||||||
|
.Lfe1:
|
||||||
|
.size ___start,.Lfe1-___start
|
||||||
|
.align 4
|
||||||
|
.type _strrchr,@function
|
||||||
|
_strrchr:
|
||||||
|
pushl %ebp
|
||||||
|
movl %esp,%ebp
|
||||||
|
subl $8,%esp
|
||||||
|
movl 12(%ebp),%eax
|
||||||
|
movb %al,-1(%ebp)
|
||||||
|
movl $0,-8(%ebp)
|
||||||
|
.align 4
|
||||||
|
.L7:
|
||||||
|
movl 8(%ebp),%eax
|
||||||
|
movb (%eax),%dl
|
||||||
|
cmpb -1(%ebp),%dl
|
||||||
|
jne .L10
|
||||||
|
movl 8(%ebp),%eax
|
||||||
|
movl %eax,-8(%ebp)
|
||||||
|
.L10:
|
||||||
|
movl 8(%ebp),%eax
|
||||||
|
cmpb $0,(%eax)
|
||||||
|
jne .L9
|
||||||
|
movl -8(%ebp),%edx
|
||||||
|
movl %edx,%eax
|
||||||
|
jmp .L6
|
||||||
|
.align 4
|
||||||
|
.L11:
|
||||||
|
.L9:
|
||||||
|
incl 8(%ebp)
|
||||||
|
jmp .L7
|
||||||
|
.align 4
|
||||||
|
.L8:
|
||||||
|
.L6:
|
||||||
|
leave
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
.Lfe2:
|
||||||
|
.size _strrchr,.Lfe2-_strrchr
|
||||||
|
.comm environ,4,4
|
||||||
|
|
||||||
|
# This section is needed for NetBSD to recognize a NetBSD binary as such.
|
||||||
|
# otherwise it will be startup in Linux emulation mode.
|
||||||
|
|
||||||
|
.section ".note.netbsd.ident","a"
|
||||||
|
.p2align 2
|
||||||
|
|
||||||
|
.long 7
|
||||||
|
.long 4
|
||||||
|
# ELF NOTE TYPE NETBSD TAG
|
||||||
|
.long 1
|
||||||
|
.ascii "NetBSD\0\0"
|
||||||
|
.long 199905
|
53
rtl/netbsd/termio.pp
Normal file
53
rtl/netbsd/termio.pp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
$Id$
|
||||||
|
This file is part of the Free Pascal run time library.
|
||||||
|
Copyright (c) 1999-2000 by Peter Vreman
|
||||||
|
member of the Free Pascal development team.
|
||||||
|
|
||||||
|
See the file COPYING.FPC, included in this distribution,
|
||||||
|
for details about the copyright.
|
||||||
|
|
||||||
|
This file contains the termios interface.
|
||||||
|
|
||||||
|
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 termio;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
Uses BaseUnix; // load base unix typing
|
||||||
|
|
||||||
|
// load types + consts
|
||||||
|
|
||||||
|
{$i termios.inc}
|
||||||
|
|
||||||
|
// load default prototypes from unix dir.
|
||||||
|
|
||||||
|
{$i termiosh.inc}
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$i textrec.inc}
|
||||||
|
|
||||||
|
// load implementation for prototypes from current dir.
|
||||||
|
{$i termiosproc.inc}
|
||||||
|
|
||||||
|
// load ttyname from unix dir.
|
||||||
|
{$i ttyname.inc}
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
||||||
|
{
|
||||||
|
$Log$
|
||||||
|
Revision 1.1 2004-01-04 01:13:23 marco
|
||||||
|
* first 1.1 netbsd rtl, basically freebsd copy and paste with 1.0.10 netbsd structures
|
||||||
|
|
||||||
|
Revision 1.1 2003/11/19 17:15:31 marco
|
||||||
|
* termio new includefile
|
||||||
|
|
||||||
|
|
||||||
|
}
|
147
rtl/netbsd/termiosproc.inc
Normal file
147
rtl/netbsd/termiosproc.inc
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
{
|
||||||
|
$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.
|
||||||
|
|
||||||
|
Termios implementation for FreeBSD
|
||||||
|
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{******************************************************************************
|
||||||
|
IOCtl and Termios calls
|
||||||
|
******************************************************************************}
|
||||||
|
|
||||||
|
Function TCGetAttr(fd:cint;var tios:TermIOS):cint;
|
||||||
|
begin
|
||||||
|
TCGETAttr:=fpIoCtl(Fd,TIOCGETA,@tios);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Function TCSetAttr(fd:cint;OptAct:cint;const tios:TermIOS):cint;
|
||||||
|
var
|
||||||
|
nr:cint;
|
||||||
|
begin
|
||||||
|
case OptAct of
|
||||||
|
TCSANOW : nr:=TIOCSETA;
|
||||||
|
TCSADRAIN : nr:=TIOCSETAW;
|
||||||
|
TCSAFLUSH : nr:=TIOCSETAF;
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
fpsetErrNo(ESysEINVAL);
|
||||||
|
TCSetAttr:=-1;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
TCSetAttr:=fpIOCtl(fd,nr,@Tios);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Procedure CFSetISpeed(var tios:TermIOS;speed:Cardinal);
|
||||||
|
begin
|
||||||
|
tios.c_ispeed:=speed; {Probably the Bxxxx speed constants}
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Procedure CFSetOSpeed(var tios:TermIOS;speed:Cardinal);
|
||||||
|
begin
|
||||||
|
tios.c_ospeed:=speed;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Procedure CFMakeRaw(var tios:TermIOS);
|
||||||
|
begin
|
||||||
|
with tios do
|
||||||
|
begin
|
||||||
|
c_iflag:=c_iflag and (not (IMAXBEL or IXOFF or INPCK or BRKINT or
|
||||||
|
PARMRK or ISTRIP or INLCR or IGNCR or ICRNL or IXON or
|
||||||
|
IGNPAR));
|
||||||
|
c_iflag:=c_iflag OR IGNBRK;
|
||||||
|
c_oflag:=c_oflag and (not OPOST);
|
||||||
|
c_lflag:=c_lflag and (not (ECHO or ECHOE or ECHOK or ECHONL or ICANON or
|
||||||
|
ISIG or IEXTEN or NOFLSH or TOSTOP or PENDIN));
|
||||||
|
c_cflag:=(c_cflag and (not (CSIZE or PARENB))) or (CS8 OR cread);
|
||||||
|
c_cc[VMIN]:=1;
|
||||||
|
c_cc[VTIME]:=0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TCSendBreak(fd,duration:cint):cint;
|
||||||
|
begin
|
||||||
|
TCSendBreak:=fpIOCtl(fd,TIOCSBRK,nil);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Function TCSetPGrp(fd,id:cint):cint;
|
||||||
|
begin
|
||||||
|
TCSetPGrp:=fpIOCtl(fd,TIOCSPGRP,pointer(id));
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Function TCGetPGrp(fd:cint;var id:cint):cint;
|
||||||
|
begin
|
||||||
|
TCGetPGrp:=fpIOCtl(fd,TIOCGPGRP,@id);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TCDrain(fd:cint):cint;
|
||||||
|
begin
|
||||||
|
TCDrain:=fpIOCtl(fd,TIOCDRAIN,nil); {Should set timeout to 1 first?}
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Function TCFlow(fd,act:cint):cint;
|
||||||
|
begin
|
||||||
|
case act OF
|
||||||
|
TCOOFF : TCFlow:=fpIoctl(fd,TIOCSTOP,nil);
|
||||||
|
TCOOn : TCFlow:=fpIOctl(Fd,TIOCStart,nil);
|
||||||
|
TCIOFF : {N/I}
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TCFlush(fd,qsel:cint):cint;
|
||||||
|
begin
|
||||||
|
TCFlush:=fpIOCtl(fd,TIOCFLUSH,pointer(qsel));
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function IsATTY (Handle:cint):cint;
|
||||||
|
{
|
||||||
|
Check if the filehandle described by 'handle' is a TTY (Terminal)
|
||||||
|
}
|
||||||
|
var
|
||||||
|
t : Termios;
|
||||||
|
begin
|
||||||
|
IsAtty:=TCGetAttr(Handle,t);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Function IsATTY(var f: text):cint;
|
||||||
|
{
|
||||||
|
Idem as previous, only now for text variables.
|
||||||
|
}
|
||||||
|
begin
|
||||||
|
IsATTY:=IsaTTY(textrec(f).handle);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
|
$Log$
|
||||||
|
Revision 1.1 2004-01-04 01:13:23 marco
|
||||||
|
* first 1.1 netbsd rtl, basically freebsd copy and paste with 1.0.10 netbsd structures
|
||||||
|
|
||||||
|
Revision 1.3 2004/01/03 12:18:29 marco
|
||||||
|
* a lot of copyright notices and CVS logs added and fixed
|
||||||
|
|
||||||
|
Revision 1.2 2003/12/16 19:43:53 marco
|
||||||
|
* nil <-> 0 changes
|
||||||
|
|
||||||
|
Revision 1.1 2003/11/19 17:15:31 marco
|
||||||
|
* termio new includefile
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user