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 * ncvalidate_iter.c | 8 * ncvalidate_iter.c |
9 * Validate x86 instructions for Native Client | 9 * Validate x86 instructions for Native Client |
10 * | 10 * |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 NaClSegmentInitialize(mbase_new, vbase, size, &segment_new); | 748 NaClSegmentInitialize(mbase_new, vbase, size, &segment_new); |
749 do { | 749 do { |
750 iter_old = NaClInstIterCreateWithLookback(state->decoder_tables, | 750 iter_old = NaClInstIterCreateWithLookback(state->decoder_tables, |
751 &segment_old, kLookbackSize); | 751 &segment_old, kLookbackSize); |
752 if (NULL == iter_old) break; | 752 if (NULL == iter_old) break; |
753 iter_new = NaClInstIterCreateWithLookback(state->decoder_tables, | 753 iter_new = NaClInstIterCreateWithLookback(state->decoder_tables, |
754 &segment_new, kLookbackSize); | 754 &segment_new, kLookbackSize); |
755 if (NULL == iter_new) break; | 755 if (NULL == iter_new) break; |
756 while (NaClInstIterHasNextInline(iter_old) && | 756 while (NaClInstIterHasNextInline(iter_old) && |
757 NaClInstIterHasNextInline(iter_new)) { | 757 NaClInstIterHasNextInline(iter_new)) { |
758 Bool inst_changed; | |
759 state->cur_inst_state = NaClInstIterGetStateInline(iter_new); | 758 state->cur_inst_state = NaClInstIterGetStateInline(iter_new); |
760 state->cur_inst = NaClInstStateInst(state->cur_inst_state); | 759 state->cur_inst = NaClInstStateInst(state->cur_inst_state); |
761 state->cur_inst_vector = NaClInstStateExpVector(state->cur_inst_state); | 760 state->cur_inst_vector = NaClInstStateExpVector(state->cur_inst_state); |
762 inst_changed = NaClValidateInstReplacement(iter_old, iter_new, state); | 761 state->cur_inst_state->unchanged = |
763 if (inst_changed) | 762 !NaClValidateInstReplacement(iter_old, iter_new, state); |
764 NaClApplyValidators(state, iter_new); | 763 NaClApplyValidators(state, iter_new); |
765 else | |
766 NaClJumpValidatorRememberIpOnly(state, iter_new); | |
767 if (state->quit) break; | 764 if (state->quit) break; |
768 NaClInstIterAdvanceInline(iter_old); | 765 NaClInstIterAdvanceInline(iter_old); |
769 NaClInstIterAdvanceInline(iter_new); | 766 NaClInstIterAdvanceInline(iter_new); |
770 } | 767 } |
771 if (NaClInstIterHasNextInline(iter_old) || | 768 if (NaClInstIterHasNextInline(iter_old) || |
772 NaClInstIterHasNextInline(iter_new)) { | 769 NaClInstIterHasNextInline(iter_new)) { |
773 NaClValidatorMessage( | 770 NaClValidatorMessage( |
774 LOG_ERROR, state, | 771 LOG_ERROR, state, |
775 "Code modification: code segments have different " | 772 "Code modification: code segments have different " |
776 "number of instructions\n"); | 773 "number of instructions\n"); |
777 } | 774 } |
778 } while (0); | 775 } while (0); |
779 | 776 |
780 state->cur_inst_state = NULL; | 777 state->cur_inst_state = NULL; |
781 state->cur_inst = NULL; | 778 state->cur_inst = NULL; |
782 state->cur_inst_vector = NULL; | 779 state->cur_inst_vector = NULL; |
783 NaClApplyPostValidators(state, iter_new); | 780 NaClApplyPostValidators(state, iter_new); |
784 NaClInstIterDestroy(iter_old); | 781 NaClInstIterDestroy(iter_old); |
785 NaClInstIterDestroy(iter_new); | 782 NaClInstIterDestroy(iter_new); |
786 } | 783 } |
OLD | NEW |