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.
28 * This crt1.o module is provided as the bare minimum required to build
29 * a 64-bit executable with gcc. It is installed in /usr/lib/amd64
30 * where it will be picked up by gcc, along with crti.o and crtn.o
33 .ident "%Z%%M% %I% %E% SMI"
39 /* global entities defined elsewhere but used here */
51 .type _environ,@object
58 .type __environ_lock,@object
59 .size __environ_lock,24
75 * The SVR4/i386 ABI (pages 3-29) says that when the entry
76 * point runs registers' %rbp, %rsp, %rdx values are specified
79 * %rbp The content of this register is unspecified at
80 * process initialization time, but the user code should mark
81 * the deepest stack frame by setting the frame pointer to zero.
82 * No other frame's %ebp should have a zero value.
84 * %rsp Performing its usual job, the stack pointer holds the address
85 * of the bottom of the stack, which is guaranteed to be
88 * The stack contains the arguments and environment:
90 * envp[0] (16+(8*argc))(%rsp)
91 * NULL (8+(8*argc))(%rsp)
96 * %rdx In a conforming program, this register contains a function
97 * pointer that the application should register with atexit(BA_OS).
98 * This function is used for shared object termination code
99 * [see Dynamic Linking in Chapter 5 of the System V ABI].
103 .type _start,@function
106 * Allocate a NULL return address and a NULL previous %rbp as if
107 * there was a genuine call to _start.
111 movq
%rsp
,%rbp
/* The first stack frame */
116 * envp[0] (32+(8*argc))(%rsp) - (A)
117 * NULL (24+(8*argc))(%rsp)
119 * argv[0] 24(%rbp) - (B)
128 movq
%rdx
,%rdi
/* register rt_do_exit */
135 * Calculate the location of the envp array by adding the size of
136 * the argv array to the start of the argv array.
138 movq
16(%rbp
),%rax
/* argc */
140 testq
%rcx
, %rcx
/* check if _environ==0 */
142 leaq
32(%rbp
,%rax
,8),%rcx
/* (A) */
143 movq
%rcx
,_environ
/* copy to _environ */
147 * Force stack alignment - below here there must have been an even
148 * number of un-popped pushq instructions whenever a call is reached
152 leaq
24(%rbp
),%rdx
/* argv (B) */
163 call main
/* main(argc,argv,envp) */
166 movq
%rax
,%rdi
/* and call exit */
170 call _exit
/* if user redefined exit, call _exit */
172 .size _start, .-_start
175 * The following is here in case any object module compiled with cc -p
176 * was linked into this module.
181 .type _mcount,@function
184 .size _mcount, .-_mcount
186 .globl __longdouble_used
189 .type __longdouble_used,@object
190 .size __longdouble_used,4