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 ApplyDfaValidator API for the x86-32 architecture. */ | |
8 #include <assert.h> | |
9 #include "native_client/src/shared/platform/nacl_log.h" | |
10 #include "native_client/src/trusted/validator/ncvalidate.h" | |
11 #include "native_client/src/trusted/validator/validation_cache.h" | |
12 #include "native_client/src/trusted/validator_ragel/unreviewed/validator.h" | |
13 | |
14 /* Be sure the correct compile flags are defined for this. */ | |
15 #if NACL_ARCH(NACL_TARGET_ARCH) != NACL_x86 | |
16 # error("Can't compile, target is for x86-32") | |
17 #else | |
18 # if NACL_TARGET_SUBARCH != 32 | |
19 # error("Can't compile, target is for x86-32") | |
20 # endif | |
21 #endif | |
22 | |
23 | |
24 static void ProcessError(const uint8_t *ptr, void *userdata) { | |
25 UNREFERENCED_PARAMETER(ptr); | |
26 UNREFERENCED_PARAMETER(userdata); | |
27 } | |
28 | |
29 NaClValidationStatus NACL_SUBARCH_NAME(ApplyDfaValidator, x86, 32) ( | |
30 enum NaClSBKind sb_kind, | |
31 uintptr_t guest_addr, | |
32 uint8_t *data, | |
33 size_t size, | |
34 int stubout_mode, | |
35 int readonly_text, | |
36 const NaClCPUFeaturesX86 *cpu_features, | |
37 struct NaClValidationCache *cache) { | |
38 UNREFERENCED_PARAMETER(guest_addr); | |
39 UNREFERENCED_PARAMETER(readonly_text); | |
Nick Bray
2012/04/19 23:11:08
I'd check if readonly_text and error if it's reque
pasko-google - do not use
2012/04/20 14:30:38
Done.
| |
40 UNREFERENCED_PARAMETER(cache); | |
41 | |
42 if (stubout_mode || sb_kind != NACL_SB_DEFAULT) { | |
Nick Bray
2012/04/19 23:11:08
Keep the checks separate, it makes it easier to re
pasko-google - do not use
2012/04/20 14:30:38
Code should be optimized for readability, not for
| |
43 return NaClValidationFailedNotImplemented; | |
44 } | |
45 if (!NaClArchSupported(cpu_features)) { | |
46 return NaClValidationFailedCpuNotSupported; | |
47 } | |
48 if (!ValidateChunkIA32(data, size, ProcessError, 0)) { | |
Nick Bray
2012/04/19 23:11:08
Nit: == 0? This would make it clearer that you're
pasko-google - do not use
2012/04/20 14:30:38
Good nit. Done.
| |
49 return NaClValidationSucceeded; | |
50 } | |
51 return NaClValidationFailed; | |
52 } | |
OLD | NEW |