|
Packit |
6c4009 |
/* PLT trampolines. i386 version.
|
|
Packit |
6c4009 |
Copyright (C) 2004-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <sysdep.h>
|
|
Packit |
6c4009 |
#include <link-defines.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef HAVE_MPX_SUPPORT
|
|
Packit |
6c4009 |
# define PRESERVE_BND_REGS_PREFIX bnd
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define PRESERVE_BND_REGS_PREFIX .byte 0xf2
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.text
|
|
Packit |
6c4009 |
.globl _dl_runtime_resolve
|
|
Packit |
6c4009 |
.type _dl_runtime_resolve, @function
|
|
Packit |
6c4009 |
cfi_startproc
|
|
Packit |
6c4009 |
.align 16
|
|
Packit |
6c4009 |
_dl_runtime_resolve:
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (8)
|
|
Packit |
6c4009 |
_CET_ENDBR
|
|
Packit |
6c4009 |
pushl %eax # Preserve registers otherwise clobbered.
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
pushl %ecx
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
pushl %edx
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
movl 16(%esp), %edx # Copy args pushed by PLT in register. Note
|
|
Packit |
6c4009 |
movl 12(%esp), %eax # that `fixup' takes its parameters in regs.
|
|
Packit |
6c4009 |
call _dl_fixup # Call resolver.
|
|
Packit |
6c4009 |
popl %edx # Get register content back.
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-4)
|
|
Packit |
6c4009 |
movl (%esp), %ecx
|
|
Packit |
6c4009 |
movl %eax, (%esp) # Store the function address.
|
|
Packit |
6c4009 |
movl 4(%esp), %eax
|
|
Packit |
6c4009 |
ret $12 # Jump to function address.
|
|
Packit |
6c4009 |
cfi_endproc
|
|
Packit |
6c4009 |
.size _dl_runtime_resolve, .-_dl_runtime_resolve
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The SHSTK compatible version.
|
|
Packit |
6c4009 |
.text
|
|
Packit |
6c4009 |
.globl _dl_runtime_resolve_shstk
|
|
Packit |
6c4009 |
.type _dl_runtime_resolve_shstk, @function
|
|
Packit |
6c4009 |
cfi_startproc
|
|
Packit |
6c4009 |
.align 16
|
|
Packit |
6c4009 |
_dl_runtime_resolve_shstk:
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (8)
|
|
Packit |
6c4009 |
_CET_ENDBR
|
|
Packit |
6c4009 |
pushl %eax # Preserve registers otherwise clobbered.
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
pushl %edx
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
movl 12(%esp), %edx # Copy args pushed by PLT in register. Note
|
|
Packit |
6c4009 |
movl 8(%esp), %eax # that `fixup' takes its parameters in regs.
|
|
Packit |
6c4009 |
call _dl_fixup # Call resolver.
|
|
Packit |
6c4009 |
movl (%esp), %edx # Get register content back.
|
|
Packit |
6c4009 |
movl %eax, %ecx # Store the function address.
|
|
Packit |
6c4009 |
movl 4(%esp), %eax # Get register content back.
|
|
Packit |
6c4009 |
addl $16, %esp # Adjust stack: PLT1 + PLT2 + %eax + %edx
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-16)
|
|
Packit |
6c4009 |
jmp *%ecx # Jump to function address.
|
|
Packit |
6c4009 |
cfi_endproc
|
|
Packit |
6c4009 |
.size _dl_runtime_resolve_shstk, .-_dl_runtime_resolve_shstk
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef PROF
|
|
Packit |
6c4009 |
# The SHSTK compatible version.
|
|
Packit |
6c4009 |
.globl _dl_runtime_profile_shstk
|
|
Packit |
6c4009 |
.type _dl_runtime_profile_shstk, @function
|
|
Packit |
6c4009 |
cfi_startproc
|
|
Packit |
6c4009 |
.align 16
|
|
Packit |
6c4009 |
_dl_runtime_profile_shstk:
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (8)
|
|
Packit |
6c4009 |
_CET_ENDBR
|
|
Packit |
6c4009 |
pushl %esp
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
addl $8, (%esp) # Account for the pushed PLT data
|
|
Packit |
6c4009 |
pushl %ebp
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
pushl %eax # Preserve registers otherwise clobbered.
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
pushl %ecx
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
pushl %edx
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
movl %esp, %ecx
|
|
Packit |
6c4009 |
subl $8, %esp
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (8)
|
|
Packit |
6c4009 |
movl $-1, 4(%esp)
|
|
Packit |
6c4009 |
leal 4(%esp), %edx
|
|
Packit |
6c4009 |
movl %edx, (%esp)
|
|
Packit |
6c4009 |
pushl %ecx # Address of the register structure
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
movl 40(%esp), %ecx # Load return address
|
|
Packit |
6c4009 |
movl 36(%esp), %edx # Copy args pushed by PLT in register. Note
|
|
Packit |
6c4009 |
movl 32(%esp), %eax # that `fixup' takes its parameters in regs.
|
|
Packit |
6c4009 |
call _dl_profile_fixup # Call resolver.
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-8)
|
|
Packit |
6c4009 |
movl (%esp), %edx
|
|
Packit |
6c4009 |
testl %edx, %edx
|
|
Packit |
6c4009 |
jns 1f
|
|
Packit |
6c4009 |
movl 4(%esp), %edx # Get register content back.
|
|
Packit |
6c4009 |
movl %eax, %ecx # Store the function address.
|
|
Packit |
6c4009 |
movl 12(%esp), %eax # Get register content back.
|
|
Packit |
6c4009 |
# Adjust stack: PLT1 + PLT2 + %esp + %ebp + %eax + %ecx + %edx
|
|
Packit |
6c4009 |
# + free.
|
|
Packit |
6c4009 |
addl $32, %esp
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-32)
|
|
Packit |
6c4009 |
jmp *%ecx # Jump to function address.
|
|
Packit |
6c4009 |
cfi_endproc
|
|
Packit |
6c4009 |
.size _dl_runtime_profile_shstk, .-_dl_runtime_profile_shstk
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.globl _dl_runtime_profile
|
|
Packit |
6c4009 |
.type _dl_runtime_profile, @function
|
|
Packit |
6c4009 |
cfi_startproc
|
|
Packit |
6c4009 |
.align 16
|
|
Packit |
6c4009 |
_dl_runtime_profile:
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (8)
|
|
Packit |
6c4009 |
_CET_ENDBR
|
|
Packit |
6c4009 |
pushl %esp
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
addl $8, (%esp) # Account for the pushed PLT data
|
|
Packit |
6c4009 |
pushl %ebp
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
pushl %eax # Preserve registers otherwise clobbered.
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
pushl %ecx
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
pushl %edx
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
movl %esp, %ecx
|
|
Packit |
6c4009 |
subl $8, %esp
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (8)
|
|
Packit |
6c4009 |
movl $-1, 4(%esp)
|
|
Packit |
6c4009 |
leal 4(%esp), %edx
|
|
Packit |
6c4009 |
movl %edx, (%esp)
|
|
Packit |
6c4009 |
pushl %ecx # Address of the register structure
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
movl 40(%esp), %ecx # Load return address
|
|
Packit |
6c4009 |
movl 36(%esp), %edx # Copy args pushed by PLT in register. Note
|
|
Packit |
6c4009 |
movl 32(%esp), %eax # that `fixup' takes its parameters in regs.
|
|
Packit |
6c4009 |
call _dl_profile_fixup # Call resolver.
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-8)
|
|
Packit |
6c4009 |
movl (%esp), %edx
|
|
Packit |
6c4009 |
testl %edx, %edx
|
|
Packit |
6c4009 |
jns 1f
|
|
Packit |
6c4009 |
popl %edx
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-4)
|
|
Packit |
6c4009 |
popl %edx # Get register content back.
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-4)
|
|
Packit |
6c4009 |
movl (%esp), %ecx
|
|
Packit |
6c4009 |
movl %eax, (%esp) # Store the function address.
|
|
Packit |
6c4009 |
movl 4(%esp), %eax
|
|
Packit |
6c4009 |
ret $20 # Jump to function address.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/*
|
|
Packit |
6c4009 |
+32 return address
|
|
Packit |
6c4009 |
+28 PLT1
|
|
Packit |
6c4009 |
+24 PLT2
|
|
Packit |
6c4009 |
+20 %esp
|
|
Packit |
6c4009 |
+16 %ebp
|
|
Packit |
6c4009 |
+12 %eax
|
|
Packit |
6c4009 |
+8 %ecx
|
|
Packit |
6c4009 |
+4 %edx
|
|
Packit |
6c4009 |
%esp free
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (8)
|
|
Packit |
6c4009 |
1: movl %ebx, (%esp)
|
|
Packit |
6c4009 |
cfi_rel_offset (ebx, 0)
|
|
Packit |
6c4009 |
movl %edx, %ebx # This is the frame buffer size
|
|
Packit |
6c4009 |
pushl %edi
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
cfi_rel_offset (edi, 0)
|
|
Packit |
6c4009 |
pushl %esi
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
cfi_rel_offset (esi, 0)
|
|
Packit |
6c4009 |
leal 44(%esp), %esi
|
|
Packit |
6c4009 |
movl %ebx, %ecx
|
|
Packit |
6c4009 |
orl $4, %ebx # Increase frame size if necessary to align
|
|
Packit |
6c4009 |
# stack for the function call
|
|
Packit |
6c4009 |
andl $~3, %ebx
|
|
Packit |
6c4009 |
movl %esp, %edi
|
|
Packit |
6c4009 |
subl %ebx, %edi
|
|
Packit |
6c4009 |
movl %esp, %ebx
|
|
Packit |
6c4009 |
cfi_def_cfa_register (ebx)
|
|
Packit |
6c4009 |
movl %edi, %esp
|
|
Packit |
6c4009 |
shrl $2, %ecx
|
|
Packit |
6c4009 |
rep
|
|
Packit |
6c4009 |
movsl
|
|
Packit |
6c4009 |
movl (%ebx), %esi
|
|
Packit |
6c4009 |
cfi_restore (esi)
|
|
Packit |
6c4009 |
movl 4(%ebx), %edi
|
|
Packit |
6c4009 |
cfi_restore (edi)
|
|
Packit |
6c4009 |
/*
|
|
Packit |
6c4009 |
%ebx+40 return address
|
|
Packit |
6c4009 |
%ebx+36 PLT1
|
|
Packit |
6c4009 |
%ebx+32 PLT2
|
|
Packit |
6c4009 |
%ebx+28 %esp
|
|
Packit |
6c4009 |
%ebx+24 %ebp
|
|
Packit |
6c4009 |
%ebx+20 %eax
|
|
Packit |
6c4009 |
%ebx+16 %ecx
|
|
Packit |
6c4009 |
%ebx+12 %edx
|
|
Packit |
6c4009 |
%ebx+8 %ebx
|
|
Packit |
6c4009 |
%ebx+4 free
|
|
Packit |
6c4009 |
%ebx free
|
|
Packit |
6c4009 |
%esp copied stack frame
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
movl %eax, (%ebx)
|
|
Packit |
6c4009 |
movl 12(%ebx), %edx
|
|
Packit |
6c4009 |
movl 16(%ebx), %ecx
|
|
Packit |
6c4009 |
movl 20(%ebx), %eax
|
|
Packit |
6c4009 |
call *(%ebx)
|
|
Packit |
6c4009 |
movl %ebx, %esp
|
|
Packit |
6c4009 |
cfi_def_cfa_register (esp)
|
|
Packit |
6c4009 |
movl 8(%esp), %ebx
|
|
Packit |
6c4009 |
cfi_restore (ebx)
|
|
Packit |
6c4009 |
/*
|
|
Packit |
6c4009 |
+40 return address
|
|
Packit |
6c4009 |
+36 PLT1
|
|
Packit |
6c4009 |
+32 PLT2
|
|
Packit |
6c4009 |
+28 %esp
|
|
Packit |
6c4009 |
+24 %ebp
|
|
Packit |
6c4009 |
+20 %eax
|
|
Packit |
6c4009 |
+16 %ecx
|
|
Packit |
6c4009 |
+12 %edx
|
|
Packit |
6c4009 |
+8 free
|
|
Packit |
6c4009 |
+4 free
|
|
Packit |
6c4009 |
%esp free
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
#if LONG_DOUBLE_SIZE != 12
|
|
Packit |
6c4009 |
# error "long double size must be 12 bytes"
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
# Allocate space for La_i86_retval and subtract 12 free bytes.
|
|
Packit |
6c4009 |
subl $(LRV_SIZE - 12), %esp
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (LRV_SIZE - 12)
|
|
Packit |
6c4009 |
movl %eax, LRV_EAX_OFFSET(%esp)
|
|
Packit |
6c4009 |
movl %edx, LRV_EDX_OFFSET(%esp)
|
|
Packit |
6c4009 |
fstpt LRV_ST0_OFFSET(%esp)
|
|
Packit |
6c4009 |
fstpt LRV_ST1_OFFSET(%esp)
|
|
Packit |
6c4009 |
#ifdef HAVE_MPX_SUPPORT
|
|
Packit |
6c4009 |
bndmov %bnd0, LRV_BND0_OFFSET(%esp)
|
|
Packit |
6c4009 |
bndmov %bnd1, LRV_BND1_OFFSET(%esp)
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
.byte 0x66,0x0f,0x1b,0x44,0x24,LRV_BND0_OFFSET
|
|
Packit |
6c4009 |
.byte 0x66,0x0f,0x1b,0x4c,0x24,LRV_BND1_OFFSET
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
pushl %esp
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
# Address of La_i86_regs area.
|
|
Packit |
6c4009 |
leal (LRV_SIZE + 4)(%esp), %ecx
|
|
Packit |
6c4009 |
# PLT2
|
|
Packit |
6c4009 |
movl (LRV_SIZE + 4 + LR_SIZE)(%esp), %eax
|
|
Packit |
6c4009 |
# PLT1
|
|
Packit |
6c4009 |
movl (LRV_SIZE + 4 + LR_SIZE + 4)(%esp), %edx
|
|
Packit |
6c4009 |
call _dl_call_pltexit
|
|
Packit |
6c4009 |
movl LRV_EAX_OFFSET(%esp), %eax
|
|
Packit |
6c4009 |
movl LRV_EDX_OFFSET(%esp), %edx
|
|
Packit |
6c4009 |
fldt LRV_ST1_OFFSET(%esp)
|
|
Packit |
6c4009 |
fldt LRV_ST0_OFFSET(%esp)
|
|
Packit |
6c4009 |
#ifdef HAVE_MPX_SUPPORT
|
|
Packit |
6c4009 |
bndmov LRV_BND0_OFFSET(%esp), %bnd0
|
|
Packit |
6c4009 |
bndmov LRV_BND1_OFFSET(%esp), %bnd1
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
.byte 0x66,0x0f,0x1a,0x44,0x24,LRV_BND0_OFFSET
|
|
Packit |
6c4009 |
.byte 0x66,0x0f,0x1a,0x4c,0x24,LRV_BND1_OFFSET
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
# Restore stack before return.
|
|
Packit |
6c4009 |
addl $(LRV_SIZE + 4 + LR_SIZE + 4), %esp
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-(LRV_SIZE + 4 + LR_SIZE + 4))
|
|
Packit |
6c4009 |
PRESERVE_BND_REGS_PREFIX
|
|
Packit |
6c4009 |
ret
|
|
Packit |
6c4009 |
cfi_endproc
|
|
Packit |
6c4009 |
.size _dl_runtime_profile, .-_dl_runtime_profile
|
|
Packit |
6c4009 |
#endif
|