From patchwork Wed Jul 8 19:57:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lu, Hongjiu" X-Patchwork-Id: 7591 Received: (qmail 469 invoked by alias); 8 Jul 2015 19:57:15 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 441 invoked by uid 89); 8 Jul 2015 19:57:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-HELO: mga01.intel.com X-ExtLoop1: 1 Date: Wed, 8 Jul 2015 12:57:09 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] Improve bndmov encoding with zero displacement Message-ID: <20150708195709.GA8828@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) 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. Verified using assemblers with and without MPX support. OK for trunk? H.J. --- * sysdeps/x86_64/dl-trampoline.S (_dl_runtime_resolve): Improve bndmov encoding with zero displacement. --- sysdeps/x86_64/dl-trampoline.S | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sysdeps/x86_64/dl-trampoline.S b/sysdeps/x86_64/dl-trampoline.S index b151d35..678c57f 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.