diff options
author | Jin Kyu Song <jin.kyu.song@intel.com> | 2013-10-15 19:38:51 -0700 |
---|---|---|
committer | Jin Kyu Song <jin.kyu.song@intel.com> | 2013-11-20 11:29:42 -0800 |
commit | 0304109b3d40c3a46e383cadaeae365c66e1b0e4 (patch) | |
tree | 257a89da17087dce1506ddf05b07a0799f050ceb /assemble.c | |
parent | 164d60740f0aa2759ae78874bd5c8692d8d59e60 (diff) | |
download | nasm-0304109b3d40c3a46e383cadaeae365c66e1b0e4.tar.gz nasm-0304109b3d40c3a46e383cadaeae365c66e1b0e4.tar.bz2 nasm-0304109b3d40c3a46e383cadaeae365c66e1b0e4.zip |
MPX: Add BND prefix for branch instructions
BND prefix is used for adding bounds checking protection
across flow control changes such as call, ret, jmp and jcc calls.
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, 11 insertions, 2 deletions
@@ -162,6 +162,7 @@ * \367 - address-size prefix (0x67) used as opcode extension * \370,\371 - match only if operand 0 meets byte jump criteria. * 370 is used for Jcc, 371 is used for JMP. + * \372 - BND prefix (0xF2 byte) used for preserving bnd0..3 * \373 - assemble 0x03 if bits==16, 0x05 if bits==32; * used for conditional jump over longer jump * \374 - this instruction takes an XMM VSIB memory EA @@ -193,6 +194,7 @@ enum match_result { MERR_BADMODE, MERR_BADHLE, MERR_ENCMISMATCH, + MERR_BADBND, /* * Matching success; the conditional ones first */ @@ -547,6 +549,7 @@ int64_t assemble(int32_t segment, int64_t offset, int bits, iflags_t cp, case P_REPNE: case P_REPNZ: case P_XACQUIRE: + case P_BND: c = 0xF2; break; case P_REPE: @@ -1739,8 +1742,7 @@ static void gencode(int32_t segment, int64_t offset, int bits, offset += 1; break; - case 0370: - case 0371: + case3(0370): break; case 0373: @@ -2227,6 +2229,13 @@ static enum match_result matches(const struct itemplate *itemp, if ((itemp->code[0] & ~1) == 0370) return MOK_JUMP; + /* + * Check if BND prefix is allowed + */ + if ((itemp->code[0] != 0372) && + has_prefix(instruction, PPS_REP, P_BND)) + return MERR_BADBND; + return MOK_GOOD; } |