| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 /* Pretend that the CPU supports every feature so that we will only stub out | 62 /* Pretend that the CPU supports every feature so that we will only stub out |
| 63 * instructions that NaCl will never allow under any condition. | 63 * instructions that NaCl will never allow under any condition. |
| 64 */ | 64 */ |
| 65 validator->SetAllCPUFeatures(cpu_features); | 65 validator->SetAllCPUFeatures(cpu_features); |
| 66 | 66 |
| 67 status = validator->Validate( | 67 status = validator->Validate( |
| 68 load_address, code, code_size, | 68 load_address, code, code_size, |
| 69 /* stubout_mode= */ TRUE, | 69 /* stubout_mode= */ TRUE, |
| 70 /* readonly_text= */ FALSE, | 70 /* readonly_text= */ FALSE, |
| 71 cpu_features, NULL); | 71 cpu_features, |
| 72 /* metadata= */ NULL, |
| 73 /* cache= */ NULL); |
| 72 if (status == NaClValidationSucceeded) { | 74 if (status == NaClValidationSucceeded) { |
| 73 /* Now run the validator again, so that we report any errors | 75 /* Now run the validator again, so that we report any errors |
| 74 * that were not fixed by stubbing out. This is done so that | 76 * that were not fixed by stubbing out. This is done so that |
| 75 * the user knows that stubout doesn't fix all errors. | 77 * the user knows that stubout doesn't fix all errors. |
| 76 */ | 78 */ |
| 77 status = NACL_SUBARCH_NAME(ApplyValidatorVerbosely, | 79 status = NACL_SUBARCH_NAME(ApplyValidatorVerbosely, |
| 78 NACL_TARGET_ARCH, | 80 NACL_TARGET_ARCH, |
| 79 NACL_TARGET_SUBARCH) | 81 NACL_TARGET_SUBARCH) |
| 80 (load_address, code, code_size, cpu_features); | 82 (load_address, code, code_size, cpu_features); |
| 81 } | 83 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 fprintf(stderr, "Usage: %s <input-file> -o <output-file>\n\n", argv[0]); | 213 fprintf(stderr, "Usage: %s <input-file> -o <output-file>\n\n", argv[0]); |
| 212 fprintf(stderr, | 214 fprintf(stderr, |
| 213 "This tool rewrites ELF objects to replace instructions that are\n" | 215 "This tool rewrites ELF objects to replace instructions that are\n" |
| 214 "rejected by the NaCl validator with safe HLT instructions.\n"); | 216 "rejected by the NaCl validator with safe HLT instructions.\n"); |
| 215 GioFileDtor((struct Gio*) &err); | 217 GioFileDtor((struct Gio*) &err); |
| 216 return 1; | 218 return 1; |
| 217 } | 219 } |
| 218 GioFileDtor((struct Gio*) &err); | 220 GioFileDtor((struct Gio*) &err); |
| 219 return FixUpELFFile(argv[1], argv[3]) ? 0 : 1; | 221 return FixUpELFFile(argv[1], argv[3]) ? 0 : 1; |
| 220 } | 222 } |
| OLD | NEW |