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

Side by Side Diff: chrome/nacl/nacl_helper_linux.cc

Issue 11828010: NaCl: Fix '*' spacing style in nacl_helper_linux.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // A mini-zygote specifically for Native Client. 5 // A mini-zygote specifically for Native Client.
6 6
7 #include "chrome/common/nacl_helper_linux.h" 7 #include "chrome/common/nacl_helper_linux.h"
8 8
9 #include <errno.h> 9 #include <errno.h>
10 #include <link.h> 10 #include <link.h>
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // structure. The debugger will look for that symbol by name to 138 // structure. The debugger will look for that symbol by name to
139 // discover the addresses of key dynamic linker data structures. 139 // discover the addresses of key dynamic linker data structures.
140 // Since all it knows about is the original main executable, which 140 // Since all it knows about is the original main executable, which
141 // is the bootstrap program, it finds the symbol defined there. The 141 // is the bootstrap program, it finds the symbol defined there. The
142 // dynamic linker's structure is somewhere else, but it is filled in 142 // dynamic linker's structure is somewhere else, but it is filled in
143 // after initialization. The parts that really matter to the 143 // after initialization. The parts that really matter to the
144 // debugger never change. So we just copy the contents of the 144 // debugger never change. So we just copy the contents of the
145 // dynamic linker's structure into the address provided by the option. 145 // dynamic linker's structure into the address provided by the option.
146 // Hereafter, if someone attaches a debugger (or examines a core dump), 146 // Hereafter, if someone attaches a debugger (or examines a core dump),
147 // the debugger will find all the symbols in the normal way. 147 // the debugger will find all the symbols in the normal way.
148 static void CheckRDebug(char *argv0) { 148 static void CheckRDebug(char* argv0) {
149 std::string r_debug_switch_value = 149 std::string r_debug_switch_value =
150 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(kNaClHelperRDebug); 150 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(kNaClHelperRDebug);
151 if (!r_debug_switch_value.empty()) { 151 if (!r_debug_switch_value.empty()) {
152 char *endp; 152 char* endp;
153 uintptr_t r_debug_addr = strtoul(r_debug_switch_value.c_str(), &endp, 0); 153 uintptr_t r_debug_addr = strtoul(r_debug_switch_value.c_str(), &endp, 0);
154 if (r_debug_addr != 0 && *endp == '\0') { 154 if (r_debug_addr != 0 && *endp == '\0') {
155 struct r_debug *bootstrap_r_debug = (struct r_debug *) r_debug_addr; 155 struct r_debug* bootstrap_r_debug =
Roland McGrath 2013/01/09 18:55:12 It is probably style-correct to drop 'struct' too.
156 reinterpret_cast<struct r_debug*>(r_debug_addr);
156 *bootstrap_r_debug = _r_debug; 157 *bootstrap_r_debug = _r_debug;
157 158
158 // Since the main executable (the bootstrap program) does not 159 // Since the main executable (the bootstrap program) does not
159 // have a dynamic section, the debugger will not skip the 160 // have a dynamic section, the debugger will not skip the
160 // first element of the link_map list as it usually would for 161 // first element of the link_map list as it usually would for
161 // an executable or PIE that was loaded normally. But the 162 // an executable or PIE that was loaded normally. But the
162 // dynamic linker has set l_name for the PIE to "" as is 163 // dynamic linker has set l_name for the PIE to "" as is
163 // normal for the main executable. So the debugger doesn't 164 // normal for the main executable. So the debugger doesn't
164 // know which file it is. Fill in the actual file name, which 165 // know which file it is. Fill in the actual file name, which
165 // came in as our argv[0]. 166 // came in as our argv[0].
166 struct link_map *l = _r_debug.r_map; 167 struct link_map* l = _r_debug.r_map;
Roland McGrath 2013/01/09 18:55:12 Same here.
167 if (l->l_name[0] == '\0') 168 if (l->l_name[0] == '\0')
168 l->l_name = argv0; 169 l->l_name = argv0;
169 } 170 }
170 } 171 }
171 } 172 }
172 173
173 // The zygote passes --reserved_at_zero=0xXXXXXXXXXXXXXXXX. 174 // The zygote passes --reserved_at_zero=0xXXXXXXXXXXXXXXXX.
174 // nacl_helper_bootstrap replaces the Xs with the amount of prereserved 175 // nacl_helper_bootstrap replaces the Xs with the amount of prereserved
175 // sandbox memory. 176 // sandbox memory.
176 // 177 //
177 // CheckReservedAtZero parses the value of the argument reserved_at_zero 178 // CheckReservedAtZero parses the value of the argument reserved_at_zero
178 // and returns the amount of prereserved sandbox memory. 179 // and returns the amount of prereserved sandbox memory.
179 static size_t CheckReservedAtZero() { 180 static size_t CheckReservedAtZero() {
180 size_t prereserved_sandbox_size = 0; 181 size_t prereserved_sandbox_size = 0;
181 std::string reserved_at_zero_switch_value = 182 std::string reserved_at_zero_switch_value =
182 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 183 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
183 kNaClHelperReservedAtZero); 184 kNaClHelperReservedAtZero);
184 if (!reserved_at_zero_switch_value.empty()) { 185 if (!reserved_at_zero_switch_value.empty()) {
185 char *endp; 186 char* endp;
186 prereserved_sandbox_size = 187 prereserved_sandbox_size =
187 strtoul(reserved_at_zero_switch_value.c_str(), &endp, 0); 188 strtoul(reserved_at_zero_switch_value.c_str(), &endp, 0);
188 if (*endp != '\0') 189 if (*endp != '\0')
189 LOG(ERROR) << "Could not parse reserved_at_zero argument value of " 190 LOG(ERROR) << "Could not parse reserved_at_zero argument value of "
190 << reserved_at_zero_switch_value; 191 << reserved_at_zero_switch_value;
191 } 192 }
192 return prereserved_sandbox_size; 193 return prereserved_sandbox_size;
193 } 194 }
194 195
195 #if defined(ADDRESS_SANITIZER) 196 #if defined(ADDRESS_SANITIZER)
196 // Do not install the SIGSEGV handler in ASan. This should make the NaCl 197 // Do not install the SIGSEGV handler in ASan. This should make the NaCl
197 // platform qualification test pass. 198 // platform qualification test pass.
198 static const char kAsanDefaultOptionsNaCl[] = "handle_segv=0"; 199 static const char kAsanDefaultOptionsNaCl[] = "handle_segv=0";
199 200
200 // Override the default ASan options for the NaCl helper. 201 // Override the default ASan options for the NaCl helper.
201 // __asan_default_options should not be instrumented, because it is called 202 // __asan_default_options should not be instrumented, because it is called
202 // before ASan is initialized. 203 // before ASan is initialized.
203 extern "C" 204 extern "C"
204 __attribute__((no_address_safety_analysis)) 205 __attribute__((no_address_safety_analysis))
205 const char *__asan_default_options() { 206 const char* __asan_default_options() {
206 return kAsanDefaultOptionsNaCl; 207 return kAsanDefaultOptionsNaCl;
207 } 208 }
208 #endif 209 #endif
209 210
210 int main(int argc, char *argv[]) { 211 int main(int argc, char* argv[]) {
211 CommandLine::Init(argc, argv); 212 CommandLine::Init(argc, argv);
212 base::AtExitManager exit_manager; 213 base::AtExitManager exit_manager;
213 base::RandUint64(); // acquire /dev/urandom fd before sandbox is raised 214 base::RandUint64(); // acquire /dev/urandom fd before sandbox is raised
214 #if !defined(CHROMIUM_SELINUX) 215 #if !defined(CHROMIUM_SELINUX)
215 // Allows NSS to fopen() /dev/urandom. 216 // Allows NSS to fopen() /dev/urandom.
216 sandbox::InitLibcUrandomOverrides(); 217 sandbox::InitLibcUrandomOverrides();
217 #endif 218 #endif
218 #if defined(USE_NSS) 219 #if defined(USE_NSS)
219 // Configure NSS for use inside the NaCl process. 220 // Configure NSS for use inside the NaCl process.
220 // The fork check has not caused problems for NaCl, but this appears to be 221 // The fork check has not caused problems for NaCl, but this appears to be
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 _exit(-1); 269 _exit(-1);
269 } 270 }
270 // if fork fails, send PID=-1 to zygote 271 // if fork fails, send PID=-1 to zygote
271 if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor, &badpid, 272 if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor, &badpid,
272 sizeof(badpid), empty)) { 273 sizeof(badpid), empty)) {
273 LOG(ERROR) << "*** send() to zygote failed"; 274 LOG(ERROR) << "*** send() to zygote failed";
274 } 275 }
275 } 276 }
276 CHECK(false); // This routine must not return 277 CHECK(false); // This routine must not return
277 } 278 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698