1 /* PLT trampolines. i386 version.
2 Copyright (C) 2004-2017 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 <http://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)
35 pushl %eax # Preserve registers otherwise clobbered.
36 cfi_adjust_cfa_offset (4)
38 cfi_adjust_cfa_offset (4)
40 cfi_adjust_cfa_offset (4)
41 movl 16(%esp), %edx # Copy args pushed by PLT in register. Note
42 movl 12(%esp), %eax # that `fixup' takes its parameters in regs.
43 call _dl_fixup # Call resolver.
44 popl %edx # Get register content back.
45 cfi_adjust_cfa_offset (-4)
47 movl %eax, (%esp) # Store the function address.
49 ret $12 # Jump to function address.
51 .size _dl_runtime_resolve, .-_dl_runtime_resolve
55 .globl _dl_runtime_profile
56 .type _dl_runtime_profile, @function
60 cfi_adjust_cfa_offset (8)
62 cfi_adjust_cfa_offset (4)
63 addl $8, (%esp) # Account for the pushed PLT data
65 cfi_adjust_cfa_offset (4)
66 pushl %eax # Preserve registers otherwise clobbered.
67 cfi_adjust_cfa_offset (4)
69 cfi_adjust_cfa_offset (4)
71 cfi_adjust_cfa_offset (4)
74 cfi_adjust_cfa_offset (8)
78 pushl %ecx # Address of the register structure
79 cfi_adjust_cfa_offset (4)
80 movl 40(%esp), %ecx # Load return address
81 movl 36(%esp), %edx # Copy args pushed by PLT in register. Note
82 movl 32(%esp), %eax # that `fixup' takes its parameters in regs.
83 call _dl_profile_fixup # Call resolver.
84 cfi_adjust_cfa_offset (-8)
89 cfi_adjust_cfa_offset (-4)
90 popl %edx # Get register content back.
91 cfi_adjust_cfa_offset (-4)
93 movl %eax, (%esp) # Store the function address.
95 ret $20 # Jump to function address.
108 cfi_adjust_cfa_offset (8)
110 cfi_rel_offset (ebx, 0)
111 movl %edx, %ebx # This is the frame buffer size
113 cfi_adjust_cfa_offset (4)
114 cfi_rel_offset (edi, 0)
116 cfi_adjust_cfa_offset (4)
117 cfi_rel_offset (esi, 0)
120 orl $4, %ebx # Increase frame size if necessary to align
121 # stack for the function call
126 cfi_def_cfa_register (ebx)
136 %ebx+40 return address
147 %esp copied stack frame
155 cfi_def_cfa_register (esp)
171 #if LONG_DOUBLE_SIZE != 12
172 # error "long double size must be 12 bytes"
174 # Allocate space for La_i86_retval and subtract 12 free bytes.
175 subl $(LRV_SIZE - 12), %esp
176 cfi_adjust_cfa_offset (LRV_SIZE - 12)
177 movl %eax, LRV_EAX_OFFSET(%esp)
178 movl %edx, LRV_EDX_OFFSET(%esp)
179 fstpt LRV_ST0_OFFSET(%esp)
180 fstpt LRV_ST1_OFFSET(%esp)
181 #ifdef HAVE_MPX_SUPPORT
182 bndmov %bnd0, LRV_BND0_OFFSET(%esp)
183 bndmov %bnd1, LRV_BND1_OFFSET(%esp)
185 .byte 0x66,0x0f,0x1b,0x44,0x24,LRV_BND0_OFFSET
186 .byte 0x66,0x0f,0x1b,0x4c,0x24,LRV_BND1_OFFSET
189 cfi_adjust_cfa_offset (4)
190 # Address of La_i86_regs area.
191 leal (LRV_SIZE + 4)(%esp), %ecx
193 movl (LRV_SIZE + 4 + LR_SIZE)(%esp), %eax
195 movl (LRV_SIZE + 4 + LR_SIZE + 4)(%esp), %edx
196 call _dl_call_pltexit
197 movl LRV_EAX_OFFSET(%esp), %eax
198 movl LRV_EDX_OFFSET(%esp), %edx
199 fldt LRV_ST1_OFFSET(%esp)
200 fldt LRV_ST0_OFFSET(%esp)
201 #ifdef HAVE_MPX_SUPPORT
202 bndmov LRV_BND0_OFFSET(%esp), %bnd0
203 bndmov LRV_BND1_OFFSET(%esp), %bnd1
205 .byte 0x66,0x0f,0x1a,0x44,0x24,LRV_BND0_OFFSET
206 .byte 0x66,0x0f,0x1a,0x4c,0x24,LRV_BND1_OFFSET
208 # Restore stack before return.
209 addl $(LRV_SIZE + 4 + LR_SIZE + 4), %esp
210 cfi_adjust_cfa_offset (-(LRV_SIZE + 4 + LR_SIZE + 4))
211 PRESERVE_BND_REGS_PREFIX
214 .size _dl_runtime_profile, .-_dl_runtime_profile