| 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 /* Implement the ApplyValidatorVerbosely API for the x86-32 architecture. */ | 7 /* Implement the ApplyValidatorVerbosely API for the x86-32 architecture. */ |
| 8 | 8 |
| 9 #include "native_client/src/trusted/validator/ncvalidate.h" | 9 #include "native_client/src/trusted/validator/ncvalidate.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #else | 21 #else |
| 22 # if NACL_TARGET_SUBARCH != 32 | 22 # if NACL_TARGET_SUBARCH != 32 |
| 23 # error("Can't compile, target is for x86-32") | 23 # error("Can't compile, target is for x86-32") |
| 24 # endif | 24 # endif |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 static NaClValidationStatus NCApplyValidatorVerbosely_x86_32( | 27 static NaClValidationStatus NCApplyValidatorVerbosely_x86_32( |
| 28 uintptr_t guest_addr, | 28 uintptr_t guest_addr, |
| 29 uint8_t *data, | 29 uint8_t *data, |
| 30 size_t size, | 30 size_t size, |
| 31 int bundle_size, | |
| 32 const NaClCPUFeaturesX86 *cpu_features) { | 31 const NaClCPUFeaturesX86 *cpu_features) { |
| 33 int validator_result = 0; | 32 int validator_result = 0; |
| 34 struct NCValidatorState *vstate; | 33 struct NCValidatorState *vstate; |
| 35 | 34 |
| 36 vstate = NCValidateInitDetailed(guest_addr, size, bundle_size, cpu_features); | 35 vstate = NCValidateInitDetailed(guest_addr, size, cpu_features); |
| 37 if (vstate == NULL) return NaClValidationFailedOutOfMemory; | 36 if (vstate == NULL) return NaClValidationFailedOutOfMemory; |
| 38 NCValidateSetNumDiagnostics(vstate, -1); /* Reports all errors. */ | 37 NCValidateSetNumDiagnostics(vstate, -1); /* Reports all errors. */ |
| 39 NCValidateSetErrorReporter(vstate, &kNCVerboseErrorReporter); | 38 NCValidateSetErrorReporter(vstate, &kNCVerboseErrorReporter); |
| 40 NCValidateSegment(data, guest_addr, size, vstate); | 39 NCValidateSegment(data, guest_addr, size, vstate); |
| 41 validator_result = NCValidateFinish(vstate); | 40 validator_result = NCValidateFinish(vstate); |
| 42 NCValidateFreeState(&vstate); | 41 NCValidateFreeState(&vstate); |
| 43 return (validator_result == 0) | 42 return (validator_result == 0) |
| 44 ? NaClValidationSucceeded : NaClValidationFailed; | 43 ? NaClValidationSucceeded : NaClValidationFailed; |
| 45 } | 44 } |
| 46 | 45 |
| 47 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorVerbosely, x86, 32) | 46 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorVerbosely, x86, 32) |
| 48 (enum NaClSBKind sb_kind, | 47 (enum NaClSBKind sb_kind, |
| 49 uintptr_t guest_addr, | 48 uintptr_t guest_addr, |
| 50 uint8_t *data, | 49 uint8_t *data, |
| 51 size_t size, | 50 size_t size, |
| 52 int bundle_size, | |
| 53 const NaClCPUFeaturesX86 *cpu_features) { | 51 const NaClCPUFeaturesX86 *cpu_features) { |
| 54 NaClValidationStatus status = NaClValidationFailedNotImplemented; | |
| 55 assert(NACL_SB_DEFAULT == sb_kind); | 52 assert(NACL_SB_DEFAULT == sb_kind); |
| 56 if (bundle_size == 16 || bundle_size == 32) { | 53 |
| 57 if (!NaClArchSupported(cpu_features)) | 54 if (!NaClArchSupported(cpu_features)) |
| 58 return NaClValidationFailedCpuNotSupported; | 55 return NaClValidationFailedCpuNotSupported; |
| 59 status = NCApplyValidatorVerbosely_x86_32( | 56 |
| 60 guest_addr, data, size, bundle_size, cpu_features); | 57 return NCApplyValidatorVerbosely_x86_32( |
| 61 } | 58 guest_addr, data, size, cpu_features); |
| 62 return status; | |
| 63 } | 59 } |
| OLD | NEW |