| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | 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 | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* | 7 /* |
| 8 * nc_jumps_detailed.c - Validate jumps using a second pass of the | 8 * nc_jumps_detailed.c - Validate jumps using a second pass of the |
| 9 * isntructions. | 9 * isntructions. |
| 10 */ | 10 */ |
| 11 | 11 |
| 12 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/nc_jumps_detaile
d.h" | 12 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/nc_jumps_detaile
d.h" |
| 13 | 13 |
| 14 #include "native_client/src/shared/platform/nacl_log.h" | 14 #include "native_client/src/shared/platform/nacl_log.h" |
| 15 #include "native_client/src/trusted/validator/x86/decoder/nc_inst_iter.h" | |
| 16 #include "native_client/src/trusted/validator/x86/decoder/nc_inst_state_internal
.h" | 15 #include "native_client/src/trusted/validator/x86/decoder/nc_inst_state_internal
.h" |
| 17 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_iter.
h" | 16 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_iter.
h" |
| 18 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_iter_
internal.h" | 17 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_iter_
internal.h" |
| 19 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/nc_jumps.h" | 18 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/nc_jumps.h" |
| 20 | 19 |
| 20 #include "native_client/src/trusted/validator/x86/decoder/nc_inst_iter_inl.c" |
| 21 |
| 21 /* Returns true if the given address is within the code segment. | 22 /* Returns true if the given address is within the code segment. |
| 22 */ | 23 */ |
| 23 static Bool NaClCheckAddressRange(NaClPcAddress address, | 24 static Bool NaClCheckAddressRange(NaClPcAddress address, |
| 24 NaClValidatorState* state) { | 25 NaClValidatorState* state) { |
| 25 if (address < state->vbase) { | 26 if (address < state->vbase) { |
| 26 return FALSE; | 27 return FALSE; |
| 27 } | 28 } |
| 28 if (address >= state->vlimit) { | 29 if (address >= state->vlimit) { |
| 29 return FALSE; | 30 return FALSE; |
| 30 } | 31 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 /* Perform second pass on instructions to find instructions crossing | 128 /* Perform second pass on instructions to find instructions crossing |
| 128 * block boundaries, and (explicitly) branch to bad places. | 129 * block boundaries, and (explicitly) branch to bad places. |
| 129 */ | 130 */ |
| 130 do { | 131 do { |
| 131 check_iter = NaClInstIterCreate(state->decoder_tables, iter->segment); | 132 check_iter = NaClInstIterCreate(state->decoder_tables, iter->segment); |
| 132 if (NULL == check_iter) { | 133 if (NULL == check_iter) { |
| 133 NaClValidatorMessage(LOG_ERROR, state, | 134 NaClValidatorMessage(LOG_ERROR, state, |
| 134 "Not enough memory to check jumps\n"); | 135 "Not enough memory to check jumps\n"); |
| 135 break; | 136 break; |
| 136 } | 137 } |
| 137 for (; NaClInstIterHasNext(check_iter); NaClInstIterAdvance(check_iter)) { | 138 for (; NaClInstIterHasNextInline(check_iter); |
| 138 NaClInstState* inst_state = NaClInstIterGetState(check_iter); | 139 NaClInstIterAdvanceInline(check_iter)) { |
| 140 NaClInstState* inst_state = NaClInstIterGetStateInline(check_iter); |
| 139 NaClInstLayoutCheck(state, inst_state, jump_sets); | 141 NaClInstLayoutCheck(state, inst_state, jump_sets); |
| 140 } | 142 } |
| 141 NaClInstIterDestroy(check_iter); | 143 NaClInstIterDestroy(check_iter); |
| 142 } while (0); | 144 } while (0); |
| 143 } | 145 } |
| OLD | NEW |