Print this page
7324 stack needs to be sufficiently aligned for SSE before init_array are called
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/sgs/rtld/i386/boot.s
+++ new/usr/src/cmd/sgs/rtld/i386/boot.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, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * Copyright (c) 1988 AT&T
24 24 * All Rights Reserved
25 25 *
26 26 *
27 27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
28 28 * Use is subject to license terms.
29 29 */
30 -#pragma ident "%Z%%M% %I% %E% SMI"
31 30
32 31 /*
33 32 * Bootstrap routine for run-time linker.
34 33 * We get control from exec which has loaded our text and
35 34 * data into the process' address space and created the process
36 35 * stack.
37 36 *
38 37 * On entry, the process stack looks like this:
39 38 *
40 39 * # # <- %esp
41 40 * #_______________________# high addresses
42 41 * # strings #
43 42 * #_______________________#
44 43 * # 0 word #
45 44 * #_______________________#
46 45 * # Auxiliary #
47 46 * # entries #
48 47 * # ... #
49 48 * # (size varies) #
50 49 * #_______________________#
51 50 * # 0 word #
52 51 * #_______________________#
53 52 * # Environment #
54 53 * # pointers #
55 54 * # ... #
56 55 * # (one word each) #
57 56 * #_______________________#
58 57 * # 0 word #
59 58 * #_______________________#
60 59 * # Argument # low addresses
61 60 * # pointers #
62 61 * # Argc words #
63 62 * #_______________________#
64 63 * # argc #
65 64 * #_______________________# <- %ebp
66 65 *
67 66 *
68 67 * We must calculate the address at which ld.so was loaded,
69 68 * find the addr of the dynamic section of ld.so, of argv[0], and of
70 69 * the process' environment pointers - and pass the thing to _setup
71 70 * to handle. We then call _rtld - on return we jump to the entry
72 71 * point for the a.out.
73 72 */
74 73
75 74 #if defined(lint)
76 75
77 76 extern unsigned long _setup();
78 77 extern void atexit_fini();
79 78 void
80 79 main()
81 80 {
82 81 (void) _setup();
83 82 atexit_fini();
84 83 }
85 84
86 85 #else
87 86
↓ open down ↓ |
47 lines elided |
↑ open up ↑ |
88 87 #include <link.h>
89 88
90 89 .file "boot.s"
91 90 .text
92 91 .globl _rt_boot
93 92 .globl _setup
94 93 .globl _GLOBAL_OFFSET_TABLE_
95 94 .type _rt_boot,@function
96 95 .align 4
97 96
97 + / init is called from the _init symbol in the CRT, however .init_array
98 + / are called "naturally" from call_init. Because of that, we need the
99 + / stack aligned here so that initializers called via _array sections may
100 + / safely use SIMD instructions.
98 101 _rt_alias:
99 102 jmp .get_ip / in case we were invoked from libc.so
100 103 _rt_boot:
101 104 movl %esp,%ebp / save for referencing args
102 105 subl $EB_MAX_SIZE32,%esp / make room for a max sized boot vector
106 + andl $-16,%esp
107 + subl $8,%esp
103 108 movl %esp,%esi / use esi as a pointer to &eb[0]
104 109 movl $EB_ARGV,0(%esi) / set up tag for argv
105 110 leal 4(%ebp),%eax / get address of argv
106 111 movl %eax,4(%esi) / put after tag
107 112 movl $EB_ENVP,8(%esi) / set up tag for envp
108 113 movl (%ebp),%eax / get # of args
109 114 addl $2,%eax / one for the zero & one for argc
110 115 leal (%ebp,%eax,4),%edi / now points past args & @ envp
111 116 movl %edi,12(%esi) / set envp
112 117 .L0: addl $4,%edi / next
113 118 cmpl $0,-4(%edi) / search for 0 at end of env
114 119 jne .L0
115 120 movl $EB_AUXV,16(%esi) / set up tag for auxv
116 121 movl %edi,20(%esi) / point to auxv
117 122 movl $EB_NULL,24(%esi) / set up NULL tag
118 123 .get_ip:
119 124 call .L1 / only way to get IP into a register
120 125 .L1:
121 126 popl %ebx / pop the IP we just "pushed"
122 127 addl $_GLOBAL_OFFSET_TABLE_+[.-.L1],%ebx
123 128 pushl (%ebx) / address of dynamic structure
124 129 pushl %esi / push &eb[0]
125 130
126 131 call _setup@PLT / _setup(&eb[0], _DYNAMIC)
127 132 movl %ebp,%esp / release stack frame
128 133
129 134 movl atexit_fini@GOT(%ebx), %edx
130 135 jmp *%eax / transfer control to a.out
131 136 .size _rt_boot,.-_rt_boot
132 137
133 138 #endif
↓ open down ↓ |
21 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX