]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/arc/start.S
3c4144bd20d4791f40c1548d4cca8aad5f9e43ee
[thirdparty/glibc.git] / sysdeps / arc / start.S
1 /* Startup code for ARC.
2 Copyright (C) 2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
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.
9
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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <https://www.gnu.org/licenses/>. */
18
19 #define __ASSEMBLY__ 1
20 #include <entry.h>
21 #include <sysdep.h>
22
23 #ifndef ENTRY_POINT
24 # error ENTRY_POINT needs to be defined for ARC
25 #endif
26
27 /* When we enter this piece of code, the program stack looks like this:
28 argc argument counter (integer)
29 argv[0] program name (pointer)
30 argv[1...N] program args (pointers)
31 argv[argc-1] end of args (integer)
32 NULL
33 env[0...N] environment variables (pointers)
34 NULL. */
35
36 ENTRY (ENTRY_POINT)
37
38 /* Needed to make gdb backtraces stop here. */
39 .cfi_label .Ldummy
40 cfi_undefined (blink)
41
42 mov fp, 0
43 ld_s r1, [sp] /* argc. */
44
45 mov_s r5, r0 /* rltd_fini. */
46 add_s r2, sp, 4 /* argv. */
47 and sp, sp, -8
48 mov r6, sp
49
50 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end). */
51
52 #ifdef SHARED
53 ld r0, [pcl, @main@gotpc]
54 ld r3, [pcl, @__libc_csu_init@gotpc]
55 ld r4, [pcl, @__libc_csu_fini@gotpc]
56 bl __libc_start_main@plt
57 #else
58 mov_s r0, main
59 mov_s r3, __libc_csu_init
60 mov r4, __libc_csu_fini
61 bl __libc_start_main
62 #endif
63
64 /* Should never get here. */
65 flag 1
66 END (ENTRY_POINT)
67
68 /* Define a symbol for the first piece of initialized data. */
69 .data
70 .globl __data_start
71 __data_start:
72 .long 0
73 .weak data_start
74 data_start = __data_start