From 0a9250c2ab32028dfdca6578655882b4be6a5c04 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Wed, 21 May 2014 08:19:16 -0700 Subject: [PATCH 1/3] BR 3392279: Fix duplicated REX prefixes The fix for BR 3392278: aa29b1d93f5a assemble.c: Don't drop rex prefix from instruction itself ... would cause multiple REX prefixes to be emitted for some instructions. Create a new flag to indicate that REX has already been emitted, which can be cleared for each instance of an instruction. Signed-off-by: H. Peter Anvin --- assemble.c | 9 +++++++-- nasm.h | 3 ++- test/times.asm | 8 ++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 test/times.asm diff --git a/assemble.c b/assemble.c index e9cd70f8..ff3cea77 100644 --- a/assemble.c +++ b/assemble.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2013 The NASM Authors - All Rights Reserved + * Copyright 1996-2014 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -1365,9 +1365,12 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, static inline unsigned int emit_rex(insn *ins, int32_t segment, int64_t offset, int bits) { if (bits == 64) { - if ((ins->rex & REX_REAL) && !(ins->rex & (REX_V | REX_EV))) { + if ((ins->rex & REX_REAL) && + !(ins->rex & (REX_V | REX_EV)) && + !ins->rex_done) { int rex = (ins->rex & REX_REAL) | REX_P; out(offset, segment, &rex, OUT_RAWDATA, 1, NO_SEG, NO_SEG); + ins->rex_done = true; return 1; } } @@ -1389,6 +1392,8 @@ static void gencode(int32_t segment, int64_t offset, int bits, uint8_t opex = 0; enum ea_type eat = EA_SCALAR; + ins->rex_done = false; + while (*codes) { c = *codes++; op1 = (c & 3) + ((opex & 1) << 2); diff --git a/nasm.h b/nasm.h index 18de37c8..666d7494 100644 --- a/nasm.h +++ b/nasm.h @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2013 The NASM Authors - All Rights Reserved + * Copyright 1996-2014 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -702,6 +702,7 @@ typedef struct insn { /* an instruction itself */ int eops_float; /* true if DD and floating */ int32_t times; /* repeat count (TIMES prefix) */ bool forw_ref; /* is there a forward reference? */ + bool rex_done; /* REX prefix emitted? */ int rex; /* Special REX Prefix */ int vexreg; /* Register encoded in VEX prefix */ int vex_cm; /* Class and M field for VEX prefix */ diff --git a/test/times.asm b/test/times.asm new file mode 100644 index 00000000..a8e3d58e --- /dev/null +++ b/test/times.asm @@ -0,0 +1,8 @@ + bits 64 + +; Broken per BR 3392278 + times 4 paddd xmm8, xmm11 + +; Broken per BR 3392279 + bswap r12d + times 4 bswap r12d From 4ac3b025be42b6db09474882c694eb012f423833 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Wed, 21 May 2014 08:28:21 -0700 Subject: [PATCH 2/3] doc: Document --v and duplicate REX prefix fix Document changes for 2.11.05. Signed-off-by: H. Peter Anvin --- doc/changes.src | 8 ++++++++ doc/nasmdoc.src | 3 +++ 2 files changed, 11 insertions(+) diff --git a/doc/changes.src b/doc/changes.src index 38cc97ef..ec4de219 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -7,6 +7,14 @@ The NASM 2 series supports x86-64, and is the production version of NASM since 2007. +\S{cl-2.11.05} Version 2.11.05 + +\b Add \c{--v} as an alias for \c{-v} (see \k{opt-v}), for +command-line compatibility with Yasm. + +\b Fix a bug introduced in 2.11.03 whereby certain instructions would +contain multiple REX prefixes, and thus be corrupt. + \S{cl-2.11.04} Version 2.11.04 \b Removed an invalid error checking code. Sometimes a memref only with diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src index 55a63133..30250918 100644 --- a/doc/nasmdoc.src +++ b/doc/nasmdoc.src @@ -984,6 +984,9 @@ and the date on which it was compiled. You will need the version number if you report a bug. +For command-line compatibility with Yasm, the form \i\c{--v} is also +accepted for this option. + \S{opt-y} The \i\c{-y} Option: Display Available Debug Info Formats Typing \c{nasm -f