1 /* Startup code for ARC.
2 Copyright (C) 2020 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 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.
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/>. */
19 #define __ASSEMBLY__ 1
24 # error ENTRY_POINT needs to be defined for ARC
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)
33 env[0...N] environment variables (pointers)
38 /* Needed to make gdb backtraces stop here. */
43 ld_s r1, [sp] /* argc. */
45 mov_s r5, r0 /* rltd_fini. */
46 add_s r2, sp, 4 /* argv. */
50 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end). */
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
59 mov_s r3, __libc_csu_init
60 mov r4, __libc_csu_fini
64 /* Should never get here. */
68 /* Define a symbol for the first piece of initialized data. */
74 data_start = __data_start