]>
Commit | Line | Data |
---|---|---|
dd2e6ef1 | 1 | /* Startup code for ARC. |
dff8da6b | 2 | Copyright (C) 2020-2024 Free Software Foundation, Inc. |
dd2e6ef1 VG |
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 | ||
06d4381d SN |
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.) | |
18 | ||
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. | |
26 | ||
dd2e6ef1 VG |
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. | |
31 | ||
32 | You should have received a copy of the GNU Lesser General Public | |
06d4381d | 33 | License along with the GNU C Library; if not, see |
dd2e6ef1 VG |
34 | <https://www.gnu.org/licenses/>. */ |
35 | ||
36 | #define __ASSEMBLY__ 1 | |
37 | #include <entry.h> | |
38 | #include <sysdep.h> | |
39 | ||
40 | #ifndef ENTRY_POINT | |
41 | # error ENTRY_POINT needs to be defined for ARC | |
42 | #endif | |
43 | ||
44 | /* When we enter this piece of code, the program stack looks like this: | |
45 | argc argument counter (integer) | |
46 | argv[0] program name (pointer) | |
47 | argv[1...N] program args (pointers) | |
48 | argv[argc-1] end of args (integer) | |
49 | NULL | |
50 | env[0...N] environment variables (pointers) | |
51 | NULL. */ | |
52 | ||
53 | ENTRY (ENTRY_POINT) | |
54 | ||
55 | /* Needed to make gdb backtraces stop here. */ | |
56 | .cfi_label .Ldummy | |
57 | cfi_undefined (blink) | |
58 | ||
59 | mov fp, 0 | |
60 | ld_s r1, [sp] /* argc. */ | |
61 | ||
62 | mov_s r5, r0 /* rltd_fini. */ | |
63 | add_s r2, sp, 4 /* argv. */ | |
64 | and sp, sp, -8 | |
65 | mov r6, sp | |
66 | ||
67 | /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end). */ | |
68 | ||
035c012e FW |
69 | mov_s r3, 0 /* Used to be init. */ |
70 | mov r4, 0 /* Used to be fini. */ | |
71 | ||
dd2e6ef1 VG |
72 | #ifdef SHARED |
73 | ld r0, [pcl, @main@gotpc] | |
dd2e6ef1 VG |
74 | bl __libc_start_main@plt |
75 | #else | |
76 | mov_s r0, main | |
dd2e6ef1 VG |
77 | bl __libc_start_main |
78 | #endif | |
79 | ||
80 | /* Should never get here. */ | |
81 | flag 1 | |
82 | END (ENTRY_POINT) | |
83 | ||
84 | /* Define a symbol for the first piece of initialized data. */ | |
85 | .data | |
86 | .globl __data_start | |
87 | __data_start: | |
88 | .long 0 | |
89 | .weak data_start | |
90 | data_start = __data_start |