Update.
[glibc.git] / sysdeps / ia64 / elf / start.S
blobab61d701dd9d0c36f49892da94311573a1398fd0
1 /* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Library General Public License for more details.
15    You should have received a copy of the GNU Library General Public
16    License along with the GNU C Library; see the file COPYING.LIB.  If not,
17    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18    Boston, MA 02111-1307, USA.  */
20 #include <sysdep.h>
22 #include <asm/unistd.h>
23 #include <asm/fpu.h>
26  * Arguments for __libc_start_main:
27  *      out0:   main
28  *      out1:   argc
29  *      out2:   argv
30  *      out3:   init
31  *      out4:   fini
32  *      out5:   rtld_fini
33  *      out6:   stack_end
34  */
36         .align 32
37         .global _start
39         .proc _start
40         type _start,@function
41 _start:
42         .prologue
43         { .mlx
44           alloc r2 = ar.pfs,0,0,7,0
45           movl r3 = FPSR_DEFAULT
46         }
47         { .mlx
48           adds out2 = 16, sp    /* get address of argc value */
49           movl gp = @gprel(0f)
50           ;;
51         }
52 0:      { .mmi
53           ld8 out1 = [out2], 8  /* load argc and move out2 to become argv */
54           mov.m r10 = ar.bsp    /* fetch rbs base address */
55           mov r9 = ip
56           ;;
57         }
58         { .mii
59           mov ar.fpsr = r3
60           sub gp = r9, gp       /* back-compute gp value */
61           adds out6 = 16, sp    /* highest non-environment stack address */
62           ;;
63         }
64         {
65           addl r11 = @ltoff(__libc_ia64_register_backing_store_base), gp
66           addl out0 = @ltoff(@fptr(main)), gp
67           addl out3 = @ltoff(@fptr(_init)), gp
68           ;;
69         }
70         { .mmi
71           ld8 r3 = [r11]        /* pointer to __libc_ia64_register_backing_store_base */
72           ld8 out0 = [out0]     /* pointer to `main' function descriptor */
73           addl out4 = @ltoff(@fptr(_fini)), gp
74           ;;
75         }
76         { .mmi
77           ld8 out3 = [out3]     /* pointer to `init' function descriptor */
78           ld8 out4 = [out4]     /* pointer to `fini' function descriptor */
79           .save rp, r4
80           mov r4 = r0           /* terminate unwind chain with a NULL return-pointer */
81         }
82         .body
83         { .mib
84           st8 [r3] = r10
85           mov out5 = ret0       /* dynamic linker destructor */
86           br.call.sptk.few rp = __libc_start_main
87         }
88         { .mib
89           break 0       /* break miserably if we ever return */
90         }
91         .endp _start
93 /* Define a symbol for the first piece of initialized data.  */
94         .data
95         .globl __data_start
96 __data_start:
97         .long 0
98         .weak data_start
99         data_start = __data_start
101         .common __libc_ia64_register_backing_store_base, 8, 8