about summary refs log tree commit diff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-07-09 09:30:09 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-08-02 06:54:17 -0700
commitfdd3aa0b19700ab564da895a2a85bf3fdb0bedf0 (patch)
tree24cc54f8fc744c871ebb4e88f2caf917b2a24718
parent9e4fc7f67f6695f294ae759a6b540f5d08a56f0c (diff)
downloadglibc-fdd3aa0b19700ab564da895a2a85bf3fdb0bedf0.tar.gz
glibc-fdd3aa0b19700ab564da895a2a85bf3fdb0bedf0.tar.xz
glibc-fdd3aa0b19700ab564da895a2a85bf3fdb0bedf0.zip
Improve bndmov encoding with zero displacement
If x86-64 assembler doesn't support MPX, we encode bndmov instruction by
hand.  When displacement is zero, assembler generates shorter encoding.
This patch improves bndmov encoding with zero displacement so that ld.so
is identical when using assemblers with and without MPX support.

	* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_resolve): Improve
	bndmov encoding with zero displacement.
-rw-r--r--sysdeps/x86_64/dl-trampoline.S8
1 files changed, 8 insertions, 0 deletions
diff --git a/sysdeps/x86_64/dl-trampoline.S b/sysdeps/x86_64/dl-trampoline.S
index b151d3566d..678c57fc24 100644
--- a/sysdeps/x86_64/dl-trampoline.S
+++ b/sysdeps/x86_64/dl-trampoline.S
@@ -80,7 +80,11 @@ _dl_runtime_resolve:
 	bndmov %bnd2, REGISTER_SAVE_BND2(%rsp)
 	bndmov %bnd3, REGISTER_SAVE_BND3(%rsp)
 # else
+#  if REGISTER_SAVE_BND0 == 0
+	.byte 0x66,0x0f,0x1b,0x04,0x24
+#  else
 	.byte 0x66,0x0f,0x1b,0x44,0x24,REGISTER_SAVE_BND0
+#  endif
 	.byte 0x66,0x0f,0x1b,0x4c,0x24,REGISTER_SAVE_BND1
 	.byte 0x66,0x0f,0x1b,0x54,0x24,REGISTER_SAVE_BND2
 	.byte 0x66,0x0f,0x1b,0x5c,0x24,REGISTER_SAVE_BND3
@@ -104,7 +108,11 @@ _dl_runtime_resolve:
 	.byte 0x66,0x0f,0x1a,0x5c,0x24,REGISTER_SAVE_BND3
 	.byte 0x66,0x0f,0x1a,0x54,0x24,REGISTER_SAVE_BND2
 	.byte 0x66,0x0f,0x1a,0x4c,0x24,REGISTER_SAVE_BND1
+#  if REGISTER_SAVE_BND0 == 0
+	.byte 0x66,0x0f,0x1a,0x04,0x24
+#  else
 	.byte 0x66,0x0f,0x1a,0x44,0x24,REGISTER_SAVE_BND0
+#  endif
 # endif
 #endif
 	# Get register content back.