1 /* Startup code compliant to the ELF s390 ABI.
2 Copyright (C) 2000, 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 (4*(argc+1))(%r15) envp[0]
44 /* Setup pointer to literal pool of _start */
46 .L0: ahi %r13,.Llit-.L0
48 /* load argc and argv from stack */
49 la %r4,4(%r15) # get argv
50 l %r3,0(%r15) # get argc
52 /* align the stack to a double word boundary */
56 /* Setup a stack frame and a parameter area */
57 ahi %r15,-104 # make room on stack
58 xc 0(4,%r15),0(%r15) # clear back-chain
60 /* set up arguments for __libc_start_main:
61 main, argc, argv, envp, _init, _fini, rtld_fini, stack_end
62 Note that envp will be determined later in __libc_start_main
64 stm %r14,%r15,96(%r15) # store rtld_fini/stack_end to parameter area
66 l %r6,.L2-.Llit(%r13) # load pointer to _fini
67 l %r5,.L1-.Llit(%r13) # load pointer to _init
68 l %r2,.L3-.Llit(%r13) # load pointer to main
70 /* ok, now branch to the libc main routine */
74 /* crash if __libc_start_main returns */
81 .L4: .long __libc_start_main
83 /* FIXME: FPU flags or what ?!? */
90 /* Define a symbol for the first piece of initialized data. */
96 data_start = __data_start