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

Side by Side Diff: src/trusted/validator_arm/ncval.cc

Issue 7799013: Intial Thumb2 Sandbox (naclrev 6680) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: asdsa Created 9 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2011 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
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 problem_code.c_str(), ref_vaddr); 44 problem_code.c_str(), ref_vaddr);
45 } 45 }
46 virtual bool should_continue() { 46 virtual bool should_continue() {
47 // Collect *all* problems before returning! 47 // Collect *all* problems before returning!
48 return true; 48 return true;
49 } 49 }
50 }; 50 };
51 51
52 const uint32_t kOneGig = 1U * 1024 * 1024 * 1024; 52 const uint32_t kOneGig = 1U * 1024 * 1024 * 1024;
53 53
54 int validate(const ncfile *ncf, bool use_zero_masks) { 54 int validate(const ncfile *ncf, bool use_zero_masks, bool thumb) {
55 nacl_arm_dec::RegisterList roRegs = nacl_arm_dec::Register(9);
56 if (thumb) {
57 roRegs = nacl_arm_dec::kRegisterListNothing;
58 }
55 SfiValidator validator( 59 SfiValidator validator(
56 16, // bytes per bundle 60 16, // bytes per bundle
57 // TODO(cbiffle): maybe check region sizes from ELF headers? 61 // TODO(cbiffle): maybe check region sizes from ELF headers?
58 // verify that instructions are in right region 62 // verify that instructions are in right region
59 kOneGig, // code region size 63 kOneGig, // code region size
60 kOneGig, // data region size 64 kOneGig, // data region size
61 nacl_arm_dec::Register(9), // read only register (used for threading) 65 roRegs, // read only register (used for threading)
62 nacl_arm_dec::Register(13)); // stack pointer 66 nacl_arm_dec::Register(13), // stack pointer
67 thumb);
63 68
64 if (use_zero_masks) { 69 if (use_zero_masks) {
65 validator.change_masks(0, 0); 70 validator.change_masks(0, 0, 0);
66 } 71 }
67 72
68 CommandLineProblemSink sink; 73 CommandLineProblemSink sink;
69 74
70 Elf_Shdr *shdr = ncf->sheaders; 75 Elf_Shdr *shdr = ncf->sheaders;
71 76
72 vector<CodeSegment> segments; 77 vector<CodeSegment> segments;
73 for (int i = 0; i < ncf->shnum; i++) { 78 for (int i = 0; i < ncf->shnum; i++) {
74 if ((shdr[i].sh_flags & SHF_EXECINSTR) != SHF_EXECINSTR) { 79 if ((shdr[i].sh_flags & SHF_EXECINSTR) != SHF_EXECINSTR) {
75 continue; 80 continue;
76 } 81 }
77
78 CodeSegment segment(ncf->data + (shdr[i].sh_addr - ncf->vbase), 82 CodeSegment segment(ncf->data + (shdr[i].sh_addr - ncf->vbase),
79 shdr[i].sh_addr, shdr[i].sh_size); 83 shdr[i].sh_addr, shdr[i].sh_size);
80 segments.push_back(segment); 84 segments.push_back(segment);
81 } 85 }
82 86
83 std::sort(segments.begin(), segments.end()); 87 std::sort(segments.begin(), segments.end());
84 88
85 bool success = validator.validate(segments, &sink); 89 bool success = validator.validate(segments, &sink);
86 if (!success) return 1; 90 if (!success) return 1;
87 return 0; 91 return 0;
(...skipping 22 matching lines...) Expand all
110 return 2; 114 return 2;
111 } 115 }
112 116
113 ncfile *ncf = nc_loadfile(filename); 117 ncfile *ncf = nc_loadfile(filename);
114 if (!ncf) { 118 if (!ncf) {
115 fprintf(stderr, "Unable to load %s: %s\n", filename, strerror(errno)); 119 fprintf(stderr, "Unable to load %s: %s\n", filename, strerror(errno));
116 return 1; 120 return 1;
117 } 121 }
118 122
119 // TODO(cbiffle): check OS ABI, ABI version, align mask 123 // TODO(cbiffle): check OS ABI, ABI version, align mask
124 int exit_code = validate(ncf, use_zero_masks, ncf->eheader->e_entry & 1);
120 125
121 int exit_code = validate(ncf, use_zero_masks);
122 nc_freefile(ncf); 126 nc_freefile(ncf);
123 return exit_code; 127 return exit_code;
124 } 128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698