From aa29b1d93f5a927c76aeee3d9e0830874015e7df Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Mon, 5 May 2014 00:30:58 +0400 Subject: [PATCH] assemble.c: Don't drop rex prefix from instruction itself emit_rex is supposed to write REX prefix into output stream if needed, but we happen to drop it off on a first write which breaks REX required instructions if TIMES directive is used. For example the code like | times 4 movq xmm11, xmm11 compiles into | 0000000000000000 <.text>: | 0: f3 45 0f 7e db movq %xmm11,%xmm11 | 5: f3 0f 7e db movq %xmm3,%xmm3 | 9: f3 0f 7e db movq %xmm3,%xmm3 | d: f3 0f 7e db movq %xmm3,%xmm3 instead of proper | 0000000000000000 <.text>: | 0: f3 45 0f 7e db movq %xmm11,%xmm11 | 5: f3 45 0f 7e db movq %xmm11,%xmm11 | a: f3 45 0f 7e db movq %xmm11,%xmm11 | f: f3 45 0f 7e db movq %xmm11,%xmm11 http://bugzilla.nasm.us/show_bug.cgi?id=3392278 Reported-by: Javier Signed-off-by: Cyrill Gorcunov Signed-off-by: H. Peter Anvin --- assemble.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/assemble.c b/assemble.c index eeab9bb..ff92722 100644 --- a/assemble.c +++ b/assemble.c @@ -1366,9 +1366,8 @@ static inline unsigned int emit_rex(insn *ins, int32_t segment, int64_t offset, { if (bits == 64) { if ((ins->rex & REX_REAL) && !(ins->rex & (REX_V | REX_EV))) { - ins->rex = (ins->rex & REX_REAL) | REX_P; - out(offset, segment, &ins->rex, OUT_RAWDATA, 1, NO_SEG, NO_SEG); - ins->rex = 0; + int rex = (ins->rex & REX_REAL) | REX_P; + out(offset, segment, &rex, OUT_RAWDATA, 1, NO_SEG, NO_SEG); return 1; } } -- 2.7.4