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.
26 #include <sys/asm_linkage.h>
30 /* global entities defined elsewhere but used here */
34 * C language startup routine.
35 * Assume that exec code has cleared the direction flag in the TSS.
36 * Assume that %esp is set to the addr after the last word pushed.
37 * The stack contains (in order): argc, argv[],envp[],...
38 * Assume that all of the segment registers are initialized.
40 * Allocate a NULL return address and a NULL previous %ebp as if
41 * there was a genuine call to _start.
42 * debugger stack trace shows _start(argc,argv[0],argv[1],...,envp[0],...)
47 movl
%esp
,%ebp
/* The first stack frame */
50 * The stack needs to be 16-byte aligned with a 4-byte bias. See
51 * comment in lib/libc/i386/gen/makectxt.c.
53 * Note: If you change it, you need to change it in the following
56 * - lib/libc/i386/threads/machdep.c
57 * - lib/libc/i386/gen/makectxt.c
58 * - lib/crt/i386/crti.s
60 andl $
-16,%esp
/* make main() and exit() be called with */
61 subl $
4,%esp
/* a properly aligned stack pointer */
62 pushl
%edx
/* possible atexit handler */
63 leal
12(%ebp
),%edx
/* argv */
64 movl
8(%ebp
),%eax
/* argc */
74 * The following is here in case any object module compiled with cc -p
75 * was linked into this module.