]>
Commit | Line | Data |
---|---|---|
d559a4db | 1 | ! crt1.s for sparc & sparcv9 (SunOS 5) |
9b73b79e | 2 | |
8d9254fc | 3 | ! Copyright (C) 1992-2020 Free Software Foundation, Inc. |
9b73b79e RS |
4 | ! Written By David Vinayak Henkel-Wallace, June 1992 |
5 | ! | |
6 | ! This file is free software; you can redistribute it and/or modify it | |
7 | ! under the terms of the GNU General Public License as published by the | |
748086b7 | 8 | ! Free Software Foundation; either version 3, or (at your option) any |
9b73b79e RS |
9 | ! later version. |
10 | ! | |
9b73b79e RS |
11 | ! This file is distributed in the hope that it will be useful, but |
12 | ! WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | ! General Public License for more details. | |
15 | ! | |
748086b7 JJ |
16 | ! Under Section 7 of GPL version 3, you are granted additional |
17 | ! permissions described in the GCC Runtime Library Exception, version | |
18 | ! 3.1, as published by the Free Software Foundation. | |
19 | ! | |
20 | ! You should have received a copy of the GNU General Public License and | |
21 | ! a copy of the GCC Runtime Library Exception along with this program; | |
22 | ! see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | ! <http://www.gnu.org/licenses/>. | |
9b73b79e RS |
24 | |
25 | ! This file takes control of the process from the kernel, as specified | |
26 | ! in section 3 of the SVr4 ABI. | |
27 | ! This file is the first thing linked into any executable. | |
28 | ||
d559a4db DM |
29 | #ifdef __sparcv9 |
30 | #define CPTRSIZE 8 | |
31 | #define CPTRSHIFT 3 | |
32 | #define STACK_BIAS 2047 | |
33 | #define ldn ldx | |
34 | #define stn stx | |
35 | #define setn(s, scratch, dst) setx s, scratch, dst | |
36 | #else | |
37 | #define CPTRSIZE 4 | |
38 | #define CPTRSHIFT 2 | |
39 | #define STACK_BIAS 0 | |
40 | #define ldn ld | |
41 | #define stn st | |
42 | #define setn(s, scratch, dst) set s, dst | |
43 | #endif | |
44 | ||
9b73b79e RS |
45 | .section ".text" |
46 | .proc 022 | |
47 | .global _start | |
48 | ||
49 | _start: | |
50 | mov 0, %fp ! Mark bottom frame pointer | |
d559a4db DM |
51 | ldn [%sp + (16 * CPTRSIZE) + STACK_BIAS], %l0 ! argc |
52 | add %sp, (17 * CPTRSIZE) + STACK_BIAS, %l1 ! argv | |
9b73b79e RS |
53 | |
54 | ! Leave some room for a call. Sun leaves 32 octets (to sit on | |
55 | ! a cache line?) so we do too. | |
d559a4db DM |
56 | #ifdef __sparcv9 |
57 | sub %sp, 48, %sp | |
58 | #else | |
9b73b79e | 59 | sub %sp, 32, %sp |
d559a4db | 60 | #endif |
9b73b79e RS |
61 | |
62 | ! %g1 may contain a function to be registered w/atexit | |
63 | orcc %g0, %g1, %g0 | |
d559a4db DM |
64 | #ifdef __sparcv9 |
65 | be %xcc, .nope | |
66 | #else | |
9b73b79e | 67 | be .nope |
d559a4db | 68 | #endif |
9b73b79e RS |
69 | mov %g1, %o0 |
70 | call atexit | |
71 | nop | |
72 | .nope: | |
73 | ! Now make sure constructors and destructors are handled. | |
d559a4db | 74 | setn(_fini, %o1, %o0) |
9b73b79e RS |
75 | call atexit, 1 |
76 | nop | |
77 | call _init, 0 | |
78 | nop | |
79 | ||
d559a4db | 80 | ! We ignore the auxiliary vector; there is no defined way to |
9b73b79e RS |
81 | ! access those data anyway. Instead, go straight to main: |
82 | mov %l0, %o0 ! argc | |
83 | mov %l1, %o1 ! argv | |
04b67900 P |
84 | #ifdef GCRT1 |
85 | setn(___Argv, %o4, %o3) | |
86 | stn %o1, [%o3] ! *___Argv | |
87 | #endif | |
9b73b79e | 88 | ! Skip argc words past argv, to env: |
d559a4db DM |
89 | sll %l0, CPTRSHIFT, %o2 |
90 | add %o2, CPTRSIZE, %o2 | |
9b73b79e | 91 | add %l1, %o2, %o2 ! env |
d559a4db DM |
92 | setn(_environ, %o4, %o3) |
93 | stn %o2, [%o3] ! *_environ | |
9b73b79e RS |
94 | call main, 4 |
95 | nop | |
96 | call exit, 0 | |
97 | nop | |
98 | call _exit, 0 | |
99 | nop | |
100 | ! We should never get here. | |
101 | ||
102 | .type _start,#function | |
103 | .size _start,.-_start |