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