OLD | NEW |
| (Empty) |
1 /* | |
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 | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 /* Implement the ApplyValidatorVerbosely API for the x86-32 architecture. */ | |
8 | |
9 #include "native_client/src/trusted/validator/ncvalidate.h" | |
10 | |
11 #include "native_client/src/shared/platform/nacl_log.h" | |
12 #include "native_client/src/trusted/cpu_features/arch/x86/cpu_x86.h" | |
13 #include "native_client/src/trusted/validator/x86/ncval_seg_sfi/ncvalidate_detai
led.h" | |
14 #include "native_client/src/trusted/validator/x86/ncval_seg_sfi/ncdecode_verbose
.h" | |
15 #include "native_client/src/trusted/validator/x86/ncval_seg_sfi/ncvalidate.h" | |
16 #include <assert.h> | |
17 | |
18 /* Be sure the correct compile flags are defined for this. */ | |
19 #if NACL_ARCH(NACL_TARGET_ARCH) != NACL_x86 | |
20 # error("Can't compile, target is for x86-32") | |
21 #else | |
22 # if NACL_TARGET_SUBARCH != 32 | |
23 # error("Can't compile, target is for x86-32") | |
24 # endif | |
25 #endif | |
26 | |
27 static NaClValidationStatus NCApplyValidatorVerbosely_x86_32( | |
28 uintptr_t guest_addr, | |
29 uint8_t *data, | |
30 size_t size, | |
31 const NaClCPUFeaturesX86 *cpu_features) { | |
32 int validator_result = 0; | |
33 struct NCValidatorState *vstate; | |
34 | |
35 vstate = NCValidateInitDetailed(guest_addr, size, cpu_features); | |
36 if (vstate == NULL) return NaClValidationFailedOutOfMemory; | |
37 NCValidateSetNumDiagnostics(vstate, -1); /* Reports all errors. */ | |
38 NCValidateSetErrorReporter(vstate, &kNCVerboseErrorReporter); | |
39 NCValidateSegment(data, guest_addr, size, vstate); | |
40 validator_result = NCValidateFinish(vstate); | |
41 NCValidateFreeState(&vstate); | |
42 return (validator_result == 0) | |
43 ? NaClValidationSucceeded : NaClValidationFailed; | |
44 } | |
45 | |
46 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorVerbosely, x86, 32) | |
47 (uintptr_t guest_addr, | |
48 uint8_t *data, | |
49 size_t size, | |
50 const NaClCPUFeatures *f) { | |
51 /* TODO(jfb) Use a safe cast here. */ | |
52 const NaClCPUFeaturesX86 *cpu_features = (NaClCPUFeaturesX86 *) f; | |
53 if (!NaClArchSupportedX86(cpu_features)) | |
54 return NaClValidationFailedCpuNotSupported; | |
55 | |
56 return NCApplyValidatorVerbosely_x86_32( | |
57 guest_addr, data, size, cpu_features); | |
58 } | |
OLD | NEW |