Update.
[glibc.git] / sysdeps / s390 / s390-32 / elf / start.S
blob104f68096a02941ce9af9a49f3269d81ef84b015
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:
31                 0(%r15)                 argc
32                 4(%r15)                 argv[0]
33                 ...
34                 (4*argc)(%r15)          NULL
35                 (4*(argc+1))(%r15)      envp[0]
36                 ...
37                                         NULL
40         .text
41         .globl _start
42         type _start,@function
43 _start:
44         /* Setup pointer to literal pool of _start */
45         basr    %r13,0
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 */
53         lhi     %r0,-8
54         nr      %r15,%r0
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
63          */
64         stm     %r14,%r15,96(%r15)      # store rtld_fini/stack_end to parameter area
65         la      %r7,96(%r15)
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 */
71         l       %r1,.L4-.Llit(%r13)
72         basr    %r14,%r1
74         /* crash if __libc_start_main returns */
75         .word   0
77 .Llit:
78 .L1:    .long  _init
79 .L2:    .long  _fini
80 .L3:    .long  main
81 .L4:    .long  __libc_start_main
83 /* FIXME: FPU flags or what ?!? */
85         .section .rodata
86         .globl _fp_hw
87         .long 3
88         .size _fp_hw, 4
90 /* Define a symbol for the first piece of initialized data.  */
91         .data
92         .globl __data_start
93 __data_start:
94         .long 0
95         .weak data_start
96         data_start = __data_start