| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 vstate->cur_inst_vector = NULL; | 496 vstate->cur_inst_vector = NULL; |
| 497 } | 497 } |
| 498 | 498 |
| 499 void NaClValidatorStateIterFinish(NaClValidatorState *vstate) { | 499 void NaClValidatorStateIterFinish(NaClValidatorState *vstate) { |
| 500 NaClValidatorStateIterFinishInline(vstate); | 500 NaClValidatorStateIterFinishInline(vstate); |
| 501 } | 501 } |
| 502 | 502 |
| 503 NaClValidatorState *NaClValidatorStateCreate( | 503 NaClValidatorState *NaClValidatorStateCreate( |
| 504 const NaClPcAddress vbase, | 504 const NaClPcAddress vbase, |
| 505 const NaClMemorySize codesize, | 505 const NaClMemorySize codesize, |
| 506 const uint8_t alignment, | |
| 507 const NaClOpKind base_register, | 506 const NaClOpKind base_register, |
| 508 const int readonly_text, | 507 const int readonly_text, |
| 509 const NaClCPUFeaturesX86 *features) { | 508 const NaClCPUFeaturesX86 *features) { |
| 510 NaClValidatorState *vstate; | 509 NaClValidatorState *vstate; |
| 511 NaClValidatorState *return_value = NULL; | 510 NaClValidatorState *return_value = NULL; |
| 511 const int alignment = 32; |
| 512 DEBUG(NaClLog(LOG_INFO, | 512 DEBUG(NaClLog(LOG_INFO, |
| 513 "Validator Create: vbase = %"NACL_PRIxNaClPcAddress", " | 513 "Validator Create: vbase = %"NACL_PRIxNaClPcAddress", " |
| 514 "sz = %"NACL_PRIxNaClMemorySize", alignment = %u\n", | 514 "sz = %"NACL_PRIxNaClMemorySize", alignment = %u\n", |
| 515 vbase, codesize, alignment)); | 515 vbase, codesize, alignment)); |
| 516 if (alignment != 16 && alignment != 32) | |
| 517 return NULL; | |
| 518 if (features == NULL) | 516 if (features == NULL) |
| 519 return NULL; | 517 return NULL; |
| 520 vstate = (NaClValidatorState*) malloc(sizeof(NaClValidatorState)); | 518 vstate = (NaClValidatorState*) malloc(sizeof(NaClValidatorState)); |
| 521 if (vstate != NULL) { | 519 if (vstate != NULL) { |
| 522 return_value = vstate; | 520 return_value = vstate; |
| 523 vstate->decoder_tables = kNaClValDecoderTables; | 521 vstate->decoder_tables = kNaClValDecoderTables; |
| 524 vstate->vbase = vbase; | 522 vstate->vbase = vbase; |
| 525 vstate->alignment = alignment; | 523 vstate->alignment = alignment; |
| 526 vstate->codesize = codesize; | 524 vstate->codesize = codesize; |
| 527 vstate->alignment_mask = alignment - 1; | 525 vstate->alignment_mask = alignment - 1; |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 "Code modification: code segments have different " | 937 "Code modification: code segments have different " |
| 940 "number of instructions\n"); | 938 "number of instructions\n"); |
| 941 } | 939 } |
| 942 } while (0); | 940 } while (0); |
| 943 NaClValidatorStateIterFinish(vstate); | 941 NaClValidatorStateIterFinish(vstate); |
| 944 NaClApplyPostValidators(vstate); | 942 NaClApplyPostValidators(vstate); |
| 945 vstate->cur_iter = NULL; | 943 vstate->cur_iter = NULL; |
| 946 NaClInstIterDestroy(iter_old); | 944 NaClInstIterDestroy(iter_old); |
| 947 NaClInstIterDestroy(iter_new); | 945 NaClInstIterDestroy(iter_new); |
| 948 } | 946 } |
| OLD | NEW |