]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/arc/crt1.S
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / arc / crt1.S
1 /*
2  * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
3  *
4  * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
5  */
6
7 #include <features.h>
8
9 .text
10
11 #ifndef __UCLIBC_CTOR_DTOR__
12         .weak   _init
13         .weak   _fini
14 #endif
15
16 /* Stick in a dummy reference to main(), so that if an application
17  * is linking when the main() function is in a static library (.a)
18  * we can be sure that main() actually gets linked in
19  */
20         .type   main,@function
21         .type   _main,@function
22
23
24 /* When we enter this piece of code, the program stack looks like this:
25         argc            argument counter (integer)
26         argv[0]         program name (pointer)
27         argv[1...N]     program args (pointers)
28         argv[argc-1]    end of args (integer)
29         NULL
30         env[0...N]      environment variables (pointers)
31         NULL
32 */
33         .text
34         .align 4
35         .global __start
36         .hidden __start
37         .type __start,@function
38 __start:
39         mov     fp, 0
40         ld_s    r1, [sp]        ; argc
41
42         mov_s   r5, r0          ; rltd_fini
43         add_s   r2, sp, 4       ; argv
44
45         mov_s   r0, main
46         mov_s   r3, _init
47         mov     r4, _fini
48
49         and     sp, sp, -8
50         mov     r6, sp
51
52         /* __uClibc_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
53         bl      __uClibc_main
54
55         /* Should never get here....  */
56         flag    1
57 .size __start,.-__start