Print this page
6507 i386 makecontext(3c) needs to 16-byte align the stack
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/common/i386/crt1.s
+++ new/usr/src/lib/common/i386/crt1.s
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 /*
28 28 * This crt1.o module is provided as the bare minimum required to build
29 29 * a 32-bit executable with gcc. It is installed in /usr/lib
30 30 * where it will be picked up by gcc, along with crti.o and crtn.o
31 31 */
32 32
33 33 .file "crt1.s"
34 34
35 35 .globl _start
36 36
37 37 /* global entities defined elsewhere but used here */
38 38 .globl main
39 39 .globl __fpstart
40 40 .globl exit
41 41 .globl _exit
42 42 .weak _DYNAMIC
43 43
44 44 .section .data
45 45
46 46 .weak environ
47 47 .set environ,_environ
48 48 .globl _environ
49 49 .type _environ,@object
50 50 .size _environ,4
51 51 .align 4
52 52 _environ:
53 53 .4byte 0x0
54 54
55 55 .globl __environ_lock
56 56 .type __environ_lock,@object
57 57 .size __environ_lock,24
58 58 .align 8
59 59 __environ_lock:
60 60 .zero 24
61 61
62 62 .globl ___Argv
63 63 .type ___Argv,@object
64 64 .size ___Argv,4
65 65 .align 4
66 66 ___Argv:
67 67 .4byte 0x0
68 68
69 69 .section .text
70 70 .align 4
71 71
72 72 /*
73 73 * C language startup routine.
74 74 * Assume that exec code has cleared the direction flag in the TSS.
75 75 * Assume that %esp is set to the addr after the last word pushed.
76 76 * The stack contains (in order): argc, argv[],envp[],...
77 77 * Assume that all of the segment registers are initialized.
78 78 *
79 79 * Allocate a NULL return address and a NULL previous %ebp as if
80 80 * there was a genuine call to _start.
81 81 * sdb stack trace shows _start(argc,argv[0],argv[1],...,envp[0],...)
82 82 */
83 83 .type _start,@function
84 84 _start:
85 85 pushl $0
86 86 pushl $0
87 87 movl %esp,%ebp /* The first stack frame */
88 88
89 89 movl $_DYNAMIC,%eax
90 90 testl %eax,%eax
91 91 jz 1f
92 92 pushl %edx /* register rt_do_exit */
93 93 call atexit
94 94 addl $4,%esp
95 95 1:
96 96 pushl $_fini
97 97 call atexit
98 98 addl $4,%esp
99 99
100 100 /*
101 101 * The following code provides almost standard static destructor handling
102 102 * for systems that do not have the modified atexit processing in their
103 103 * system libraries. It checks for the existence of the new routine
104 104 * "_get_exit_frame_monitor()", which is in libc.so when the new exit-handling
105 105 * code is there. It then check for the existence of "__Crun::do_exit_code()"
106 106 * which will be in libCrun.so whenever the code was linked with the C++
107 107 * compiler. If there is no enhanced atexit, and we do have do_exit_code,
108 108 * we register the latter with atexit. There are 5 extra slots in
109 109 * atexit, so this will still be standard conforming. Since the code
110 110 * is registered after the .fini section, it runs before the library
111 111 * cleanup code, leaving nothing for the calls to _do_exit_code_in_range
112 112 * to handle.
113 113 *
114 114 * Remove this code and the associated code in libCrun when the earliest
115 115 * system to be supported is Solaris 8.
116 116 */
117 117 .weak _get_exit_frame_monitor
118 118 .weak __1cG__CrunMdo_exit_code6F_v_
119 119
120 120 .section .data
121 121 .align 4
122 122 __get_exit_frame_monitor_ptr:
123 123 .4byte _get_exit_frame_monitor
124 124 .type __get_exit_frame_monitor_ptr,@object
125 125 .size __get_exit_frame_monitor_ptr,4
126 126
127 127 .align 4
128 128 __do_exit_code_ptr:
129 129 .4byte __1cG__CrunMdo_exit_code6F_v_
130 130 .type __do_exit_code_ptr,@object
131 131 .size __do_exit_code_ptr,4
132 132
133 133 .section .text
134 134
135 135 lea __get_exit_frame_monitor_ptr, %eax
136 136 movl (%eax), %eax
137 137 testl %eax,%eax
138 138 jz 1f
139 139 lea __do_exit_code_ptr, %eax
140 140 movl (%eax), %eax
141 141 testl %eax, %eax
142 142 jz 1f
143 143 pushl %eax
144 144 call atexit /* atexit(__Crun::do_exit_code()) */
145 145 addl $4,%esp
146 146 1:
147 147
148 148 /*
149 149 * End of destructor handling code
150 150 */
151 151
152 152 /*
153 153 * Calculate the location of the envp array by adding the size of
↓ open down ↓ |
153 lines elided |
↑ open up ↑ |
154 154 * the argv array to the start of the argv array.
155 155 */
156 156
157 157 movl 8(%ebp),%eax /* argc */
158 158 movl _environ, %edx /* fixed bug 4302802 */
159 159 testl %edx, %edx /* check if _enviorn==0 */
160 160 jne 1f /* fixed bug 4203802 */
161 161 leal 16(%ebp,%eax,4),%edx /* envp */
162 162 movl %edx,_environ /* copy to _environ */
163 163 1:
164 + /*
165 + * The stack needs to be 16-byte aligned with a 4-byte bias. See
166 + * comment in lib/libc/i386/gen/makectxt.c.
167 + *
168 + * Note: If you change it, you need to change it in the following
169 + * files as well:
170 + *
171 + * - lib/libc/i386/threads/machdep.c
172 + * - lib/libc/i386/gen/makectxt.c
173 + * - lib/common/i386/crti.s
174 + */
164 175 andl $-16,%esp /* make main() and exit() be called with */
165 - subl $4,%esp /* a 16-byte aligned stack pointer */
176 + subl $4,%esp /* a properly aligned stack pointer */
166 177 pushl %edx
167 178 leal 12(%ebp),%edx /* argv */
168 179 movl %edx,___Argv
169 180 pushl %edx
170 181 pushl %eax /* argc */
171 182 call __fpstart
172 183 call __fsr /* support for ftrap/fround/fprecision */
173 184 call _init
174 185 call main /* main(argc,argv,envp) */
175 186 movl %eax,(%esp) /* return value from main, for exit() */
176 187 movl %eax,4(%esp) /* remember it for _exit(), below */
177 188 call exit
178 189 movl 4(%esp),%eax /* if user redefined exit, call _exit */
179 190 movl %eax,(%esp)
180 191 call _exit
181 192 hlt
182 193 .size _start, .-_start
183 194
184 195 #include "fsr.s"
185 196
186 197 /*
187 198 * The following is here in case any object module compiled with cc -p
188 199 * was linked into this module.
189 200 */
190 201 .section .text
191 202 .align 4
192 203 .globl _mcount
193 204 .type _mcount,@function
194 205 _mcount:
195 206 ret
196 207 .size _mcount, .-_mcount
197 208
198 209 .section .data
199 210
200 211 .globl __longdouble_used
201 212 .type __longdouble_used,@object
202 213 .size __longdouble_used,4
203 214 .align 4
204 215 __longdouble_used:
205 216 .4byte 0x0
↓ open down ↓ |
30 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX