/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* This gcrt1.o module is provided as the bare minimum required to build a
* where it will be picked up by gcc, along with crti.o and crtn.o
*/
.ident "%Z%%M% %I% %E% SMI"
/* global entities defined elsewhere but used here */
.align 4
.align 4
.align 4
/*
* C language startup routine.
* Assume that exec code has cleared the direction flag in the TSS.
* Assume that %esp is set to the addr after the last word pushed.
* The stack contains (in order): argc, argv[],envp[],...
* Assume that all of the segment registers are initialized.
*
* Allocate a NULL return address and a NULL previous %ebp as if
* there was a genuine call to _start.
* sdb stack trace shows _start(argc,argv[0],argv[1],...,envp[0],...)
*/
pushl $0
pushl $0
/*
* Check to see if there is an _mcleanup() function linked in, and if so,
* register it with atexit() as the last thing to be run by exit().
*/
jz 1f
1:
jz 1f
1:
/* start profiling */
/*
* The following code provides almost standard static destructor handling
* for systems that do not have the modified atexit processing in their
* system libraries. It checks for the existence of the new routine
* "_get_exit_frame_monitor()", which is in libc.so when the new exit-handling
* code is there. It then check for the existence of "__Crun::do_exit_code()"
* which will be in libCrun.so whenever the code was linked with the C++
* compiler. If there is no enhanced atexit, and we do have do_exit_code,
* we register the latter with atexit. There are 5 extra slots in
* atexit, so this will still be standard conforming. Since the code
* is registered after the .fini section, it runs before the library
* cleanup code, leaving nothing for the calls to _do_exit_code_in_range
* to handle.
*
* Remove this code and the associated code in libCrun when the earliest
* system to be supported is Solaris 8.
*/
.align 4
.align 4
jz 1f
jz 1f
1:
/*
* End of destructor handling code
*/
/*
* Calculate the location of the envp array by adding the size of
* the argv array to the start of the argv array.
*/
1: