1 /* Copyright (C) 1995-2017 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 License as
7 published by the Free Software Foundation; either version 2.1 of the
8 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 <http://www.gnu.org/licenses/>. */
21 /* This is the canonical entry point, usually the first thing in the text
24 Note that the code in the .init section has already been run.
25 This includes _init and _libc_init
28 At this entry point, most registers' values are unspecified, except:
30 x0/w0 Contains a function pointer to be registered with `atexit'.
31 This is how the dynamic linker arranges to have DT_FINI
32 functions called for shared libraries that have been loaded
33 before this code runs.
35 sp The stack contains the arguments and environment:
40 (8*(argc+1))(sp) envp[0]
47 .type _start,#function
49 /* Create an initial frame with 0 LR and FP */
53 /* Setup rtld_fini in argument register */
56 /* Load argc and a pointer to argv */
57 ldr PTR_REG (1), [sp, #0]
60 /* Setup stack limit in argument register */
65 ldr PTR_REG (0), [x0, #:got_lo12:main]
67 adrp x3, :got:__libc_csu_init
68 ldr PTR_REG (3), [x3, #:got_lo12:__libc_csu_init]
70 adrp x4, :got:__libc_csu_fini
71 ldr PTR_REG (4), [x4, #:got_lo12:__libc_csu_fini]
73 /* Set up the other arguments in registers */
74 ldr PTR_REG (0), =main
75 ldr PTR_REG (3), =__libc_csu_init
76 ldr PTR_REG (4), =__libc_csu_fini
79 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini,
82 /* Let the libc call main and exit with its return code. */
85 /* should never get here....*/
88 /* Define a symbol for the first piece of initialized data. */
94 data_start = __data_start