|
|
147e83 |
# MPX Support for glibc:
|
|
|
147e83 |
#
|
|
|
147e83 |
# Note: Renamed configure.ac changes to configure.in changes.
|
|
|
147e83 |
#
|
|
|
147e83 |
# commit ea8ba7cd14d0f479bae8365ae5c4ef177bdd0aad
|
|
|
147e83 |
# Author: Igor Zamyatin <igor.zamyatin@intel.com>
|
|
|
147e83 |
# Date: Wed Apr 16 14:43:16 2014 -0700
|
|
|
147e83 |
#
|
|
|
147e83 |
# Save/restore bound registers for _dl_runtime_profile
|
|
|
147e83 |
#
|
|
|
147e83 |
# This patch saves and restores bound registers in x86-64 PLT for
|
|
|
147e83 |
# ld.so profile and LD_AUDIT:
|
|
|
147e83 |
#
|
|
|
147e83 |
# * sysdeps/x86_64/bits/link.h (La_x86_64_regs): Add lr_bnd.
|
|
|
147e83 |
# (La_x86_64_retval): Add lrv_bnd0 and lrv_bnd1.
|
|
|
147e83 |
# * sysdeps/x86_64/dl-trampoline.S (_dl_runtime_profile): Save
|
|
|
147e83 |
# Intel MPX bound registers before _dl_profile_fixup.
|
|
|
147e83 |
# * sysdeps/x86_64/dl-trampoline.h: Restore Intel MPX bound
|
|
|
147e83 |
# registers after _dl_profile_fixup. Save and restore bound
|
|
|
147e83 |
# registers bnd0/bnd1 when calling _dl_call_pltexit.
|
|
|
147e83 |
# * sysdeps/x86_64/link-defines.sym (BND_SIZE): New.
|
|
|
147e83 |
# (LR_BND_OFFSET): Likewise.
|
|
|
147e83 |
# (LRV_BND0_OFFSET): Likewise.
|
|
|
147e83 |
# (LRV_BND1_OFFSET): Likewise.
|
|
|
147e83 |
#
|
|
|
147e83 |
# commit a4c75cfd56e536c2b18556e8a482d88dffa0fffc
|
|
|
147e83 |
# Author: Igor Zamyatin <igor.zamyatin@intel.com>
|
|
|
147e83 |
# Date: Tue Apr 1 10:16:04 2014 -0700
|
|
|
147e83 |
#
|
|
|
147e83 |
# Save/restore bound registers in _dl_runtime_resolve
|
|
|
147e83 |
#
|
|
|
147e83 |
# This patch saves and restores bound registers in symbol lookup for x86-64:
|
|
|
147e83 |
#
|
|
|
147e83 |
# 1. Branches without BND prefix clear bound registers.
|
|
|
147e83 |
# 2. x86-64 pass bounds in bound registers as specified in MPX psABI
|
|
|
147e83 |
# extension on hjl/mpx/master branch at
|
|
|
147e83 |
#
|
|
|
147e83 |
# https://github.com/hjl-tools/x86-64-psABI
|
|
|
147e83 |
# https://groups.google.com/forum/#!topic/x86-64-abi/KFsB0XTgWYc
|
|
|
147e83 |
#
|
|
|
147e83 |
# Binutils has been updated to create an alternate PLT to add BND prefix
|
|
|
147e83 |
# when branching to ld.so.
|
|
|
147e83 |
#
|
|
|
147e83 |
# * config.h.in (HAVE_MPX_SUPPORT): New #undef.
|
|
|
147e83 |
# * sysdeps/x86_64/configure.ac: Set HAVE_MPX_SUPPORT.
|
|
|
147e83 |
# * sysdeps/x86_64/configure: Regenerated.
|
|
|
147e83 |
# * sysdeps/x86_64/dl-trampoline.S (REGISTER_SAVE_AREA): New
|
|
|
147e83 |
# macro.
|
|
|
147e83 |
# (REGISTER_SAVE_RAX): Likewise.
|
|
|
147e83 |
# (REGISTER_SAVE_RCX): Likewise.
|
|
|
147e83 |
# (REGISTER_SAVE_RDX): Likewise.
|
|
|
147e83 |
# (REGISTER_SAVE_RSI): Likewise.
|
|
|
147e83 |
# (REGISTER_SAVE_RDI): Likewise.
|
|
|
147e83 |
# (REGISTER_SAVE_R8): Likewise.
|
|
|
147e83 |
# (REGISTER_SAVE_R9): Likewise.
|
|
|
147e83 |
# (REGISTER_SAVE_BND0): Likewise.
|
|
|
147e83 |
# (REGISTER_SAVE_BND1): Likewise.
|
|
|
147e83 |
# (REGISTER_SAVE_BND2): Likewise.
|
|
|
147e83 |
# (_dl_runtime_resolve): Use them. Save and restore Intel MPX
|
|
|
147e83 |
# bound registers when calling _dl_fixup.
|
|
|
147e83 |
#
|
|
|
147e83 |
diff -urN glibc-2.17-c758a686/config.h.in glibc-2.17-c758a686/config.h.in
|
|
|
147e83 |
--- glibc-2.17-c758a686/config.h.in 2014-09-10 23:26:03.467045808 -0400
|
|
|
147e83 |
+++ glibc-2.17-c758a686/config.h.in 2014-09-10 23:27:41.532851928 -0400
|
|
|
147e83 |
@@ -107,6 +107,9 @@
|
|
|
147e83 |
/* Define if assembler supports AVX512. */
|
|
|
147e83 |
#undef HAVE_AVX512_ASM_SUPPORT
|
|
|
147e83 |
|
|
|
147e83 |
+/* Define if assembler supports Intel MPX. */
|
|
|
147e83 |
+#undef HAVE_MPX_SUPPORT
|
|
|
147e83 |
+
|
|
|
147e83 |
/* Define if gcc supports FMA4. */
|
|
|
147e83 |
#undef HAVE_FMA4_SUPPORT
|
|
|
147e83 |
|
|
|
147e83 |
diff -urN glibc-2.17-c758a686/sysdeps/x86/bits/link.h glibc-2.17-c758a686/sysdeps/x86/bits/link.h
|
|
|
147e83 |
--- glibc-2.17-c758a686/sysdeps/x86/bits/link.h 2014-09-10 23:26:03.467045808 -0400
|
|
|
147e83 |
+++ glibc-2.17-c758a686/sysdeps/x86/bits/link.h 2014-09-10 23:27:41.533851926 -0400
|
|
|
147e83 |
@@ -93,6 +93,9 @@
|
|
|
147e83 |
uint64_t lr_rsp;
|
|
|
147e83 |
La_x86_64_xmm lr_xmm[8];
|
|
|
147e83 |
La_x86_64_vector lr_vector[8];
|
|
|
147e83 |
+#ifndef __ILP32__
|
|
|
147e83 |
+ __int128 lr_bnd[4];
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
} La_x86_64_regs;
|
|
|
147e83 |
|
|
|
147e83 |
/* Return values for calls from PLT on x86-64. */
|
|
|
147e83 |
@@ -106,6 +109,10 @@
|
|
|
147e83 |
long double lrv_st1;
|
|
|
147e83 |
La_x86_64_vector lrv_vector0;
|
|
|
147e83 |
La_x86_64_vector lrv_vector1;
|
|
|
147e83 |
+#ifndef __ILP32__
|
|
|
147e83 |
+ __int128 lrv_bnd0;
|
|
|
147e83 |
+ __int128 lrv_bnd1;
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
} La_x86_64_retval;
|
|
|
147e83 |
|
|
|
147e83 |
#define La_x32_regs La_x86_64_regs
|
|
|
147e83 |
diff -urN glibc-2.17-c758a686/sysdeps/x86_64/configure glibc-2.17-c758a686/sysdeps/x86_64/configure
|
|
|
147e83 |
--- glibc-2.17-c758a686/sysdeps/x86_64/configure 2014-09-10 23:26:03.573045598 -0400
|
|
|
147e83 |
+++ glibc-2.17-c758a686/sysdeps/x86_64/configure 2014-09-10 23:27:41.532851928 -0400
|
|
|
147e83 |
@@ -212,6 +212,33 @@
|
|
|
147e83 |
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_novzeroupper" >&5
|
|
|
147e83 |
$as_echo "$libc_cv_cc_novzeroupper" >&6; }
|
|
|
147e83 |
|
|
|
147e83 |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Intel MPX support" >&5
|
|
|
147e83 |
+$as_echo_n "checking for Intel MPX support... " >&6; }
|
|
|
147e83 |
+if ${libc_cv_asm_mpx+:} false; then :
|
|
|
147e83 |
+ $as_echo_n "(cached) " >&6
|
|
|
147e83 |
+else
|
|
|
147e83 |
+ cat > conftest.s <<\EOF
|
|
|
147e83 |
+ bndmov %bnd0,(%rsp)
|
|
|
147e83 |
+EOF
|
|
|
147e83 |
+if { ac_try='${CC-cc} -c $ASFLAGS conftest.s 1>&5'
|
|
|
147e83 |
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
|
|
|
147e83 |
+ (eval $ac_try) 2>&5
|
|
|
147e83 |
+ ac_status=$?
|
|
|
147e83 |
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
|
|
147e83 |
+ test $ac_status = 0; }; }; then
|
|
|
147e83 |
+ libc_cv_asm_mpx=yes
|
|
|
147e83 |
+else
|
|
|
147e83 |
+ libc_cv_asm_mpx=no
|
|
|
147e83 |
+fi
|
|
|
147e83 |
+rm -f conftest*
|
|
|
147e83 |
+fi
|
|
|
147e83 |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_asm_mpx" >&5
|
|
|
147e83 |
+$as_echo "$libc_cv_asm_mpx" >&6; }
|
|
|
147e83 |
+if test $libc_cv_asm_mpx == yes; then
|
|
|
147e83 |
+ $as_echo "#define HAVE_MPX_SUPPORT 1" >>confdefs.h
|
|
|
147e83 |
+
|
|
|
147e83 |
+fi
|
|
|
147e83 |
+
|
|
|
147e83 |
$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
|
|
|
147e83 |
|
|
|
147e83 |
# work around problem with autoconf and empty lines at the end of files
|
|
|
147e83 |
diff -urN glibc-2.17-c758a686/sysdeps/x86_64/configure.in glibc-2.17-c758a686/sysdeps/x86_64/configure.in
|
|
|
147e83 |
--- glibc-2.17-c758a686/sysdeps/x86_64/configure.in 2014-09-10 23:26:03.468045806 -0400
|
|
|
147e83 |
+++ glibc-2.17-c758a686/sysdeps/x86_64/configure.in 2014-09-10 23:27:41.532851928 -0400
|
|
|
147e83 |
@@ -70,6 +70,21 @@
|
|
|
147e83 |
[libc_cv_cc_novzeroupper=no])
|
|
|
147e83 |
])
|
|
|
147e83 |
|
|
|
147e83 |
+dnl Check whether asm supports Intel MPX
|
|
|
147e83 |
+AC_CACHE_CHECK(for Intel MPX support, libc_cv_asm_mpx, [dnl
|
|
|
147e83 |
+cat > conftest.s <<\EOF
|
|
|
147e83 |
+ bndmov %bnd0,(%rsp)
|
|
|
147e83 |
+EOF
|
|
|
147e83 |
+if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
|
|
|
147e83 |
+ libc_cv_asm_mpx=yes
|
|
|
147e83 |
+else
|
|
|
147e83 |
+ libc_cv_asm_mpx=no
|
|
|
147e83 |
+fi
|
|
|
147e83 |
+rm -f conftest*])
|
|
|
147e83 |
+if test $libc_cv_asm_mpx == yes; then
|
|
|
147e83 |
+ AC_DEFINE(HAVE_MPX_SUPPORT)
|
|
|
147e83 |
+fi
|
|
|
147e83 |
+
|
|
|
147e83 |
dnl It is always possible to access static and hidden symbols in an
|
|
|
147e83 |
dnl position independent way.
|
|
|
147e83 |
AC_DEFINE(PI_STATIC_AND_HIDDEN)
|
|
|
147e83 |
diff -urN glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.h glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.h
|
|
|
147e83 |
--- glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.h 2014-09-10 23:26:03.468045806 -0400
|
|
|
147e83 |
+++ glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.h 2014-09-10 23:27:41.535851922 -0400
|
|
|
147e83 |
@@ -63,6 +63,20 @@
|
|
|
147e83 |
movaps (LR_XMM_OFFSET + XMM_SIZE*6)(%rsp), %xmm6
|
|
|
147e83 |
movaps (LR_XMM_OFFSET + XMM_SIZE*7)(%rsp), %xmm7
|
|
|
147e83 |
|
|
|
147e83 |
+#ifndef __ILP32__
|
|
|
147e83 |
+# ifdef HAVE_MPX_SUPPORT
|
|
|
147e83 |
+ bndmov (LR_BND_OFFSET)(%rsp), %bnd0 # Restore bound
|
|
|
147e83 |
+ bndmov (LR_BND_OFFSET + BND_SIZE)(%rsp), %bnd1 # registers.
|
|
|
147e83 |
+ bndmov (LR_BND_OFFSET + BND_SIZE*2)(%rsp), %bnd2
|
|
|
147e83 |
+ bndmov (LR_BND_OFFSET + BND_SIZE*3)(%rsp), %bnd3
|
|
|
147e83 |
+# else
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1a,0x84,0x24;.long (LR_BND_OFFSET)
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1a,0x8c,0x24;.long (LR_BND_OFFSET + BND_SIZE)
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1a,0x94,0x24;.long (LR_BND_OFFSET + BND_SIZE*2)
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1a,0x9c,0x24;.long (LR_BND_OFFSET + BND_SIZE*3)
|
|
|
147e83 |
+# endif
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
+
|
|
|
147e83 |
#ifdef RESTORE_AVX
|
|
|
147e83 |
/* Check if any xmm0-xmm7 registers are changed by audit
|
|
|
147e83 |
module. */
|
|
|
147e83 |
@@ -222,6 +236,16 @@
|
|
|
147e83 |
vmovdqa %xmm1, (LRV_SIZE + XMM_SIZE)(%rcx)
|
|
|
147e83 |
#endif
|
|
|
147e83 |
|
|
|
147e83 |
+#ifndef __ILP32__
|
|
|
147e83 |
+# ifdef HAVE_MPX_SUPPORT
|
|
|
147e83 |
+ bndmov %bnd0, LRV_BND0_OFFSET(%rcx) # Preserve returned bounds.
|
|
|
147e83 |
+ bndmov %bnd1, LRV_BND1_OFFSET(%rcx)
|
|
|
147e83 |
+# else
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1b,0x81;.long (LRV_BND0_OFFSET)
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1b,0x89;.long (LRV_BND1_OFFSET)
|
|
|
147e83 |
+# endif
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
+
|
|
|
147e83 |
fstpt LRV_ST0_OFFSET(%rcx)
|
|
|
147e83 |
fstpt LRV_ST1_OFFSET(%rcx)
|
|
|
147e83 |
|
|
|
147e83 |
@@ -254,6 +278,16 @@
|
|
|
147e83 |
1:
|
|
|
147e83 |
#endif
|
|
|
147e83 |
|
|
|
147e83 |
+#ifndef __ILP32__
|
|
|
147e83 |
+# ifdef HAVE_MPX_SUPPORT
|
|
|
147e83 |
+ bndmov LRV_BND0_OFFSET(%rcx), %bnd0 # Restore bound registers.
|
|
|
147e83 |
+ bndmov LRV_BND1_OFFSET(%rcx), %bnd1
|
|
|
147e83 |
+# else
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1a,0x81;.long (LRV_BND0_OFFSET)
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1a,0x89;.long (LRV_BND1_OFFSET)
|
|
|
147e83 |
+# endif
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
+
|
|
|
147e83 |
fldt LRV_ST1_OFFSET(%rsp)
|
|
|
147e83 |
fldt LRV_ST0_OFFSET(%rsp)
|
|
|
147e83 |
|
|
|
147e83 |
diff -urN glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.S glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.S
|
|
|
147e83 |
--- glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.S 2014-09-10 23:26:03.468045806 -0400
|
|
|
147e83 |
+++ glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.S 2014-09-10 23:27:41.534851924 -0400
|
|
|
147e83 |
@@ -24,6 +24,30 @@
|
|
|
147e83 |
# error RTLD_SAVESPACE_SSE must be aligned to 32 bytes
|
|
|
147e83 |
#endif
|
|
|
147e83 |
|
|
|
147e83 |
+/* Area on stack to save and restore registers used for parameter
|
|
|
147e83 |
+ passing when calling _dl_fixup. */
|
|
|
147e83 |
+#ifdef __ILP32__
|
|
|
147e83 |
+/* X32 saves RCX, RDX, RSI, RDI, R8 and R9 plus RAX. */
|
|
|
147e83 |
+# define REGISTER_SAVE_AREA (8 * 7)
|
|
|
147e83 |
+# define REGISTER_SAVE_RAX 0
|
|
|
147e83 |
+#else
|
|
|
147e83 |
+/* X86-64 saves RCX, RDX, RSI, RDI, R8 and R9 plus RAX as well as BND0,
|
|
|
147e83 |
+ BND1, BND2, BND3. */
|
|
|
147e83 |
+# define REGISTER_SAVE_AREA (8 * 7 + 16 * 4)
|
|
|
147e83 |
+/* Align bound register save area to 16 bytes. */
|
|
|
147e83 |
+# define REGISTER_SAVE_BND0 0
|
|
|
147e83 |
+# define REGISTER_SAVE_BND1 (REGISTER_SAVE_BND0 + 16)
|
|
|
147e83 |
+# define REGISTER_SAVE_BND2 (REGISTER_SAVE_BND1 + 16)
|
|
|
147e83 |
+# define REGISTER_SAVE_BND3 (REGISTER_SAVE_BND2 + 16)
|
|
|
147e83 |
+# define REGISTER_SAVE_RAX (REGISTER_SAVE_BND3 + 16)
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
+#define REGISTER_SAVE_RCX (REGISTER_SAVE_RAX + 8)
|
|
|
147e83 |
+#define REGISTER_SAVE_RDX (REGISTER_SAVE_RCX + 8)
|
|
|
147e83 |
+#define REGISTER_SAVE_RSI (REGISTER_SAVE_RDX + 8)
|
|
|
147e83 |
+#define REGISTER_SAVE_RDI (REGISTER_SAVE_RSI + 8)
|
|
|
147e83 |
+#define REGISTER_SAVE_R8 (REGISTER_SAVE_RDI + 8)
|
|
|
147e83 |
+#define REGISTER_SAVE_R9 (REGISTER_SAVE_R8 + 8)
|
|
|
147e83 |
+
|
|
|
147e83 |
.text
|
|
|
147e83 |
.globl _dl_runtime_resolve
|
|
|
147e83 |
.type _dl_runtime_resolve, @function
|
|
|
147e83 |
@@ -31,28 +55,63 @@
|
|
|
147e83 |
cfi_startproc
|
|
|
147e83 |
_dl_runtime_resolve:
|
|
|
147e83 |
cfi_adjust_cfa_offset(16) # Incorporate PLT
|
|
|
147e83 |
- subq $56,%rsp
|
|
|
147e83 |
- cfi_adjust_cfa_offset(56)
|
|
|
147e83 |
- movq %rax,(%rsp) # Preserve registers otherwise clobbered.
|
|
|
147e83 |
- movq %rcx, 8(%rsp)
|
|
|
147e83 |
- movq %rdx, 16(%rsp)
|
|
|
147e83 |
- movq %rsi, 24(%rsp)
|
|
|
147e83 |
- movq %rdi, 32(%rsp)
|
|
|
147e83 |
- movq %r8, 40(%rsp)
|
|
|
147e83 |
- movq %r9, 48(%rsp)
|
|
|
147e83 |
- movq 64(%rsp), %rsi # Copy args pushed by PLT in register.
|
|
|
147e83 |
- movq 56(%rsp), %rdi # %rdi: link_map, %rsi: reloc_index
|
|
|
147e83 |
+ subq $REGISTER_SAVE_AREA,%rsp
|
|
|
147e83 |
+ cfi_adjust_cfa_offset(REGISTER_SAVE_AREA)
|
|
|
147e83 |
+ # Preserve registers otherwise clobbered.
|
|
|
147e83 |
+ movq %rax, REGISTER_SAVE_RAX(%rsp)
|
|
|
147e83 |
+ movq %rcx, REGISTER_SAVE_RCX(%rsp)
|
|
|
147e83 |
+ movq %rdx, REGISTER_SAVE_RDX(%rsp)
|
|
|
147e83 |
+ movq %rsi, REGISTER_SAVE_RSI(%rsp)
|
|
|
147e83 |
+ movq %rdi, REGISTER_SAVE_RDI(%rsp)
|
|
|
147e83 |
+ movq %r8, REGISTER_SAVE_R8(%rsp)
|
|
|
147e83 |
+ movq %r9, REGISTER_SAVE_R9(%rsp)
|
|
|
147e83 |
+#ifndef __ILP32__
|
|
|
147e83 |
+ # We also have to preserve bound registers. These are nops if
|
|
|
147e83 |
+ # Intel MPX isn't available or disabled.
|
|
|
147e83 |
+# ifdef HAVE_MPX_SUPPORT
|
|
|
147e83 |
+ bndmov %bnd0, REGISTER_SAVE_BND0(%rsp)
|
|
|
147e83 |
+ bndmov %bnd1, REGISTER_SAVE_BND1(%rsp)
|
|
|
147e83 |
+ bndmov %bnd2, REGISTER_SAVE_BND2(%rsp)
|
|
|
147e83 |
+ bndmov %bnd3, REGISTER_SAVE_BND3(%rsp)
|
|
|
147e83 |
+# else
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1b,0x44,0x24,REGISTER_SAVE_BND0
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1b,0x4c,0x24,REGISTER_SAVE_BND1
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1b,0x54,0x24,REGISTER_SAVE_BND2
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1b,0x5c,0x24,REGISTER_SAVE_BND3
|
|
|
147e83 |
+# endif
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
+ # Copy args pushed by PLT in register.
|
|
|
147e83 |
+ # %rdi: link_map, %rsi: reloc_index
|
|
|
147e83 |
+ movq (REGISTER_SAVE_AREA + 8)(%rsp), %rsi
|
|
|
147e83 |
+ movq REGISTER_SAVE_AREA(%rsp), %rdi
|
|
|
147e83 |
call _dl_fixup # Call resolver.
|
|
|
147e83 |
movq %rax, %r11 # Save return value
|
|
|
147e83 |
- movq 48(%rsp), %r9 # Get register content back.
|
|
|
147e83 |
- movq 40(%rsp), %r8
|
|
|
147e83 |
- movq 32(%rsp), %rdi
|
|
|
147e83 |
- movq 24(%rsp), %rsi
|
|
|
147e83 |
- movq 16(%rsp), %rdx
|
|
|
147e83 |
- movq 8(%rsp), %rcx
|
|
|
147e83 |
- movq (%rsp), %rax
|
|
|
147e83 |
- addq $72, %rsp # Adjust stack(PLT did 2 pushes)
|
|
|
147e83 |
- cfi_adjust_cfa_offset(-72)
|
|
|
147e83 |
+#ifndef __ILP32__
|
|
|
147e83 |
+ # Restore bound registers. These are nops if Intel MPX isn't
|
|
|
147e83 |
+ # avaiable or disabled.
|
|
|
147e83 |
+# ifdef HAVE_MPX_SUPPORT
|
|
|
147e83 |
+ bndmov REGISTER_SAVE_BND3(%rsp), %bnd3
|
|
|
147e83 |
+ bndmov REGISTER_SAVE_BND2(%rsp), %bnd2
|
|
|
147e83 |
+ bndmov REGISTER_SAVE_BND1(%rsp), %bnd1
|
|
|
147e83 |
+ bndmov REGISTER_SAVE_BND0(%rsp), %bnd0
|
|
|
147e83 |
+# else
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1a,0x5c,0x24,REGISTER_SAVE_BND3
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1a,0x54,0x24,REGISTER_SAVE_BND2
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1a,0x4c,0x24,REGISTER_SAVE_BND1
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1a,0x44,0x24,REGISTER_SAVE_BND0
|
|
|
147e83 |
+# endif
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
+ # Get register content back.
|
|
|
147e83 |
+ movq REGISTER_SAVE_R9(%rsp), %r9
|
|
|
147e83 |
+ movq REGISTER_SAVE_R8(%rsp), %r8
|
|
|
147e83 |
+ movq REGISTER_SAVE_RDI(%rsp), %rdi
|
|
|
147e83 |
+ movq REGISTER_SAVE_RSI(%rsp), %rsi
|
|
|
147e83 |
+ movq REGISTER_SAVE_RDX(%rsp), %rdx
|
|
|
147e83 |
+ movq REGISTER_SAVE_RCX(%rsp), %rcx
|
|
|
147e83 |
+ movq REGISTER_SAVE_RAX(%rsp), %rax
|
|
|
147e83 |
+ # Adjust stack(PLT did 2 pushes)
|
|
|
147e83 |
+ addq $(REGISTER_SAVE_AREA + 16), %rsp
|
|
|
147e83 |
+ cfi_adjust_cfa_offset(-(REGISTER_SAVE_AREA + 16))
|
|
|
147e83 |
jmp *%r11 # Jump to function address.
|
|
|
147e83 |
cfi_endproc
|
|
|
147e83 |
.size _dl_runtime_resolve, .-_dl_runtime_resolve
|
|
|
147e83 |
@@ -130,6 +189,20 @@
|
|
|
147e83 |
movaps %xmm6, (LR_XMM_OFFSET + XMM_SIZE*6)(%rsp)
|
|
|
147e83 |
movaps %xmm7, (LR_XMM_OFFSET + XMM_SIZE*7)(%rsp)
|
|
|
147e83 |
|
|
|
147e83 |
+# ifndef __ILP32__
|
|
|
147e83 |
+# ifdef HAVE_MPX_SUPPORT
|
|
|
147e83 |
+ bndmov %bnd0, (LR_BND_OFFSET)(%rsp) # Preserve bound
|
|
|
147e83 |
+ bndmov %bnd1, (LR_BND_OFFSET + BND_SIZE)(%rsp) # registers. Nops if
|
|
|
147e83 |
+ bndmov %bnd2, (LR_BND_OFFSET + BND_SIZE*2)(%rsp) # MPX not available
|
|
|
147e83 |
+ bndmov %bnd3, (LR_BND_OFFSET + BND_SIZE*3)(%rsp) # or disabled.
|
|
|
147e83 |
+# else
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1b,0x84,0x24;.long (LR_BND_OFFSET)
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1b,0x8c,0x24;.long (LR_BND_OFFSET + BND_SIZE)
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1b,0x84,0x24;.long (LR_BND_OFFSET + BND_SIZE*2)
|
|
|
147e83 |
+ .byte 0x66,0x0f,0x1b,0x8c,0x24;.long (LR_BND_OFFSET + BND_SIZE*3)
|
|
|
147e83 |
+# endif
|
|
|
147e83 |
+# endif
|
|
|
147e83 |
+
|
|
|
147e83 |
# if defined HAVE_AVX_SUPPORT || defined HAVE_AVX512_ASM_SUPPORT
|
|
|
147e83 |
.data
|
|
|
147e83 |
L(have_avx):
|
|
|
147e83 |
diff -urN glibc-2.17-c758a686/sysdeps/x86_64/link-defines.sym glibc-2.17-c758a686/sysdeps/x86_64/link-defines.sym
|
|
|
147e83 |
--- glibc-2.17-c758a686/sysdeps/x86_64/link-defines.sym 2014-09-10 23:26:03.468045806 -0400
|
|
|
147e83 |
+++ glibc-2.17-c758a686/sysdeps/x86_64/link-defines.sym 2014-09-10 23:27:41.535851922 -0400
|
|
|
147e83 |
@@ -6,6 +6,7 @@
|
|
|
147e83 |
XMM_SIZE sizeof (La_x86_64_xmm)
|
|
|
147e83 |
YMM_SIZE sizeof (La_x86_64_ymm)
|
|
|
147e83 |
ZMM_SIZE sizeof (La_x86_64_zmm)
|
|
|
147e83 |
+BND_SIZE sizeof (__int128)
|
|
|
147e83 |
|
|
|
147e83 |
LR_SIZE sizeof (struct La_x86_64_regs)
|
|
|
147e83 |
LR_RDX_OFFSET offsetof (struct La_x86_64_regs, lr_rdx)
|
|
|
147e83 |
@@ -18,6 +19,9 @@
|
|
|
147e83 |
LR_RSP_OFFSET offsetof (struct La_x86_64_regs, lr_rsp)
|
|
|
147e83 |
LR_XMM_OFFSET offsetof (struct La_x86_64_regs, lr_xmm)
|
|
|
147e83 |
LR_VECTOR_OFFSET offsetof (struct La_x86_64_regs, lr_vector)
|
|
|
147e83 |
+#ifndef __ILP32__
|
|
|
147e83 |
+LR_BND_OFFSET offsetof (struct La_x86_64_regs, lr_bnd)
|
|
|
147e83 |
+#endif
|
|
|
147e83 |
|
|
|
147e83 |
LRV_SIZE sizeof (struct La_x86_64_retval)
|
|
|
147e83 |
LRV_RAX_OFFSET offsetof (struct La_x86_64_retval, lrv_rax)
|
|
|
147e83 |
@@ -28,3 +32,7 @@
|
|
|
147e83 |
LRV_ST1_OFFSET offsetof (struct La_x86_64_retval, lrv_st1)
|
|
|
147e83 |
LRV_VECTOR0_OFFSET offsetof (struct La_x86_64_retval, lrv_vector0)
|
|
|
147e83 |
LRV_VECTOR1_OFFSET offsetof (struct La_x86_64_retval, lrv_vector1)
|
|
|
147e83 |
+#ifndef __ILP32__
|
|
|
147e83 |
+LRV_BND0_OFFSET offsetof (struct La_x86_64_retval, lrv_bnd0)
|
|
|
147e83 |
+LRV_BND1_OFFSET offsetof (struct La_x86_64_retval, lrv_bnd1)
|
|
|
147e83 |
+#endif
|