summaryrefslogtreecommitdiff
path: root/assemble.c
diff options
context:
space:
mode:
authorJin Kyu Song <jin.kyu.song@intel.com>2013-11-21 19:40:42 -0800
committerJin Kyu Song <jin.kyu.song@intel.com>2013-11-22 11:59:14 -0800
commit305f3cee04d1adf3f4e335c5645814f2b67e8a69 (patch)
treef303bc5873de869d5a1f05212033302b55c59d63 /assemble.c
parent5f3bfee708deba146302df4bb33d081f496399c0 (diff)
downloadnasm-305f3cee04d1adf3f4e335c5645814f2b67e8a69.tar.gz
nasm-305f3cee04d1adf3f4e335c5645814f2b67e8a69.tar.bz2
nasm-305f3cee04d1adf3f4e335c5645814f2b67e8a69.zip
bnd: Drop bnd prefix for relaxed short jmp instructions
Reverted the redundant branch instruction patterns for bnd prefix. And when a relaxed jmp instruction becomes a short (Jb) form, bnd prefix is not needed because it does not initialize bnd registers. So in that case, bnd prefix is silently dropped. BND JMP foo -> drops bnd prefix BND JMP short foo -> shows an explicit error Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Diffstat (limited to 'assemble.c')
-rw-r--r--assemble.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/assemble.c b/assemble.c
index a09b964..0667ef7 100644
--- a/assemble.c
+++ b/assemble.c
@@ -361,6 +361,7 @@ static bool jmp_match(int32_t segment, int64_t offset, int bits,
int64_t isize;
const uint8_t *code = temp->code;
uint8_t c = code[0];
+ bool is_byte;
if (((c & ~1) != 0370) || (ins->oprs[0].type & STRICT))
return false;
@@ -379,7 +380,14 @@ static bool jmp_match(int32_t segment, int64_t offset, int bits,
return false;
isize = ins->oprs[0].offset - offset - isize; /* isize is delta */
- return (isize >= -128 && isize <= 127); /* is it byte size? */
+ is_byte = (isize >= -128 && isize <= 127); /* is it byte size? */
+
+ if (is_byte && c == 0371 && ins->prefixes[PPS_REP] == P_BND) {
+ /* jmp short (opcode eb) cannot be used with bnd prefix. */
+ ins->prefixes[PPS_REP] = P_none;
+ }
+
+ return is_byte;
}
int64_t assemble(int32_t segment, int64_t offset, int bits, iflags_t cp,
@@ -684,6 +692,9 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflags_t cp,
error(ERR_NONFATAL, "instruction not supported in %d-bit mode",
bits);
break;
+ case MERR_BADBND:
+ error(ERR_NONFATAL, "bnd prefix is not allowed");
+ break;
default:
error(ERR_NONFATAL,
"invalid combination of opcode and operands");