diff options
author | Jin Kyu Song <jin.kyu.song@intel.com> | 2013-11-21 19:40:42 -0800 |
---|---|---|
committer | Jin Kyu Song <jin.kyu.song@intel.com> | 2013-11-22 11:59:14 -0800 |
commit | 305f3cee04d1adf3f4e335c5645814f2b67e8a69 (patch) | |
tree | f303bc5873de869d5a1f05212033302b55c59d63 /assemble.c | |
parent | 5f3bfee708deba146302df4bb33d081f496399c0 (diff) | |
download | nasm-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.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -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"); |