Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/tools/validator_tools/ncstubout.c

Issue 10134056: Refactor the process of choosing validators. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: more aesthetics Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/tools/validator_tools/build.scons ('k') | src/trusted/service_runtime/build.scons » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /* 7 /*
8 * This tool rewrites ELF files to replace instructions that will be 8 * This tool rewrites ELF files to replace instructions that will be
9 * rejected by the validator with safe HLT instructions. This is 9 * rejected by the validator with safe HLT instructions. This is
10 * useful if you have a large library in which many functions do not 10 * useful if you have a large library in which many functions do not
(...skipping 11 matching lines...) Expand all
22 #include "native_client/src/shared/platform/nacl_check.h" 22 #include "native_client/src/shared/platform/nacl_check.h"
23 #include "native_client/src/shared/utils/types.h" 23 #include "native_client/src/shared/utils/types.h"
24 #include "native_client/src/trusted/validator/cpufeatures.h" 24 #include "native_client/src/trusted/validator/cpufeatures.h"
25 #include "native_client/src/trusted/validator/ncvalidate.h" 25 #include "native_client/src/trusted/validator/ncvalidate.h"
26 26
27 static Bool FixUpSection(uintptr_t load_address, 27 static Bool FixUpSection(uintptr_t load_address,
28 unsigned char *code, 28 unsigned char *code,
29 size_t code_size) { 29 size_t code_size) {
30 NaClValidationStatus status; 30 NaClValidationStatus status;
31 NaClCPUFeatures cpu_features; 31 NaClCPUFeatures cpu_features;
32 const struct NaClValidatorInterface *validator = NaClCreateValidator();
32 /* Pretend that the CPU supports every feature so that we will only stub out 33 /* Pretend that the CPU supports every feature so that we will only stub out
33 * instructions that NaCl will never allow under any condition. 34 * instructions that NaCl will never allow under any condition.
34 */ 35 */
35 NaClSetAllCPUFeatures(&cpu_features); 36 NaClSetAllCPUFeatures(&cpu_features);
36 37
37 status = NACL_SUBARCH_NAME(ApplyValidator, 38 status = validator->Validate(load_address, code, code_size,
38 NACL_TARGET_ARCH,
39 NACL_TARGET_SUBARCH)
40 (load_address, code, code_size,
41 /* stubout_mode= */ TRUE, /* readonly_text= */ FALSE, 39 /* stubout_mode= */ TRUE, /* readonly_text= */ FALSE,
42 &cpu_features, NULL); 40 &cpu_features, NULL);
43 if (status == NaClValidationSucceeded) { 41 if (status == NaClValidationSucceeded) {
44 /* Now run the validator again, so that we report any errors 42 /* Now run the validator again, so that we report any errors
45 * that were not fixed by stubbing out. This is done so that 43 * that were not fixed by stubbing out. This is done so that
46 * the user knows that stubout doesn't fix all errors. 44 * the user knows that stubout doesn't fix all errors.
47 */ 45 */
48 status = NACL_SUBARCH_NAME(ApplyValidatorVerbosely, 46 status = NACL_SUBARCH_NAME(ApplyValidatorVerbosely,
49 NACL_TARGET_ARCH, 47 NACL_TARGET_ARCH,
50 NACL_TARGET_SUBARCH) 48 NACL_TARGET_SUBARCH)
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 fprintf(stderr, "Usage: %s <input-file> -o <output-file>\n\n", argv[0]); 198 fprintf(stderr, "Usage: %s <input-file> -o <output-file>\n\n", argv[0]);
201 fprintf(stderr, 199 fprintf(stderr,
202 "This tool rewrites ELF objects to replace instructions that are\n" 200 "This tool rewrites ELF objects to replace instructions that are\n"
203 "rejected by the NaCl validator with safe HLT instructions.\n"); 201 "rejected by the NaCl validator with safe HLT instructions.\n");
204 GioFileDtor((struct Gio*) &err); 202 GioFileDtor((struct Gio*) &err);
205 return 1; 203 return 1;
206 } 204 }
207 GioFileDtor((struct Gio*) &err); 205 GioFileDtor((struct Gio*) &err);
208 return FixUpELFFile(argv[1], argv[3]) ? 0 : 1; 206 return FixUpELFFile(argv[1], argv[3]) ? 0 : 1;
209 } 207 }
OLDNEW
« no previous file with comments | « src/tools/validator_tools/build.scons ('k') | src/trusted/service_runtime/build.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698