2.9
[glibc/nacl-glibc.git] / sysdeps / powerpc / powerpc64 / elf / start.S
blobc9119a26248d3f67063ba5d93c7cf7a5832a4dea
1 /* Startup code for programs linked with GNU libc.  PowerPC64 version.
2    Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    In addition to the permissions in the GNU Lesser General Public
11    License, the Free Software Foundation gives you unlimited
12    permission to link the compiled version of this file with other
13    programs, and to distribute those programs without any restriction
14    coming from the use of this file. (The GNU Lesser General Public
15    License restrictions do apply in other respects; for example, they
16    cover modification of the file, and distribution when not linked
17    into another program.)
19    Note that people who make modified versions of this file are not
20    obligated to grant this special exception for their modified
21    versions; it is their choice whether to do so. The GNU Lesser
22    General Public License gives permission to release a modified
23    version without this exception; this exception also makes it
24    possible to release a modified version which carries forward this
25    exception.
27    The GNU C Library is distributed in the hope that it will be useful,
28    but WITHOUT ANY WARRANTY; without even the implied warranty of
29    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
30    Lesser General Public License for more details.
32    You should have received a copy of the GNU Lesser General Public
33    License along with the GNU C Library; if not, write to the Free
34    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
35    02111-1307 USA.  */
37 #include <sysdep.h>
38 #include "bp-sym.h"
40  /* These are the various addresses we require.  */
41 #ifdef PIC
42         .section ".data.rel.ro.local","aw"
43 #else
44         .section ".rodata"
45 #endif
46         .align  3
47 L(start_addresses):
48         .quad   0 /* was _SDA_BASE_  but not in 64-bit ABI*/
49 /*     function descriptors so don't need JUMPTARGET */
50         .quad   BP_SYM(main)
51         .quad   __libc_csu_init
52         .quad   __libc_csu_fini
54         ASM_SIZE_DIRECTIVE(L(start_addresses))
56         .section        ".toc","aw"
57 .L01:
58         .tc     L(start_addresses)[TC],L(start_addresses)
59         .section ".text"
60 ENTRY(_start)
61  /* Save the stack pointer, in case we're statically linked under Linux.  */
62         mr      r9,r1
63  /* Set up an initial stack frame, and clear the LR.  */
64         clrrdi  r1,r1,4
65         li      r0,0
66         stdu    r1,-128(r1)
67         mtlr    r0
68         std     r0,0(r1)
70  /* put the address of start_addresses in r8...  **
71 ** PPC64 ABI uses R13 for thread local, so we leave it alone */
72         ld      r8,.L01(r2)
74  /* and continue in libc-start, in glibc.  */
75         b       JUMPTARGET(BP_SYM(__libc_start_main))
76 /* The linker needs this nop to recognize that it's OK to call via a
77    TOC adjusting stub.  */
78         nop
80 END(_start)
82 /* Define a symbol for the first piece of initialized data.  */
83         .section ".data"
84         .globl  __data_start
85 __data_start:
86 weak_alias (__data_start, data_start)