1# 2# $Id: prt0.as,v 1.4 2004/07/03 21:50:30 daniel Exp $ 3# This file is part of the Free Pascal run time library. 4# Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt 5# and Peter Vreman 6# members of the Free Pascal development team. 7# 8# See the file COPYING.FPC, included in this distribution, 9# for details about the copyright. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY;without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14# 15#**********************************************************************} 16# 17# FreeBSD standard (static) ELF startup code for Free Pascal 18# 19 20 .file "prt1.as" 21 22gcc2_compiled.: 23.section .rodata 24.LC0: 25 .ascii "\0" 26.data 27 .p2align 2 28 .globl __progname 29 .type __progname,@object 30 .size __progname,4 31__progname: 32 .long .LC0 33 .align 4 34 .type __fpucw,@object 35 .size __fpucw,4 36 .global __fpucw 37___fpucw: 38 .long 0x1332 39 40 .globl ___fpc_brk_addr /* heap management */ 41 .type ___fpc_brk_addr,@object 42 .size ___fpc_brk_addr,4 43___fpc_brk_addr: 44 .long 0 45 46.text 47 .p2align 2 48.globl _start 49 .type _start,@function 50_start: 51 pushl %ebp 52 movl %esp,%ebp 53 pushl %edi 54 pushl %esi 55 pushl %ebx 56#APP 57 movl %edx,%edx 58#NO_APP 59 leal 8(%ebp),%edi 60 movl %edi,operatingsystem_parameter_argv 61 mov -4(%edi),%eax 62 movl %eax,operatingsystem_parameter_argc 63 movl 4(%ebp),%ebx 64 leal 12(%ebp,%ebx,4),%esi 65 movl %esi,operatingsystem_parameter_envp 66 movl %esi,environ 67 testl %ebx,%ebx 68 jle .L2 69 movl 8(%ebp),%eax 70 testl %eax,%eax 71 je .L2 72 movl %eax,__progname 73 cmpb $0,(%eax) 74 je .L2 75 .p2align 2,0x90 76.L6: 77 cmpb $47,(%eax) 78 jne .L5 79 leal 1(%eax),%ecx 80 movl %ecx,__progname 81.L5: 82 incl %eax 83 cmpb $0,(%eax) 84 jne .L6 85.L2: 86.L9: 87 88# copied from linux 89 90 finit /* initialize fpu */ 91 fwait 92 fldcw ___fpucw 93 94 xorl %ebp,%ebp 95 96 call main 97 pushl %eax 98 jmp _haltproc 99 100.p2align 2,0x90 101.globl _haltproc 102.type _haltproc,@function 103 104_haltproc: 105 mov $1,%eax 106 movzwl operatingsystem_result,%ebx 107 pushl %ebx 108 call _actualsyscall 109 addl $4,%esp 110 jmp _haltproc 111 112_actualsyscall: 113 int $0x80 114 jb .LErrorcode 115 xor %ebx,%ebx 116 ret 117.LErrorcode: 118 mov %eax,%ebx 119 mov $-1,%eax 120 ret 121 .p2align 2,0x90 122.Lfe1: 123 .size _start,.Lfe1-_start 124 .comm environ,4,4 125 .weak _DYNAMIC 126 .ident "GCC: (GNU) 2.7.2.1" 127 128 129.bss 130 .type __stkptr,@object 131 .size __stkptr,4 132 .global __stkptr 133__stkptr: 134 .skip 4 135 136 .type operatingsystem_parameters,@object 137 .size operatingsystem_parameters,12 138operatingsystem_parameters: 139 .skip 3*4 140 141 .global operatingsystem_parameter_envp 142 .global operatingsystem_parameter_argc 143 .global operatingsystem_parameter_argv 144 .set operatingsystem_parameter_envp,operatingsystem_parameters+0 145 .set operatingsystem_parameter_argc,operatingsystem_parameters+4 146 .set operatingsystem_parameter_argv,operatingsystem_parameters+8 147 148//.section .threadvar,"aw",@nobits 149 .comm ___fpc_threadvar_offset,4 150 151.section .note.GNU-stack,"",@progbits 152