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 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #include <sys/asm_linkage.h>
34 * The SVR4/i386 ABI (pages 3-29) says that when the entry
35 * point runs registers' %rbp, %rsp, %rdx values are specified
38 * %rbp The content of this register is unspecified at
39 * process initialization time, but the user code should mark
40 * the deepest stack frame by setting the frame pointer to zero.
41 * No other frame's %ebp should have a zero value.
43 * %rsp Performing its usual job, the stack pointer holds the address
44 * of the bottom of the stack, which is guaranteed to be
47 * The stack contains the arguments and environment:
49 * envp[0] (16+(8*argc))(%rsp)
50 * NULL (8+(8*argc))(%rsp)
55 * %rdx In a conforming program, this register contains a function
56 * pointer that the application should register with atexit(BA_OS).
57 * This function is used for shared object termination code
58 * [see Dynamic Linking in Chapter 5 of the System V ABI].
64 * Allocate a NULL return address and a NULL previous %rbp as if
65 * there was a genuine call to _start.
69 movq
%rsp
,%rbp
/* The first stack frame */
74 * envp[0] (32+(8*argc))(%rsp) - (A)
75 * NULL (24+(8*argc))(%rsp)
77 * argv[0] 24(%rbp) - (B)
83 andq $
-16,%rsp
/* align the stack */
84 movq
16(%rbp
),%rdi
/* argc */
85 leaq
24(%rbp
),%rsi
/* argv */
86 /* NB: rt_do_exit, if applicable, is already in %rdx */
92 * The following is here in case any object module compiled with cc -p
93 * was linked into this module.