Update copyright notices with scripts/update-copyrights.
[glibc.git] / ports / sysdeps / am33 / elf / start.S
blob0ca71f14a409ab0fee26d5aa2ddff13c29d89738
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:
31                 (4,sp)                  argc
32                 (8,sp)                  argv[0]
33                 ...
34                 (4*(argc+1),sp)         NULL
35                 (4*(argc+2),sp)         envp[0]
36                 ...
37                                         NULL
40 #include "bp-sym.h"
42         .text
43         .globl _start
44         .type _start,@function
45 _start:
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.  */
49         mov sp,a3
50         add -32,sp
51         
52         mov a3,(28,sp)          /* stack_end.  */       
53         mov d0,(24,sp)          /* rtld_fini.  */
54         mov _fini, d3
55         mov d3,(20,sp)          /* fini.  */
56         mov _init, d2
57         mov d2,(16,sp)          /* init.  */
58         inc4 a3
59         mov a3,(12,sp)          /* argv.  */
60         
61         /* Set the initial frame pointer as 0, so that the bottom of
62            the stack is clearly marked.  */
63         mov 0,a3
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.  */
75         .data
76         .globl __data_start
77 __data_start:
78         .long 0
79         .weak data_start
80         data_start = __data_start