1 /* PLT trampolines. i386 version.
2 Copyright (C) 2004-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
20 #include <link-defines.h>
22 #ifdef HAVE_MPX_SUPPORT
23 # define PRESERVE_BND_REGS_PREFIX bnd
25 # define PRESERVE_BND_REGS_PREFIX .byte 0xf2
29 .globl _dl_runtime_resolve
30 .type _dl_runtime_resolve, @function
34 cfi_adjust_cfa_offset (8)
36 pushl %eax # Preserve registers otherwise clobbered.
37 cfi_adjust_cfa_offset (4)
39 cfi_adjust_cfa_offset (4)
41 cfi_adjust_cfa_offset (4)
42 movl 16(%esp), %edx # Copy args pushed by PLT in register. Note
43 movl 12(%esp), %eax # that `fixup' takes its parameters in regs.
44 call _dl_fixup # Call resolver.
45 popl %edx # Get register content back.
46 cfi_adjust_cfa_offset (-4)
48 movl %eax, (%esp) # Store the function address.
50 ret $12 # Jump to function address.
52 .size _dl_runtime_resolve, .-_dl_runtime_resolve
54 # The SHSTK compatible version.
56 .globl _dl_runtime_resolve_shstk
57 .type _dl_runtime_resolve_shstk, @function
60 _dl_runtime_resolve_shstk:
61 cfi_adjust_cfa_offset (8)
63 pushl %eax # Preserve registers otherwise clobbered.
64 cfi_adjust_cfa_offset (4)
66 cfi_adjust_cfa_offset (4)
67 movl 12(%esp), %edx # Copy args pushed by PLT in register. Note
68 movl 8(%esp), %eax # that `fixup' takes its parameters in regs.
69 call _dl_fixup # Call resolver.
70 movl (%esp), %edx # Get register content back.
71 movl %eax, %ecx # Store the function address.
72 movl 4(%esp), %eax # Get register content back.
73 addl $16, %esp # Adjust stack: PLT1 + PLT2 + %eax + %edx
74 cfi_adjust_cfa_offset (-16)
75 jmp *%ecx # Jump to function address.
77 .size _dl_runtime_resolve_shstk, .-_dl_runtime_resolve_shstk
80 # The SHSTK compatible version.
81 .globl _dl_runtime_profile_shstk
82 .type _dl_runtime_profile_shstk, @function
85 _dl_runtime_profile_shstk:
86 cfi_adjust_cfa_offset (8)
89 cfi_adjust_cfa_offset (4)
90 addl $8, (%esp) # Account for the pushed PLT data
92 cfi_adjust_cfa_offset (4)
93 pushl %eax # Preserve registers otherwise clobbered.
94 cfi_adjust_cfa_offset (4)
96 cfi_adjust_cfa_offset (4)
98 cfi_adjust_cfa_offset (4)
101 cfi_adjust_cfa_offset (8)
105 pushl %ecx # Address of the register structure
106 cfi_adjust_cfa_offset (4)
107 movl 40(%esp), %ecx # Load return address
108 movl 36(%esp), %edx # Copy args pushed by PLT in register. Note
109 movl 32(%esp), %eax # that `fixup' takes its parameters in regs.
110 call _dl_profile_fixup # Call resolver.
111 cfi_adjust_cfa_offset (-8)
115 movl 4(%esp), %edx # Get register content back.
116 movl %eax, %ecx # Store the function address.
117 movl 12(%esp), %eax # Get register content back.
118 # Adjust stack: PLT1 + PLT2 + %esp + %ebp + %eax + %ecx + %edx
121 cfi_adjust_cfa_offset (-32)
122 jmp *%ecx # Jump to function address.
124 .size _dl_runtime_profile_shstk, .-_dl_runtime_profile_shstk
126 .globl _dl_runtime_profile
127 .type _dl_runtime_profile, @function
131 cfi_adjust_cfa_offset (8)
134 cfi_adjust_cfa_offset (4)
135 addl $8, (%esp) # Account for the pushed PLT data
137 cfi_adjust_cfa_offset (4)
138 pushl %eax # Preserve registers otherwise clobbered.
139 cfi_adjust_cfa_offset (4)
141 cfi_adjust_cfa_offset (4)
143 cfi_adjust_cfa_offset (4)
146 cfi_adjust_cfa_offset (8)
150 pushl %ecx # Address of the register structure
151 cfi_adjust_cfa_offset (4)
152 movl 40(%esp), %ecx # Load return address
153 movl 36(%esp), %edx # Copy args pushed by PLT in register. Note
154 movl 32(%esp), %eax # that `fixup' takes its parameters in regs.
155 call _dl_profile_fixup # Call resolver.
156 cfi_adjust_cfa_offset (-8)
161 cfi_adjust_cfa_offset (-4)
162 popl %edx # Get register content back.
163 cfi_adjust_cfa_offset (-4)
165 movl %eax, (%esp) # Store the function address.
167 ret $20 # Jump to function address.
180 cfi_adjust_cfa_offset (8)
182 cfi_rel_offset (ebx, 0)
183 movl %edx, %ebx # This is the frame buffer size
185 cfi_adjust_cfa_offset (4)
186 cfi_rel_offset (edi, 0)
188 cfi_adjust_cfa_offset (4)
189 cfi_rel_offset (esi, 0)
192 orl $4, %ebx # Increase frame size if necessary to align
193 # stack for the function call
198 cfi_def_cfa_register (ebx)
208 %ebx+40 return address
219 %esp copied stack frame
227 cfi_def_cfa_register (esp)
243 #if LONG_DOUBLE_SIZE != 12
244 # error "long double size must be 12 bytes"
246 # Allocate space for La_i86_retval and subtract 12 free bytes.
247 subl $(LRV_SIZE - 12), %esp
248 cfi_adjust_cfa_offset (LRV_SIZE - 12)
249 movl %eax, LRV_EAX_OFFSET(%esp)
250 movl %edx, LRV_EDX_OFFSET(%esp)
251 fstpt LRV_ST0_OFFSET(%esp)
252 fstpt LRV_ST1_OFFSET(%esp)
253 #ifdef HAVE_MPX_SUPPORT
254 bndmov %bnd0, LRV_BND0_OFFSET(%esp)
255 bndmov %bnd1, LRV_BND1_OFFSET(%esp)
257 .byte 0x66,0x0f,0x1b,0x44,0x24,LRV_BND0_OFFSET
258 .byte 0x66,0x0f,0x1b,0x4c,0x24,LRV_BND1_OFFSET
261 cfi_adjust_cfa_offset (4)
262 # Address of La_i86_regs area.
263 leal (LRV_SIZE + 4)(%esp), %ecx
265 movl (LRV_SIZE + 4 + LR_SIZE)(%esp), %eax
267 movl (LRV_SIZE + 4 + LR_SIZE + 4)(%esp), %edx
268 call _dl_call_pltexit
269 movl LRV_EAX_OFFSET(%esp), %eax
270 movl LRV_EDX_OFFSET(%esp), %edx
271 fldt LRV_ST1_OFFSET(%esp)
272 fldt LRV_ST0_OFFSET(%esp)
273 #ifdef HAVE_MPX_SUPPORT
274 bndmov LRV_BND0_OFFSET(%esp), %bnd0
275 bndmov LRV_BND1_OFFSET(%esp), %bnd1
277 .byte 0x66,0x0f,0x1a,0x44,0x24,LRV_BND0_OFFSET
278 .byte 0x66,0x0f,0x1a,0x4c,0x24,LRV_BND1_OFFSET
280 # Restore stack before return.
281 addl $(LRV_SIZE + 4 + LR_SIZE + 4), %esp
282 cfi_adjust_cfa_offset (-(LRV_SIZE + 4 + LR_SIZE + 4))
283 PRESERVE_BND_REGS_PREFIX
286 .size _dl_runtime_profile, .-_dl_runtime_profile