1 /* Startup code compliant to the 64 bit S/390 ELF ABI.
2 Copyright (C) 2001 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library 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. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 This is the canonical entry point, usually the first thing in the text
23 segment. Most registers' values are unspecified, except for:
25 %r14 Contains a function pointer to be registered with `atexit'.
26 This is how the dynamic linker arranges to have DT_FINI
27 functions called for shared libraries that have been loaded
28 before this code runs.
30 %r15 The stack contains the arguments and environment:
35 (8*(argc+1))(%r15) envp[0]
42 .type _start,@function
44 /* Load argc and argv from stack. */
45 la %r4,8(%r15) # get argv
46 lg %r3,0(%r15) # get argc
48 /* Align the stack to a double word boundary. */
52 /* Setup a stack frame and a parameter area. */
53 aghi %r15,-176 # make room on stack
54 xc 0(8,%r15),0(%r15) # clear back-chain
56 /* Set up arguments for __libc_start_main:
57 main, argc, argv, envp, _init, _fini, rtld_fini, stack_end
58 Note that envp will be determined later in __libc_start_main.
60 stmg %r14,%r15,160(%r15) # store rtld_fini/stack_end to parameter area
62 larl %r6,_fini # load pointer to _fini
63 larl %r5,_init # load pointer to _init
64 larl %r2,main # load pointer to main
66 /* Ok, now branch to the libc main routine. */
67 brasl %r14,__libc_start_main
69 /* Crash if __libc_start_main returns. */
72 /* FIXME: FPU flags or what ?!? */
79 /* Define a symbol for the first piece of initialized data. */
85 data_start = __data_start