| 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 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 | 14 |
| 15 #include "native_client/src/include/nacl_string.h" | 15 #include "native_client/src/include/nacl_string.h" |
| 16 #include "native_client/src/trusted/validator/ncfileutil.h" | 16 #include "native_client/src/trusted/validator/ncfileutil.h" |
| 17 #include "native_client/src/trusted/validator_mips/model.h" | 17 #include "native_client/src/trusted/validator_mips/model.h" |
| 18 #include "native_client/src/trusted/validator_mips/validator.h" | 18 #include "native_client/src/trusted/validator_mips/validator.h" |
| 19 | 19 |
| 20 using nacl_mips_val::SfiValidator; | 20 using nacl_mips_val::SfiValidator; |
| 21 using nacl_mips_val::CodeSegment; | 21 using nacl_mips_val::CodeSegment; |
| 22 using nacl_mips_dec::RegisterList; |
| 23 using nacl_mips_dec::kRegisterStack; |
| 22 | 24 |
| 23 using std::string; | 25 using std::string; |
| 24 using std::vector; | 26 using std::vector; |
| 25 | 27 |
| 26 /* | 28 /* |
| 27 * Reports problems in an easily-parsed textual format, for consumption by a | 29 * Reports problems in an easily-parsed textual format, for consumption by a |
| 28 * validation-reporting script. | 30 * validation-reporting script. |
| 29 * | 31 * |
| 30 * The format is as follows: | 32 * The format is as follows: |
| 31 * ncval: <hex vaddr> <decimal safety> <problem ID string> <hex ref vaddr> | 33 * ncval: <hex vaddr> <decimal safety> <problem ID string> <hex ref vaddr> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 51 | 53 |
| 52 const uint32_t kOneGig = 1U * 1024 * 1024 * 1024; | 54 const uint32_t kOneGig = 1U * 1024 * 1024 * 1024; |
| 53 const uint32_t kQuarterGig = 256U * 1024 * 1024; | 55 const uint32_t kQuarterGig = 256U * 1024 * 1024; |
| 54 | 56 |
| 55 int Validate(const ncfile *ncf, bool use_zero_masks) { | 57 int Validate(const ncfile *ncf, bool use_zero_masks) { |
| 56 SfiValidator validator( | 58 SfiValidator validator( |
| 57 16, // Bytes per bundle. | 59 16, // Bytes per bundle. |
| 58 kQuarterGig, // Code region size. | 60 kQuarterGig, // Code region size. |
| 59 kOneGig, // Data region size. | 61 kOneGig, // Data region size. |
| 60 nacl_mips_dec::kRegListReserved, // Read only registers. | 62 nacl_mips_dec::kRegListReserved, // Read only registers. |
| 61 nacl_mips_dec::kRegisterStack); // Data addressing register ($sp). | 63 RegisterList(kRegisterStack)); // Data addressing register ($sp). |
| 62 | 64 |
| 63 if (use_zero_masks) { | 65 if (use_zero_masks) { |
| 64 validator.ChangeMasks(0, 0); | 66 validator.ChangeMasks(0, 0); |
| 65 } | 67 } |
| 66 | 68 |
| 67 CommandLineProblemSink sink; | 69 CommandLineProblemSink sink; |
| 68 | 70 |
| 69 Elf_Shdr *shdr = ncf->sheaders; | 71 Elf_Shdr *shdr = ncf->sheaders; |
| 70 | 72 |
| 71 vector<CodeSegment> segments; | 73 vector<CodeSegment> segments; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 ncfile *ncf = nc_loadfile(filename); | 114 ncfile *ncf = nc_loadfile(filename); |
| 113 if (!ncf) { | 115 if (!ncf) { |
| 114 fprintf(stderr, "Unable to load %s: %s\n", filename, strerror(errno)); | 116 fprintf(stderr, "Unable to load %s: %s\n", filename, strerror(errno)); |
| 115 return 1; | 117 return 1; |
| 116 } | 118 } |
| 117 | 119 |
| 118 int exit_code = Validate(ncf, use_zero_masks); | 120 int exit_code = Validate(ncf, use_zero_masks); |
| 119 nc_freefile(ncf); | 121 nc_freefile(ncf); |
| 120 return exit_code; | 122 return exit_code; |
| 121 } | 123 } |
| OLD | NEW |