OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / uClibc / libc / sysdeps / linux / v850 / crt0.S
1 /*
2  * libc/sysdeps/linux/v850/crt0.S -- Initial program entry point for linux/v850
3  *
4  *  Copyright (C) 2001,02,03  NEC Electronics Corporation
5  *  Copyright (C) 2001,02,03  Miles Bader <miles@gnu.org>
6  *
7  * This file is subject to the terms and conditions of the GNU Lesser
8  * General Public License.  See the file COPYING.LIB in the main
9  * directory of this archive for more details.
10  *
11  * Written by Miles Bader <miles@gnu.org>
12  */
13
14 #include <clinkage.h>
15
16 /* Upon entry, the stack contains the following data:
17         argc, argv[0], ..., argv[argc-1], 0, envp[0], ..., 0
18 */
19
20         .text
21 C_ENTRY(start):
22         ld.w    0[sp], r6       /* Arg 0: argc */
23
24         addi    4, sp, r7       /* Arg 1: argv */
25
26         mov     r7, r8          /* Arg 2: envp */
27         mov     r6, r10         /* skip argc elements to get envp start */
28         add     1, r10          /* ...plus the NULL at the end of argv */
29         shl     2, r10          /* Convert to byte-count to skip */
30         add     r10, r8
31
32         /* Load CTBP register */
33         mov     hilo(C_SYMBOL_NAME(_ctbp)), r19
34         ldsr    r19, ctbp
35
36         /* Load GP */
37         mov     hilo(C_SYMBOL_NAME(_gp)), gp
38
39         /* tail-call uclibc's startup routine */
40         addi    -24, sp, sp             /* Stack space reserved for args */
41         jr      C_SYMBOL_NAME(__uClibc_main)
42
43
44 /* Stick in a dummy reference to `main', so that if an application
45    is linking when the `main' function is in a static library (.a)
46    we can be sure that `main' actually gets linked in.  */
47 L_dummy_main_reference:
48         .long   C_SYMBOL_NAME(main)
49
50 /* Define a symbol for the first piece of initialized data.  */
51         .data
52         .globl __data_start
53 __data_start:
54         .long 0
55         .weak data_start
56         data_start = __data_start
57