2
This file is part of the Free Pascal run time library.
3
Copyright (c) 2005 by Michael Van Canneyt, Peter Vreman,
4
& Daniel Mantione, members of the Free Pascal development team.
6
See the file COPYING.FPC, included in this distribution,
7
for details about the copyright.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
**********************************************************************}
16
Linux ELF startup code for Free Pascal
19
Stack layout at program start:
24
.... ENVIRONMENT VARIABLES
30
.... COMMAND LINE OPTIONS
36
procedure PASCALMAIN; external name 'PASCALMAIN';
38
{******************************************************************************
39
Shared library start/halt
40
******************************************************************************}
42
procedure _FPC_shared_lib_start(argc : dword;argv,envp : pointer); cdecl; public name '_start';
44
{ we've to discuss about the use of this ;) }
46
{ Save initial stackpointer }
47
movl %esp,initialstkptr
50
operatingsystem_parameter_argc:=argc; { Copy the argument count }
51
operatingsystem_parameter_argv:=argv; { Copy the argument pointer }
52
operatingsystem_parameter_envp:=envp; { Copy the environment pointer }
60
procedure initdummy; assembler; nostackframe;
67
// .type FPC_LIB_START,@function
70
jmp _FPC_shared_lib_start@PLT
72
jmp _FPC_shared_lib_start
78
procedure _FPC_shared_lib_haltproc; assembler; nostackframe; public name '_haltproc';
82
addl $_GLOBAL_OFFSET_TABLE_,%ebx
86
incl %eax { eax=1, exit call }
89
movl ExitCode@GOT(%ebx),%ebx
90
{$if sizeof(ExitCode)=2}