2
# This file is part of the Free Pascal run time library.
3
# Copyright (c) 2002 by Florian Klaempfl
4
# 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
#**********************************************************************}
15
# Linux ELF startup code for Free Pascal
18
/* This is the canonical entry point, usually the first thing in the text
19
segment. The SVR4/i386 ABI (pages 3-31, 3-32) says that when the entry
20
point runs, most registers' values are unspecified, except for:
22
%rdx Contains a function pointer to be registered with `atexit'.
23
This is how the dynamic linker arranges to have DT_FINI
24
functions called for shared libraries that have been loaded
25
before this code runs.
27
%rsp The stack contains the arguments and environment:
32
(8*(argc+1))(%rsp) envp[0]
39
.type _start,@function
41
# movq %rdx,%r9 /* Address of the shared library termination
43
popq %rsi /* Pop the argument count. */
44
movq %rsi,operatingsystem_parameter_argc
45
movq %rsp,operatingsystem_parameter_argv /* argv starts just at the current stack top. */
48
movq %rax,operatingsystem_parameter_envp
49
andq $~15,%rsp /* Align the stack to a 16 byte boundary to follow the ABI. */
51
/* Save initial stackpointer */
59
.type _haltproc,@function
61
movl $231,%eax /* exit_group call */
62
movzwl operatingsystem_result,%edi
66
/* Define a symbol for the first piece of initialized data. */
72
data_start = __data_start
77
.comm operatingsystem_parameter_envp,8
78
.comm operatingsystem_parameter_argc,8
79
.comm operatingsystem_parameter_argv,8
82
/* We need this stuff to make gdb behave itself, otherwise
83
gdb will chokes with SIGILL when trying to debug apps.
85
.section ".note.ABI-tag", "a"
96
.section .note.GNU-stack,"",@progbits