4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * This crt1.o module is provided as the bare minimum required to build
29 * a 32-bit executable with gcc. It is installed in /usr/lib
30 * where it will be picked up by gcc, along with crti.o and crtn.o
37 /* global entities defined elsewhere but used here */
49 .type _environ,@object
56 .type __environ_lock,@object
57 .size __environ_lock,24
73 * C language startup routine.
74 * Assume that exec code has cleared the direction flag in the TSS.
75 * Assume that %esp is set to the addr after the last word pushed.
76 * The stack contains (in order): argc, argv[],envp[],...
77 * Assume that all of the segment registers are initialized.
79 * Allocate a NULL return address and a NULL previous %ebp as if
80 * there was a genuine call to _start.
81 * sdb stack trace shows _start(argc,argv[0],argv[1],...,envp[0],...)
83 .type _start,@function
87 movl
%esp
,%ebp
/* The first stack frame */
92 pushl
%edx
/* register rt_do_exit */
101 * The following code provides almost standard static destructor handling
102 * for systems that do not have the modified atexit processing in their
103 * system libraries. It checks for the existence of the new routine
104 * "_get_exit_frame_monitor()", which is in libc.so when the new exit-handling
105 * code is there. It then check for the existence of "__Crun::do_exit_code()"
106 * which will be in libCrun.so whenever the code was linked with the C++
107 * compiler. If there is no enhanced atexit, and we do have do_exit_code,
108 * we register the latter with atexit. There are 5 extra slots in
109 * atexit, so this will still be standard conforming. Since the code
110 * is registered after the .fini section, it runs before the library
111 * cleanup code, leaving nothing for the calls to _do_exit_code_in_range
114 * Remove this code and the associated code in libCrun when the earliest
115 * system to be supported is Solaris 8.
117 .weak _get_exit_frame_monitor
118 .weak __1cG__CrunMdo_exit_code6F_v_
122 __get_exit_frame_monitor_ptr
:
123 .4byte _get_exit_frame_monitor
124 .type __get_exit_frame_monitor_ptr,@object
125 .size __get_exit_frame_monitor_ptr,4
129 .4byte __1cG__CrunMdo_exit_code6F_v_
130 .type __do_exit_code_ptr,@object
131 .size __do_exit_code_ptr,4
135 lea __get_exit_frame_monitor_ptr
, %eax
139 lea __do_exit_code_ptr
, %eax
144 call atexit
/* atexit(__Crun::do_exit_code()) */
149 * End of destructor handling code
153 * Calculate the location of the envp array by adding the size of
154 * the argv array to the start of the argv array.
157 movl
8(%ebp
),%eax
/* argc */
158 movl _environ
, %edx
/* fixed bug 4302802 */
159 testl
%edx
, %edx
/* check if _enviorn==0 */
160 jne
1f
/* fixed bug 4203802 */
161 leal
16(%ebp
,%eax
,4),%edx
/* envp */
162 movl
%edx
,_environ
/* copy to _environ */
165 * The stack needs to be 16-byte aligned with a 4-byte bias. See
166 * comment in lib/libc/i386/gen/makectxt.c.
168 * Note: If you change it, you need to change it in the following
171 * - lib/libc/i386/threads/machdep.c
172 * - lib/libc/i386/gen/makectxt.c
173 * - lib/common/i386/crti.s
175 andl $
-16,%esp
/* make main() and exit() be called with */
176 subl $
4,%esp
/* a properly aligned stack pointer */
178 leal
12(%ebp
),%edx
/* argv */
181 pushl
%eax
/* argc */
183 call __fsr
/* support for ftrap/fround/fprecision */
185 call main
/* main(argc,argv,envp) */
186 movl
%eax
,(%esp
) /* return value from main, for exit() */
187 movl
%eax
,4(%esp
) /* remember it for _exit(), below */
189 movl
4(%esp
),%eax
/* if user redefined exit, call _exit */
193 .size _start, .-_start
198 * The following is here in case any object module compiled with cc -p
199 * was linked into this module.
204 .type _mcount,@function
207 .size _mcount, .-_mcount
211 .globl __longdouble_used
212 .type __longdouble_used,@object
213 .size __longdouble_used,4