Mercurial > illumos > illumos-gate
annotate usr/src/cmd/sgs/rtld/amd64/boot_elf.s @ 13675:a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Joshua M. Clulow <josh@sysmgr.org>
Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Approved by: Albert Lee <trisk@nexenta.com>
author | Robert Mustacchi <rm@joyent.com> |
---|---|
date | Wed, 25 Apr 2012 00:27:21 -0400 |
parents | ae3aa141e3fa |
children |
rev | line source |
---|---|
0 | 1 /* |
2 * CDDL HEADER START | |
3 * | |
4 * The contents of this file are subject to the terms of the | |
2133
f845bbe77e56
6431835 data corruption on x64 in 64-bit mode while LD_PROFILE is in effect
ab196087
parents:
0
diff
changeset
|
5 * Common Development and Distribution License (the "License"). |
f845bbe77e56
6431835 data corruption on x64 in 64-bit mode while LD_PROFILE is in effect
ab196087
parents:
0
diff
changeset
|
6 * You may not use this file except in compliance with the License. |
0 | 7 * |
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. | |
12 * | |
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] | |
18 * | |
19 * CDDL HEADER END | |
20 */ | |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
21 |
0 | 22 /* |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
24 * Use is subject to license terms. |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
25 * Copyright (c) 2012 Joyent, Inc. All rights reserved. |
0 | 26 */ |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
27 |
0 | 28 #if defined(lint) |
29 | |
30 #include <sys/types.h> | |
31 #include <_rtld.h> | |
32 #include <_audit.h> | |
33 #include <_elf.h> | |
34 #include <sys/regset.h> | |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
35 #include <sys/auxv_386.h> |
0 | 36 |
37 /* ARGSUSED0 */ | |
38 int | |
39 elf_plt_trace() | |
40 { | |
41 return (0); | |
42 } | |
43 #else | |
44 | |
45 #include <link.h> | |
46 #include <_audit.h> | |
47 #include <sys/asm_linkage.h> | |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
48 #include <sys/auxv_386.h> |
0 | 49 |
50 .file "boot_elf.s" | |
51 .text | |
52 | |
53 /* | |
54 * On entry the 'glue code' has already done the following: | |
55 * | |
56 * pushq %rbp | |
57 * movq %rsp, %rbp | |
58 * subq $0x10, %rsp | |
59 * leaq trace_fields(%rip), %r11 | |
60 * movq %r11, -0x8(%rbp) | |
61 * movq $elf_plt_trace, %r11 | |
62 * jmp *%r11 | |
63 * | |
64 * so - -8(%rbp) contains the dyndata ptr | |
65 * | |
66 * 0x0 Addr *reflmp | |
67 * 0x8 Addr *deflmp | |
68 * 0x10 Word symndx | |
69 * 0x14 Word sb_flags | |
70 * 0x18 Sym symdef.st_name | |
71 * 0x1c symdef.st_info | |
72 * 0x1d symdef.st_other | |
73 * 0x1e symdef.st_shndx | |
74 * 0x20 symdef.st_value | |
75 * 0x28 symdef.st_size | |
76 * | |
77 * Also note - on entry 16 bytes have already been subtracted | |
78 * from the %rsp. The first 8 bytes is for the dyn_data_ptr, | |
79 * the second 8 bytes are to align the stack and are available | |
80 * for use. | |
81 */ | |
82 #define REFLMP_OFF 0x0 | |
83 #define DEFLMP_OFF 0x8 | |
84 #define SYMNDX_OFF 0x10 | |
85 #define SBFLAGS_OFF 0x14 | |
86 #define SYMDEF_OFF 0x18 | |
87 #define SYMDEF_VALUE_OFF 0x20 | |
88 /* | |
89 * Local stack space storage for elf_plt_trace is allocated | |
90 * as follows: | |
91 * | |
92 * First - before we got here - %rsp has been decremented | |
93 * by 0x10 to make space for the dyndata ptr (and another | |
94 * free word). In addition to that, we create space | |
95 * for the following: | |
96 * | |
97 * La_amd64_regs 8 * 8: 64 | |
98 * prev_stack_size 8 8 | |
99 * Saved regs: | |
100 * %rdi 8 | |
101 * %rsi 8 | |
102 * %rdx 8 | |
103 * %rcx 8 | |
104 * %r8 8 | |
105 * %r9 8 | |
106 * %r10 8 | |
107 * %r11 8 | |
108 * %rax 8 | |
109 * ======= | |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
110 * Subtotal: 144 (32byte aligned) |
2133
f845bbe77e56
6431835 data corruption on x64 in 64-bit mode while LD_PROFILE is in effect
ab196087
parents:
0
diff
changeset
|
111 * |
f845bbe77e56
6431835 data corruption on x64 in 64-bit mode while LD_PROFILE is in effect
ab196087
parents:
0
diff
changeset
|
112 * Saved Media Regs (used to pass floating point args): |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
113 * %xmm0 - %xmm7 32 * 8: 256 |
2133
f845bbe77e56
6431835 data corruption on x64 in 64-bit mode while LD_PROFILE is in effect
ab196087
parents:
0
diff
changeset
|
114 * ======= |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
115 * Total: 400 (32byte aligned) |
0 | 116 * |
117 * So - will subtract the following to create enough space | |
118 * | |
119 * -8(%rbp) store dyndata ptr | |
120 * -16(%rbp) store call destination | |
121 * -80(%rbp) space for La_amd64_regs | |
122 * -88(%rbp) prev stack size | |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
123 * The next %rbp offsets are only true if the caller had correct stack |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
124 * alignment. See note above SPRDIOFF for why we use %rsp alignment to |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
125 * access these stack fields. |
0 | 126 * -96(%rbp) entering %rdi |
127 * -104(%rbp) entering %rsi | |
128 * -112(%rbp) entering %rdx | |
129 * -120(%rbp) entering %rcx | |
130 * -128(%rbp) entering %r8 | |
131 * -136(%rbp) entering %r9 | |
132 * -144(%rbp) entering %r10 | |
133 * -152(%rbp) entering %r11 | |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
134 * -160(%rbp) entering %rax |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
135 * -192(%rbp) entering %xmm0 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
136 * -224(%rbp) entering %xmm1 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
137 * -256(%rbp) entering %xmm2 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
138 * -288(%rbp) entering %xmm3 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
139 * -320(%rbp) entering %xmm4 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
140 * -384(%rbp) entering %xmm5 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
141 * -416(%rbp) entering %xmm6 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
142 * -448(%rbp) entering %xmm7 |
0 | 143 * |
144 */ | |
145 #define SPDYNOFF -8 | |
146 #define SPDESTOFF -16 | |
147 #define SPLAREGOFF -80 | |
148 #define SPPRVSTKOFF -88 | |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
149 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
150 /* |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
151 * The next set of offsets are relative to %rsp. |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
152 * We guarantee %rsp is ABI compliant 32-byte aligned. This guarantees the |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
153 * ymm registers are saved to 32-byte aligned addresses. |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
154 * %rbp may only be 8 byte aligned if we came in from non-ABI compliant code. |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
155 */ |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
156 #define SPRDIOFF 320 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
157 #define SPRSIOFF 312 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
158 #define SPRDXOFF 304 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
159 #define SPRCXOFF 296 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
160 #define SPR8OFF 288 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
161 #define SPR9OFF 280 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
162 #define SPR10OFF 272 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
163 #define SPR11OFF 264 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
164 #define SPRAXOFF 256 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
165 #define SPXMM0OFF 224 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
166 #define SPXMM1OFF 192 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
167 #define SPXMM2OFF 160 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
168 #define SPXMM3OFF 128 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
169 #define SPXMM4OFF 96 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
170 #define SPXMM5OFF 64 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
171 #define SPXMM6OFF 32 |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
172 #define SPXMM7OFF 0 |
0 | 173 |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
174 /* See elf_rtbndr for explanation behind org_scapset */ |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
175 .extern org_scapset |
0 | 176 .globl elf_plt_trace |
177 .type elf_plt_trace,@function | |
178 .align 16 | |
179 elf_plt_trace: | |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
180 /* |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
181 * Enforce ABI 32-byte stack alignment here. |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
182 * The next andq instruction does this pseudo code: |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
183 * If %rsp is 8 byte aligned then subtract 8 from %rsp. |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
184 */ |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
185 andq $-32, %rsp /* enforce ABI 32-byte stack alignment */ |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
186 subq $400,%rsp / create some local storage |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
187 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
188 movq %rdi, SPRDIOFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
189 movq %rsi, SPRSIOFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
190 movq %rdx, SPRDXOFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
191 movq %rcx, SPRCXOFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
192 movq %r8, SPR8OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
193 movq %r9, SPR9OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
194 movq %r10, SPR10OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
195 movq %r11, SPR11OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
196 movq %rax, SPRAXOFF(%rsp) |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
197 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
198 movq org_scapset@GOTPCREL(%rip),%r9 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
199 movq (%r9),%r9 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
200 movl (%r9),%edx |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
201 testl $AV_386_AVX,%edx |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
202 jne .trace_save_ymm |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
203 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
204 .trace_save_xmm: |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
205 movdqa %xmm0, SPXMM0OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
206 movdqa %xmm1, SPXMM1OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
207 movdqa %xmm2, SPXMM2OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
208 movdqa %xmm3, SPXMM3OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
209 movdqa %xmm4, SPXMM4OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
210 movdqa %xmm5, SPXMM5OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
211 movdqa %xmm6, SPXMM6OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
212 movdqa %xmm7, SPXMM7OFF(%rsp) |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
213 jmp .trace_save_finish |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
214 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
215 .trace_save_ymm: |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
216 vmovdqa %ymm0, SPXMM0OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
217 vmovdqa %ymm1, SPXMM1OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
218 vmovdqa %ymm2, SPXMM2OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
219 vmovdqa %ymm3, SPXMM3OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
220 vmovdqa %ymm4, SPXMM4OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
221 vmovdqa %ymm5, SPXMM5OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
222 vmovdqa %ymm6, SPXMM6OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
223 vmovdqa %ymm7, SPXMM7OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
224 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
225 .trace_save_finish: |
0 | 226 |
227 movq SPDYNOFF(%rbp), %rax / %rax = dyndata | |
228 testb $LA_SYMB_NOPLTENTER, SBFLAGS_OFF(%rax) / <link.h> | |
229 je .start_pltenter | |
230 movq SYMDEF_VALUE_OFF(%rax), %rdi | |
231 movq %rdi, SPDESTOFF(%rbp) / save destination address | |
232 jmp .end_pltenter | |
233 | |
234 .start_pltenter: | |
235 /* | |
236 * save all registers into La_amd64_regs | |
237 */ | |
238 leaq SPLAREGOFF(%rbp), %rsi / %rsi = &La_amd64_regs | |
239 leaq 8(%rbp), %rdi | |
240 movq %rdi, 0(%rsi) / la_rsp | |
241 movq 0(%rbp), %rdi | |
242 movq %rdi, 8(%rsi) / la_rbp | |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
243 movq SPRDIOFF(%rsp), %rdi |
0 | 244 movq %rdi, 16(%rsi) / la_rdi |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
245 movq SPRSIOFF(%rsp), %rdi |
0 | 246 movq %rdi, 24(%rsi) / la_rsi |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
247 movq SPRDXOFF(%rsp), %rdi |
0 | 248 movq %rdi, 32(%rsi) / la_rdx |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
249 movq SPRCXOFF(%rsp), %rdi |
0 | 250 movq %rdi, 40(%rsi) / la_rcx |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
251 movq SPR8OFF(%rsp), %rdi |
0 | 252 movq %rdi, 48(%rsi) / la_r8 |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
253 movq SPR9OFF(%rsp), %rdi |
0 | 254 movq %rdi, 56(%rsi) / la_r9 |
255 | |
256 /* | |
257 * prepare for call to la_pltenter | |
258 */ | |
259 movq SPDYNOFF(%rbp), %r11 / %r11 = &dyndata | |
260 leaq SBFLAGS_OFF(%r11), %r9 / arg6 (&sb_flags) | |
261 leaq SPLAREGOFF(%rbp), %r8 / arg5 (&La_amd64_regs) | |
262 movl SYMNDX_OFF(%r11), %ecx / arg4 (symndx) | |
263 leaq SYMDEF_OFF(%r11), %rdx / arg3 (&Sym) | |
264 movq DEFLMP_OFF(%r11), %rsi / arg2 (dlmp) | |
265 movq REFLMP_OFF(%r11), %rdi / arg1 (rlmp) | |
266 call audit_pltenter@PLT | |
267 movq %rax, SPDESTOFF(%rbp) / save calling address | |
268 .end_pltenter: | |
269 | |
270 /* | |
271 * If *no* la_pltexit() routines exist | |
272 * we do not need to keep the stack frame | |
273 * before we call the actual routine. Instead we | |
274 * jump to it and remove our stack from the stack | |
275 * at the same time. | |
276 */ | |
277 movl audit_flags(%rip), %eax | |
278 andl $AF_PLTEXIT, %eax / value of audit.h:AF_PLTEXIT | |
279 cmpl $0, %eax | |
280 je .bypass_pltexit | |
281 /* | |
282 * Has the *nopltexit* flag been set for this entry point | |
283 */ | |
284 movq SPDYNOFF(%rbp), %r11 / %r11 = &dyndata | |
285 testb $LA_SYMB_NOPLTEXIT, SBFLAGS_OFF(%r11) | |
286 je .start_pltexit | |
287 | |
288 .bypass_pltexit: | |
289 /* | |
290 * No PLTEXIT processing required. | |
291 */ | |
292 movq 0(%rbp), %r11 | |
293 movq %r11, -8(%rbp) / move prev %rbp | |
294 movq SPDESTOFF(%rbp), %r11 / r11 == calling destination | |
295 movq %r11, 0(%rbp) / store destination at top | |
296 | |
297 / | |
298 / Restore registers | |
299 / | |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
300 movq org_scapset@GOTPCREL(%rip),%r9 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
301 movq (%r9),%r9 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
302 movl (%r9),%edx |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
303 testl $AV_386_AVX,%edx |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
304 jne .trace_restore_ymm |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
305 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
306 .trace_restore_xmm: |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
307 movdqa SPXMM0OFF(%rsp), %xmm0 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
308 movdqa SPXMM1OFF(%rsp), %xmm1 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
309 movdqa SPXMM2OFF(%rsp), %xmm2 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
310 movdqa SPXMM3OFF(%rsp), %xmm3 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
311 movdqa SPXMM4OFF(%rsp), %xmm4 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
312 movdqa SPXMM5OFF(%rsp), %xmm5 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
313 movdqa SPXMM6OFF(%rsp), %xmm6 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
314 movdqa SPXMM7OFF(%rsp), %xmm7 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
315 jmp .trace_restore_finish |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
316 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
317 .trace_restore_ymm: |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
318 vmovdqa SPXMM0OFF(%rsp), %ymm0 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
319 vmovdqa SPXMM1OFF(%rsp), %ymm1 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
320 vmovdqa SPXMM2OFF(%rsp), %ymm2 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
321 vmovdqa SPXMM3OFF(%rsp), %ymm3 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
322 vmovdqa SPXMM4OFF(%rsp), %ymm4 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
323 vmovdqa SPXMM5OFF(%rsp), %ymm5 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
324 vmovdqa SPXMM6OFF(%rsp), %ymm6 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
325 vmovdqa SPXMM7OFF(%rsp), %ymm7 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
326 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
327 .trace_restore_finish: |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
328 movq SPRDIOFF(%rsp), %rdi |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
329 movq SPRSIOFF(%rsp), %rsi |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
330 movq SPRDXOFF(%rsp), %rdx |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
331 movq SPRCXOFF(%rsp), %rcx |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
332 movq SPR8OFF(%rsp), %r8 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
333 movq SPR9OFF(%rsp), %r9 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
334 movq SPR10OFF(%rsp), %r10 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
335 movq SPR11OFF(%rsp), %r11 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
336 movq SPRAXOFF(%rsp), %rax |
0 | 337 |
338 subq $8, %rbp / adjust %rbp for 'ret' | |
339 movq %rbp, %rsp / | |
340 /* | |
341 * At this point, after a little doctoring, we should | |
342 * have the following on the stack: | |
343 * | |
344 * 16(%rsp): ret addr | |
345 * 8(%rsp): dest_addr | |
346 * 0(%rsp): Previous %rbp | |
347 * | |
348 * So - we pop the previous %rbp, and then | |
349 * ret to our final destination. | |
350 */ | |
351 popq %rbp / | |
352 ret / jmp to final destination | |
353 / and clean up stack :) | |
354 | |
355 .start_pltexit: | |
356 /* | |
357 * In order to call the destination procedure and then return | |
358 * to audit_pltexit() for post analysis we must first grow | |
359 * our stack frame and then duplicate the original callers | |
360 * stack state. This duplicates all of the arguements | |
361 * that were to be passed to the destination procedure. | |
362 */ | |
363 movq %rbp, %rdi / | |
364 addq $16, %rdi / %rdi = src | |
365 movq (%rbp), %rdx / | |
366 subq %rdi, %rdx / %rdx == prev frame sz | |
367 /* | |
368 * If audit_argcnt > 0 then we limit the number of | |
369 * arguements that will be duplicated to audit_argcnt. | |
370 * | |
371 * If (prev_stack_size > (audit_argcnt * 8)) | |
372 * prev_stack_size = audit_argcnt * 8; | |
373 */ | |
374 movl audit_argcnt(%rip),%eax / %eax = audit_argcnt | |
375 cmpl $0, %eax | |
376 jle .grow_stack | |
377 leaq (,%rax,8), %rax / %eax = %eax * 4 | |
378 cmpq %rax,%rdx | |
379 jle .grow_stack | |
380 movq %rax, %rdx | |
381 /* | |
382 * Grow the stack and duplicate the arguements of the | |
383 * original caller. | |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
384 * |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
385 * We save %rsp in %r11 since we need to use the current rsp for |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
386 * accessing the registers saved in our stack frame. |
0 | 387 */ |
388 .grow_stack: | |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
389 movq %rsp, %r11 |
0 | 390 subq %rdx, %rsp / grow the stack |
391 movq %rdx, SPPRVSTKOFF(%rbp) / -88(%rbp) == prev frame sz | |
392 movq %rsp, %rcx / %rcx = dest | |
393 addq %rcx, %rdx / %rdx == tail of dest | |
394 .while_base: | |
395 cmpq %rdx, %rcx / while (base+size >= src++) { | |
396 jge .end_while / | |
397 movq (%rdi), %rsi | |
398 movq %rsi,(%rcx) / *dest = *src | |
399 addq $8, %rdi / src++ | |
400 addq $8, %rcx / dest++ | |
401 jmp .while_base / } | |
402 | |
403 /* | |
404 * The above stack is now an exact duplicate of | |
405 * the stack of the original calling procedure. | |
406 */ | |
407 .end_while: | |
408 / | |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
409 / Restore registers using %r11 which contains our old %rsp value |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
410 / before growing the stack. |
0 | 411 / |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
412 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
413 / Yes, we have to do this dance again. Sorry. |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
414 movq org_scapset@GOTPCREL(%rip),%r9 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
415 movq (%r9),%r9 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
416 movl (%r9),%edx |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
417 testl $AV_386_AVX,%edx |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
418 jne .trace_r2_ymm |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
419 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
420 .trace_r2_xmm: |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
421 movdqa SPXMM0OFF(%r11), %xmm0 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
422 movdqa SPXMM1OFF(%r11), %xmm1 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
423 movdqa SPXMM2OFF(%r11), %xmm2 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
424 movdqa SPXMM3OFF(%r11), %xmm3 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
425 movdqa SPXMM4OFF(%r11), %xmm4 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
426 movdqa SPXMM5OFF(%r11), %xmm5 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
427 movdqa SPXMM6OFF(%r11), %xmm6 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
428 movdqa SPXMM7OFF(%r11), %xmm7 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
429 jmp .trace_r2_finish |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
430 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
431 .trace_r2_ymm: |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
432 vmovdqa SPXMM0OFF(%r11), %ymm0 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
433 vmovdqa SPXMM1OFF(%r11), %ymm1 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
434 vmovdqa SPXMM2OFF(%r11), %ymm2 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
435 vmovdqa SPXMM3OFF(%r11), %ymm3 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
436 vmovdqa SPXMM4OFF(%r11), %ymm4 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
437 vmovdqa SPXMM5OFF(%r11), %ymm5 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
438 vmovdqa SPXMM6OFF(%r11), %ymm6 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
439 vmovdqa SPXMM7OFF(%r11), %ymm7 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
440 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
441 .trace_r2_finish: |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
442 movq SPRDIOFF(%r11), %rdi |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
443 movq SPRSIOFF(%r11), %rsi |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
444 movq SPRDXOFF(%r11), %rdx |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
445 movq SPRCXOFF(%r11), %rcx |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
446 movq SPR8OFF(%r11), %r8 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
447 movq SPR9OFF(%r11), %r9 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
448 movq SPR10OFF(%r11), %r10 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
449 movq SPRAXOFF(%r11), %rax |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
450 movq SPR11OFF(%r11), %r11 / retore %r11 last |
0 | 451 |
452 /* | |
453 * Call to desitnation function - we'll return here | |
454 * for pltexit monitoring. | |
455 */ | |
456 call *SPDESTOFF(%rbp) | |
457 | |
458 addq SPPRVSTKOFF(%rbp), %rsp / cleanup dupped stack | |
459 | |
460 / | |
461 / prepare for call to audit_pltenter() | |
462 / | |
463 movq SPDYNOFF(%rbp), %r11 / %r11 = &dyndata | |
464 movq SYMNDX_OFF(%r11), %r8 / arg5 (symndx) | |
465 leaq SYMDEF_OFF(%r11), %rcx / arg4 (&Sym) | |
466 movq DEFLMP_OFF(%r11), %rdx / arg3 (dlmp) | |
467 movq REFLMP_OFF(%r11), %rsi / arg2 (rlmp) | |
468 movq %rax, %rdi / arg1 (returnval) | |
469 call audit_pltexit@PLT | |
470 | |
471 /* | |
472 * Clean up after ourselves and return to the | |
473 * original calling procedure. | |
474 */ | |
475 | |
476 / | |
477 / Restore registers | |
478 / | |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
479 movq SPRDIOFF(%rsp), %rdi |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
480 movq SPRSIOFF(%rsp), %rsi |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
481 movq SPRDXOFF(%rsp), %rdx |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
482 movq SPRCXOFF(%rsp), %rcx |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
483 movq SPR8OFF(%rsp), %r8 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
484 movq SPR9OFF(%rsp), %r9 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
485 movq SPR10OFF(%rsp), %r10 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
486 movq SPR11OFF(%rsp), %r11 |
0 | 487 // rax already contains return value |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
488 movdqa SPXMM0OFF(%rsp), %xmm0 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
489 movdqa SPXMM1OFF(%rsp), %xmm1 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
490 movdqa SPXMM2OFF(%rsp), %xmm2 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
491 movdqa SPXMM3OFF(%rsp), %xmm3 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
492 movdqa SPXMM4OFF(%rsp), %xmm4 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
493 movdqa SPXMM5OFF(%rsp), %xmm5 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
494 movdqa SPXMM6OFF(%rsp), %xmm6 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
495 movdqa SPXMM7OFF(%rsp), %xmm7 |
0 | 496 |
497 movq %rbp, %rsp / | |
498 popq %rbp / | |
499 ret / return to caller | |
500 .size elf_plt_trace, .-elf_plt_trace | |
501 #endif | |
502 | |
503 /* | |
504 * We got here because a call to a function resolved to a procedure | |
505 * linkage table entry. That entry did a JMPL to the first PLT entry, which | |
506 * in turn did a call to elf_rtbndr. | |
507 * | |
508 * the code sequence that got us here was: | |
509 * | |
510 * .PLT0: | |
511 * pushq GOT+8(%rip) #GOT[1] | |
512 * jmp *GOT+16(%rip) #GOT[2] | |
513 * nop | |
514 * nop | |
515 * nop | |
516 * nop | |
517 * ... | |
518 * PLT entry for foo: | |
519 * jmp *name1@GOTPCREL(%rip) | |
520 * pushl $rel.plt.foo | |
521 * jmp PLT0 | |
522 * | |
523 * At entry, the stack looks like this: | |
524 * | |
525 * return address 16(%rsp) | |
526 * $rel.plt.foo (plt index) 8(%rsp) | |
527 * lmp 0(%rsp) | |
528 * | |
529 */ | |
530 #if defined(lint) | |
531 | |
532 extern unsigned long elf_bndr(Rt_map *, unsigned long, caddr_t); | |
533 | |
534 void | |
535 elf_rtbndr(Rt_map * lmp, unsigned long reloc, caddr_t pc) | |
536 { | |
537 (void) elf_bndr(lmp, reloc, pc); | |
538 } | |
539 | |
540 #else | |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
541 |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
542 /* |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
543 * The PLT code that landed us here placed 2 arguments on the stack as |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
544 * arguments to elf_rtbndr. |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
545 * Additionally the pc of caller is below these 2 args. |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
546 * Our stack will look like this after we establish a stack frame with |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
547 * push %rbp; movq %rsp, %rbp sequence: |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
548 * |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
549 * 8(%rbp) arg1 - *lmp |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
550 * 16(%rbp), %rsi arg2 - reloc index |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
551 * 24(%rbp), %rdx arg3 - pc of caller |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
552 */ |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
553 #define LBPLMPOFF 8 /* arg1 - *lmp */ |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
554 #define LBPRELOCOFF 16 /* arg2 - reloc index */ |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
555 #define LBRPCOFF 24 /* arg3 - pc of caller */ |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
556 |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
557 /* |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
558 * Possible arguments for the resolved function are in registers as per |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
559 * the AMD64 ABI. We must save on the local stack all possible register |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
560 * arguments before interposing functions to resolve the called function. |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
561 * Possible arguments must be restored before invoking the resolved function. |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
562 * |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
563 * Before the AVX instruction set enhancements to AMD64 there were no changes in |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
564 * the set of registers and their sizes across different processors. With AVX, |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
565 * the xmm registers became the lower 128 bits of the ymm registers. Because of |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
566 * this, we need to conditionally save 256 bits instead of 128 bits. Regardless |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
567 * of whether we have ymm registers or not, we're always going to push the stack |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
568 * space assuming that we do to simplify the code. |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
569 * |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
570 * Local stack space storage for elf_rtbndr is allocated as follows: |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
571 * |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
572 * Saved regs: |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
573 * %rax 8 |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
574 * %rdi 8 |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
575 * %rsi 8 |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
576 * %rdx 8 |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
577 * %rcx 8 |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
578 * %r8 8 |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
579 * %r9 8 |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
580 * %r10 8 |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
581 * ======= |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
582 * Subtotal: 64 (32byte aligned) |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
583 * |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
584 * Saved Media Regs (used to pass floating point args): |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
585 * %ymm0 - %ymm7 32 * 8 256 |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
586 * ======= |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
587 * Total: 320 (32byte aligned) |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
588 * |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
589 * So - will subtract the following to create enough space |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
590 * |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
591 * 0(%rsp) save %rax |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
592 * 8(%rsp) save %rdi |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
593 * 16(%rsp) save %rsi |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
594 * 24(%rsp) save %rdx |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
595 * 32(%rsp) save %rcx |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
596 * 40(%rsp) save %r8 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
597 * 48(%rsp) save %r9 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
598 * 56(%rsp) save %r10 |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
599 * 64(%rsp) save %ymm0 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
600 * 96(%rsp) save %ymm1 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
601 * 128(%rsp) save %ymm2 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
602 * 160(%rsp) save %ymm3 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
603 * 192(%rsp) save %ymm4 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
604 * 224(%rsp) save %ymm5 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
605 * 256(%rsp) save %ymm6 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
606 * 288(%rsp) save %ymm7 |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
607 * |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
608 * Note: Some callers may use 8-byte stack alignment instead of the |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
609 * ABI required 16-byte alignment. We use %rsp offsets to save/restore |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
610 * registers because %rbp may not be 16-byte aligned. We guarantee %rsp |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
611 * is 16-byte aligned in the function preamble. |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
612 */ |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
613 /* |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
614 * As the registers may either be xmm or ymm, we've left the name as xmm, but |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
615 * increased the offset between them to always cover the xmm and ymm cases. |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
616 */ |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
617 #define LS_SIZE $320 /* local stack space to save all possible arguments */ |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
618 #define LSRAXOFF 0 /* for SSE register count */ |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
619 #define LSRDIOFF 8 /* arg 0 ... */ |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
620 #define LSRSIOFF 16 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
621 #define LSRDXOFF 24 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
622 #define LSRCXOFF 32 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
623 #define LSR8OFF 40 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
624 #define LSR9OFF 48 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
625 #define LSR10OFF 56 /* ... arg 5 */ |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
626 #define LSXMM0OFF 64 /* SSE arg 0 ... */ |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
627 #define LSXMM1OFF 96 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
628 #define LSXMM2OFF 128 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
629 #define LSXMM3OFF 160 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
630 #define LSXMM4OFF 192 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
631 #define LSXMM5OFF 224 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
632 #define LSXMM6OFF 256 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
633 #define LSXMM7OFF 288 /* ... SSE arg 7 */ |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
634 |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
635 /* |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
636 * The org_scapset is a global variable that is a part of rtld. It |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
637 * contains the capabilities that the kernel has told us are supported |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
638 * (auxv_hwcap). This is necessary for determining whether or not we |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
639 * need to save and restore AVX registers or simple SSE registers. Note, |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
640 * that the field we care about is currently at offset 0, if that |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
641 * changes, this code will have to be updated. |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
642 */ |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
643 .extern org_scapset |
0 | 644 .weak _elf_rtbndr |
645 _elf_rtbndr = elf_rtbndr | |
646 | |
647 ENTRY(elf_rtbndr) | |
648 | |
649 pushq %rbp | |
650 movq %rsp, %rbp | |
651 | |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
652 /* |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
653 * Some libraries may (incorrectly) use non-ABI compliant 8-byte stack |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
654 * alignment. Enforce ABI 16-byte stack alignment here. |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
655 * The next andq instruction does this pseudo code: |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
656 * If %rsp is 8 byte aligned then subtract 8 from %rsp. |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
657 */ |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
658 andq $-32, %rsp /* enforce ABI 32-byte stack alignment */ |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
659 |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
660 subq LS_SIZE, %rsp /* save all ABI defined argument registers */ |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
661 |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
662 movq %rax, LSRAXOFF(%rsp) /* for SSE register count */ |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
663 movq %rdi, LSRDIOFF(%rsp) /* arg 0 .. */ |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
664 movq %rsi, LSRSIOFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
665 movq %rdx, LSRDXOFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
666 movq %rcx, LSRCXOFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
667 movq %r8, LSR8OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
668 movq %r9, LSR9OFF(%rsp) /* .. arg 5 */ |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
669 movq %r10, LSR10OFF(%rsp) /* call chain reg */ |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
670 |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
671 /* |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
672 * Our xmm registers could secretly by ymm registers in disguise. |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
673 */ |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
674 movq org_scapset@GOTPCREL(%rip),%r9 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
675 movq (%r9),%r9 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
676 movl (%r9),%edx |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
677 testl $AV_386_AVX,%edx |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
678 jne .save_ymm |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
679 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
680 .save_xmm: |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
681 movdqa %xmm0, LSXMM0OFF(%rsp) /* SSE arg 0 ... */ |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
682 movdqa %xmm1, LSXMM1OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
683 movdqa %xmm2, LSXMM2OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
684 movdqa %xmm3, LSXMM3OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
685 movdqa %xmm4, LSXMM4OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
686 movdqa %xmm5, LSXMM5OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
687 movdqa %xmm6, LSXMM6OFF(%rsp) |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
688 movdqa %xmm7, LSXMM7OFF(%rsp) /* ... SSE arg 7 */ |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
689 jmp .save_finish |
0 | 690 |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
691 .save_ymm: |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
692 vmovdqa %ymm0, LSXMM0OFF(%rsp) /* SSE arg 0 ... */ |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
693 vmovdqa %ymm1, LSXMM1OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
694 vmovdqa %ymm2, LSXMM2OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
695 vmovdqa %ymm3, LSXMM3OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
696 vmovdqa %ymm4, LSXMM4OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
697 vmovdqa %ymm5, LSXMM5OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
698 vmovdqa %ymm6, LSXMM6OFF(%rsp) |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
699 vmovdqa %ymm7, LSXMM7OFF(%rsp) /* ... SSE arg 7 */ |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
700 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
701 .save_finish: |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
702 movq LBPLMPOFF(%rbp), %rdi /* arg1 - *lmp */ |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
703 movq LBPRELOCOFF(%rbp), %rsi /* arg2 - reloc index */ |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
704 movq LBRPCOFF(%rbp), %rdx /* arg3 - pc of caller */ |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
705 call elf_bndr@PLT /* call elf_rtbndr(lmp, relndx, pc) */ |
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
706 movq %rax, LBPRELOCOFF(%rbp) /* store final destination */ |
0 | 707 |
13675
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
708 /* |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
709 * Restore possible arguments before invoking resolved function. We |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
710 * check the xmm vs. ymm regs first so we can use the others. |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
711 */ |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
712 movq org_scapset@GOTPCREL(%rip),%r9 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
713 movq (%r9),%r9 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
714 movl (%r9),%edx |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
715 testl $AV_386_AVX,%edx |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
716 jne .restore_ymm |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
717 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
718 .restore_xmm: |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
719 movdqa LSXMM0OFF(%rsp), %xmm0 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
720 movdqa LSXMM1OFF(%rsp), %xmm1 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
721 movdqa LSXMM2OFF(%rsp), %xmm2 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
722 movdqa LSXMM3OFF(%rsp), %xmm3 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
723 movdqa LSXMM4OFF(%rsp), %xmm4 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
724 movdqa LSXMM5OFF(%rsp), %xmm5 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
725 movdqa LSXMM6OFF(%rsp), %xmm6 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
726 movdqa LSXMM7OFF(%rsp), %xmm7 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
727 jmp .restore_finish |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
728 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
729 .restore_ymm: |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
730 vmovdqa LSXMM0OFF(%rsp), %ymm0 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
731 vmovdqa LSXMM1OFF(%rsp), %ymm1 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
732 vmovdqa LSXMM2OFF(%rsp), %ymm2 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
733 vmovdqa LSXMM3OFF(%rsp), %ymm3 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
734 vmovdqa LSXMM4OFF(%rsp), %ymm4 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
735 vmovdqa LSXMM5OFF(%rsp), %ymm5 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
736 vmovdqa LSXMM6OFF(%rsp), %ymm6 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
737 vmovdqa LSXMM7OFF(%rsp), %ymm7 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
738 |
a9ae30c28ee4
2413 %ymm* need to be preserved on way through PLT
Robert Mustacchi <rm@joyent.com>
parents:
6186
diff
changeset
|
739 .restore_finish: |
6186
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
740 movq LSRAXOFF(%rsp), %rax |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
741 movq LSRDIOFF(%rsp), %rdi |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
742 movq LSRSIOFF(%rsp), %rsi |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
743 movq LSRDXOFF(%rsp), %rdx |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
744 movq LSRCXOFF(%rsp), %rcx |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
745 movq LSR8OFF(%rsp), %r8 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
746 movq LSR9OFF(%rsp), %r9 |
ae3aa141e3fa
6672544 elf_rtbndr must support non-ABI aligned stacks on amd64
bholler
parents:
6158
diff
changeset
|
747 movq LSR10OFF(%rsp), %r10 |
6158
685e2f65770b
6668050 First trip through PLT does not preserve args in xmm registers
bholler
parents:
2133
diff
changeset
|
748 |
0 | 749 movq %rbp, %rsp |
750 popq %rbp | |
751 | |
752 addq $8, %rsp /* pop 1st plt-pushed args */ | |
753 /* the second arguement is used */ | |
754 /* for the 'return' address to our */ | |
755 /* final destination */ | |
756 | |
757 ret /* invoke resolved function */ | |
758 .size elf_rtbndr, .-elf_rtbndr | |
759 #endif |