1 /* Startup code compliant to the ELF MN10300 ABI.
2 Copyright (C) 1995-2013 Free Software Foundation, Inc.
3 Contributed by Alexandre Oliva <aoliva@redhat.com>
4 Based on ../../i386/elf/start.S.
5 This file is part of the GNU C Library.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library. If not, see
19 <http://www.gnu.org/licenses/>. */
21 /* This is the canonical entry point, usually the first thing in the text
22 segment. The SVR4/i386 ABI (pages 3-31, 3-32) says that when the entry
23 point runs, most registers' values are unspecified, except for:
25 a0 Contains a function pointer to be registered with `atexit'.
26 This is how the dynamic linker arranges to have DT_FINI
27 functions called for shared libraries that have been loaded
28 before this code runs.
30 sp The stack contains the arguments and environment:
35 (4*(argc+2),sp) envp[0]
42 .type _start,@function
44 /* Extract the arguments as encoded on the stack and set up
45 the arguments for `main': argc, argv. envp will be determined
46 later in __libc_start_main. */
50 mov a3,(28,sp) /* stack_end. */
51 mov d0,(24,sp) /* rtld_fini. */
53 mov d3,(20,sp) /* fini. */
55 mov d2,(16,sp) /* init. */
57 mov a3,(12,sp) /* argv. */
59 /* Set the initial frame pointer as 0, so that the bottom of
60 the stack is clearly marked. */
63 mov (32,sp), d1 /* argc. */
64 mov main, d0 /* main. */
66 /* Call the user's main function, and exit with its value.
67 But let the libc call main. */
68 call __libc_start_main,[],0
70 call abort,[],0 /* Crash if somehow `exit' does return. */
72 /* Define a symbol for the first piece of initialized data. */
78 data_start = __data_start