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]
44 .type _start,@function
46 /* Extract the arguments as encoded on the stack and set up
47 the arguments for `main': argc, argv. envp will be determined
48 later in __libc_start_main. */
52 mov a3,(28,sp) /* stack_end. */
53 mov d0,(24,sp) /* rtld_fini. */
55 mov d3,(20,sp) /* fini. */
57 mov d2,(16,sp) /* init. */
59 mov a3,(12,sp) /* argv. */
61 /* Set the initial frame pointer as 0, so that the bottom of
62 the stack is clearly marked. */
65 mov (32,sp), d1 /* argc. */
66 mov BP_SYM (main), d0 /* main. */
68 /* Call the user's main function, and exit with its value.
69 But let the libc call main. */
70 call BP_SYM (__libc_start_main),[],0
72 call BP_SYM (abort),[],0 /* Crash if somehow `exit' does return. */
74 /* Define a symbol for the first piece of initialized data. */
80 data_start = __data_start