| 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 #ifndef NACL_TRUSTED_BUT_NOT_TCB | 7 #ifndef NACL_TRUSTED_BUT_NOT_TCB |
| 8 #error("This file is not meant for use in the TCB") | 8 #error("This file is not meant for use in the TCB") |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 */ | 93 */ |
| 94 return NaClInstDecodesCorrectly(inst) && | 94 return NaClInstDecodesCorrectly(inst) && |
| 95 (NACLi_ILLEGAL != NACL_INST(inst)->opinfo->insttype); | 95 (NACLi_ILLEGAL != NACL_INST(inst)->opinfo->insttype); |
| 96 } | 96 } |
| 97 | 97 |
| 98 Bool NaClSegmentValidates(uint8_t* mbase, | 98 Bool NaClSegmentValidates(uint8_t* mbase, |
| 99 size_t size, | 99 size_t size, |
| 100 NaClPcAddress vbase) { | 100 NaClPcAddress vbase) { |
| 101 NaClCPUFeaturesX86 cpu_features; | 101 NaClCPUFeaturesX86 cpu_features; |
| 102 NaClValidationStatus status; | 102 NaClValidationStatus status; |
| 103 /* TODO(pasko): Validator initialization can be slow, make it run only once. |
| 104 */ |
| 105 const struct NaClValidatorInterface *validator = NaClCreateValidator(); |
| 103 | 106 |
| 104 /* check if NaCl thinks the given code segment is valid. */ | 107 /* check if NaCl thinks the given code segment is valid. */ |
| 105 NaClSetAllCPUFeatures(&cpu_features); | 108 NaClSetAllCPUFeatures(&cpu_features); |
| 106 status = NaCl_ApplyValidator_x86_32( | 109 status = validator->Validate( |
| 107 vbase, mbase, size, | 110 vbase, mbase, size, |
| 108 /* stubout_mode= */ FALSE, /* readonly_text= */ FALSE, &cpu_features, | 111 /* stubout_mode= */ FALSE, /* readonly_text= */ FALSE, &cpu_features, |
| 109 NULL); | 112 NULL); |
| 110 switch (status) { | 113 switch (status) { |
| 111 case NaClValidationSucceeded: | 114 case NaClValidationSucceeded: |
| 112 return TRUE; | 115 return TRUE; |
| 113 default: | 116 default: |
| 114 return FALSE; | 117 return FALSE; |
| 115 } | 118 } |
| 116 } | 119 } |
| OLD | NEW |