OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can be | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 /* | |
8 * Captures instructions that jump. | |
9 */ | |
10 | |
11 #ifndef NACL_TRUSTED_BUT_NOT_TCB | |
12 #error("This file is not meant for use in the TCB") | |
13 #endif | |
14 | |
15 #include "native_client/src/trusted/validator/x86/decoder/generator/nc_def_jumps
.h" | |
16 | |
17 #include "native_client/src/include/nacl_macros.h" | |
18 #include "native_client/src/trusted/validator/x86/decoder/generator/ncdecode_for
ms.h" | |
19 #include "native_client/src/trusted/validator/x86/decoder/generator/ncdecode_tab
legen.h" | |
20 | |
21 /* List of instructions that do unconditional jumps. */ | |
22 static const NaClMnemonic kDefinesUnconditionalJump[] = { | |
23 InstJmp, | |
24 InstCall, | |
25 }; | |
26 | |
27 /* List of instructions that do conditional jumps with branch hints. */ | |
28 static const NaClMnemonic kDefinesConditionalJumpWithHints[] = { | |
29 InstJb, | |
30 InstJbe, | |
31 InstJcxz, | |
32 InstJecxz, | |
33 InstJrcxz, | |
34 InstJnl, | |
35 InstJnle, | |
36 InstJl, | |
37 InstJle, | |
38 InstJnb, | |
39 InstJnbe, | |
40 InstJno, | |
41 InstJnp, | |
42 InstJns, | |
43 InstJnz, | |
44 InstJo, | |
45 InstJp, | |
46 InstJs, | |
47 InstJz, | |
48 }; | |
49 | |
50 /* List of instructions that do conditional jumps without branch hints. */ | |
51 static const NaClMnemonic kDefinesConditionalJumpWithoutHints[] = { | |
52 InstLoop, | |
53 InstLoope, | |
54 InstLoopne, | |
55 }; | |
56 | |
57 static void NaClAddJumpFlags(NaClIFlag flag, const NaClMnemonic* name, | |
58 size_t name_size) { | |
59 if (NaClInInstructionSet(name, name_size, NULL, 0)) { | |
60 NaClGetDefInst()->flags |= NACL_IFLAG(flag); | |
61 } | |
62 } | |
63 | |
64 | |
65 void NaClAddJumpFlagsIfApplicable(void) { | |
66 NaClAddJumpFlags(JumpInstruction, kDefinesUnconditionalJump, | |
67 NACL_ARRAY_SIZE(kDefinesUnconditionalJump)); | |
68 NaClAddJumpFlags(ConditionalJump, kDefinesConditionalJumpWithHints, | |
69 NACL_ARRAY_SIZE(kDefinesConditionalJumpWithHints)); | |
70 NaClAddJumpFlags(BranchHints, kDefinesConditionalJumpWithHints, | |
71 NACL_ARRAY_SIZE(kDefinesConditionalJumpWithHints)); | |
72 NaClAddJumpFlags(ConditionalJump, kDefinesConditionalJumpWithoutHints, | |
73 NACL_ARRAY_SIZE(kDefinesConditionalJumpWithoutHints)); | |
74 } | |
OLD | NEW |