Chromium Code Reviews| Index: src/trusted/validator_ragel/unreviewed/dfa_validate_32.c |
| diff --git a/src/trusted/validator_ragel/unreviewed/dfa_validate_32.c b/src/trusted/validator_ragel/unreviewed/dfa_validate_32.c |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7fc6d86ec3db9c13d6af1b64c10aa53995108b1d |
| --- /dev/null |
| +++ b/src/trusted/validator_ragel/unreviewed/dfa_validate_32.c |
| @@ -0,0 +1,52 @@ |
| +/* |
| + * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +/* Implement the ApplyDfaValidator API for the x86-32 architecture. */ |
| +#include <assert.h> |
| +#include "native_client/src/shared/platform/nacl_log.h" |
| +#include "native_client/src/trusted/validator/ncvalidate.h" |
| +#include "native_client/src/trusted/validator/validation_cache.h" |
| +#include "native_client/src/trusted/validator_ragel/unreviewed/validator.h" |
| + |
| +/* Be sure the correct compile flags are defined for this. */ |
| +#if NACL_ARCH(NACL_TARGET_ARCH) != NACL_x86 |
| +# error("Can't compile, target is for x86-32") |
| +#else |
| +# if NACL_TARGET_SUBARCH != 32 |
| +# error("Can't compile, target is for x86-32") |
| +# endif |
| +#endif |
| + |
| + |
| +static void ProcessError(const uint8_t *ptr, void *userdata) { |
| + UNREFERENCED_PARAMETER(ptr); |
| + UNREFERENCED_PARAMETER(userdata); |
| +} |
| + |
| +NaClValidationStatus NACL_SUBARCH_NAME(ApplyDfaValidator, x86, 32) ( |
| + enum NaClSBKind sb_kind, |
| + uintptr_t guest_addr, |
| + uint8_t *data, |
| + size_t size, |
| + int stubout_mode, |
| + int readonly_text, |
| + const NaClCPUFeaturesX86 *cpu_features, |
| + struct NaClValidationCache *cache) { |
| + UNREFERENCED_PARAMETER(guest_addr); |
| + 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.
|
| + UNREFERENCED_PARAMETER(cache); |
| + |
| + 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
|
| + return NaClValidationFailedNotImplemented; |
| + } |
| + if (!NaClArchSupported(cpu_features)) { |
| + return NaClValidationFailedCpuNotSupported; |
| + } |
| + 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.
|
| + return NaClValidationSucceeded; |
| + } |
| + return NaClValidationFailed; |
| +} |