]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgcc/config/sparc/sol2-c1.S
Update copyright years.
[thirdparty/gcc.git] / libgcc / config / sparc / sol2-c1.S
CommitLineData
5c5060a1 1! crt1.s for sparc & sparcv9 (SunOS 5)
dd046ec9 2
fbd26352 3! Copyright (C) 1992-2019 Free Software Foundation, Inc.
dd046ec9 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
6bc9506f 8! Free Software Foundation; either version 3, or (at your option) any
dd046ec9 9! later version.
10!
dd046ec9 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!
6bc9506f 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/>.
dd046ec9 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
5c5060a1 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
dd046ec9 45 .section ".text"
46 .proc 022
47 .global _start
48
49_start:
50 mov 0, %fp ! Mark bottom frame pointer
5c5060a1 51 ldn [%sp + (16 * CPTRSIZE) + STACK_BIAS], %l0 ! argc
52 add %sp, (17 * CPTRSIZE) + STACK_BIAS, %l1 ! argv
dd046ec9 53
54 ! Leave some room for a call. Sun leaves 32 octets (to sit on
55 ! a cache line?) so we do too.
5c5060a1 56#ifdef __sparcv9
57 sub %sp, 48, %sp
58#else
dd046ec9 59 sub %sp, 32, %sp
5c5060a1 60#endif
dd046ec9 61
62 ! %g1 may contain a function to be registered w/atexit
63 orcc %g0, %g1, %g0
5c5060a1 64#ifdef __sparcv9
65 be %xcc, .nope
66#else
dd046ec9 67 be .nope
5c5060a1 68#endif
dd046ec9 69 mov %g1, %o0
70 call atexit
71 nop
72.nope:
73 ! Now make sure constructors and destructors are handled.
5c5060a1 74 setn(_fini, %o1, %o0)
dd046ec9 75 call atexit, 1
76 nop
77 call _init, 0
78 nop
79
5c5060a1 80 ! We ignore the auxiliary vector; there is no defined way to
dd046ec9 81 ! access those data anyway. Instead, go straight to main:
82 mov %l0, %o0 ! argc
83 mov %l1, %o1 ! argv
f8c2b51c 84#ifdef GCRT1
85 setn(___Argv, %o4, %o3)
86 stn %o1, [%o3] ! *___Argv
87#endif
dd046ec9 88 ! Skip argc words past argv, to env:
5c5060a1 89 sll %l0, CPTRSHIFT, %o2
90 add %o2, CPTRSIZE, %o2
dd046ec9 91 add %l1, %o2, %o2 ! env
5c5060a1 92 setn(_environ, %o4, %o3)
93 stn %o2, [%o3] ! *_environ
dd046ec9 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