Chromium Code Reviews| 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 /* | 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 21 matching lines...) Expand all Loading... | |
| 32 NaClValidationStatus status; | 32 NaClValidationStatus status; |
| 33 NaClCPUFeatures cpu_features; | 33 NaClCPUFeatures cpu_features; |
| 34 /* Pretend that the CPU supports every feature so that we will only stub out | 34 /* Pretend that the CPU supports every feature so that we will only stub out |
| 35 * instructions that NaCl will never allow under any condition. | 35 * instructions that NaCl will never allow under any condition. |
| 36 */ | 36 */ |
| 37 NaClSetAllCPUFeatures(&cpu_features); | 37 NaClSetAllCPUFeatures(&cpu_features); |
| 38 | 38 |
| 39 status = NACL_SUBARCH_NAME(ApplyValidator, | 39 status = NACL_SUBARCH_NAME(ApplyValidator, |
| 40 NACL_TARGET_ARCH, | 40 NACL_TARGET_ARCH, |
| 41 NACL_TARGET_SUBARCH) | 41 NACL_TARGET_SUBARCH) |
| 42 (sb_kind, NaClApplyValidationDoStubout, load_address, code, | 42 (sb_kind, load_address, code, code_size, bundle_size, TRUE, FALSE, |
|
Mark Seaborn
2012/04/10 00:57:38
Can you write it as
/* stubout_mode= */ TRUE,
/* r
Nick Bray (chromium)
2012/04/10 18:49:20
Done.
| |
| 43 code_size, bundle_size, FALSE, &cpu_features, NULL); | 43 &cpu_features, NULL); |
| 44 if (status == NaClValidationSucceeded) { | 44 if (status == NaClValidationSucceeded) { |
| 45 /* Now run the validator again, so that we report any errors | 45 /* Now run the validator again, so that we report any errors |
| 46 * that were not fixed by stubbing out. This is done so that | 46 * that were not fixed by stubbing out. This is done so that |
| 47 * the user knows that stubout doesn't fix all errors. | 47 * the user knows that stubout doesn't fix all errors. |
| 48 */ | 48 */ |
| 49 status = NACL_SUBARCH_NAME(ApplyValidatorVerbosely, | 49 status = NACL_SUBARCH_NAME(ApplyValidatorVerbosely, |
| 50 NACL_TARGET_ARCH, | 50 NACL_TARGET_ARCH, |
| 51 NACL_TARGET_SUBARCH) | 51 NACL_TARGET_SUBARCH) |
| 52 (sb_kind, NaClApplyCodeValidation, load_address, code, code_size, | 52 (sb_kind, load_address, code, code_size, bundle_size, &cpu_features); |
| 53 bundle_size, &cpu_features); | |
| 54 } | 53 } |
| 55 | 54 |
| 56 switch (status) { | 55 switch (status) { |
| 57 case NaClValidationSucceeded: | 56 case NaClValidationSucceeded: |
| 58 return TRUE; | 57 return TRUE; |
| 59 default: | 58 default: |
| 60 case NaClValidationFailed: | 59 case NaClValidationFailed: |
| 61 fprintf(stderr, "Errors still exist after attempting to stubout code\n"); | 60 fprintf(stderr, "Errors still exist after attempting to stubout code\n"); |
| 62 return FALSE; | 61 return FALSE; |
| 63 case NaClValidationFailedOutOfMemory: | 62 case NaClValidationFailedOutOfMemory: |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 fprintf(stderr, "Usage: %s <input-file> -o <output-file>\n\n", argv[0]); | 201 fprintf(stderr, "Usage: %s <input-file> -o <output-file>\n\n", argv[0]); |
| 203 fprintf(stderr, | 202 fprintf(stderr, |
| 204 "This tool rewrites ELF objects to replace instructions that are\n" | 203 "This tool rewrites ELF objects to replace instructions that are\n" |
| 205 "rejected by the NaCl validator with safe HLT instructions.\n"); | 204 "rejected by the NaCl validator with safe HLT instructions.\n"); |
| 206 GioFileDtor((struct Gio*) &err); | 205 GioFileDtor((struct Gio*) &err); |
| 207 return 1; | 206 return 1; |
| 208 } | 207 } |
| 209 GioFileDtor((struct Gio*) &err); | 208 GioFileDtor((struct Gio*) &err); |
| 210 return FixUpELFFile(argv[1], argv[3]) ? 0 : 1; | 209 return FixUpELFFile(argv[1], argv[3]) ? 0 : 1; |
| 211 } | 210 } |
| OLD | NEW |