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

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: Remove "struct" 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 r_debug* bootstrap_r_debug = reinterpret_cast<r_debug*>(r_debug_addr);
156 *bootstrap_r_debug = _r_debug; 156 *bootstrap_r_debug = _r_debug;
157 157
158 // Since the main executable (the bootstrap program) does not 158 // Since the main executable (the bootstrap program) does not
159 // have a dynamic section, the debugger will not skip the 159 // have a dynamic section, the debugger will not skip the
160 // first element of the link_map list as it usually would for 160 // first element of the link_map list as it usually would for
161 // an executable or PIE that was loaded normally. But the 161 // an executable or PIE that was loaded normally. But the
162 // dynamic linker has set l_name for the PIE to "" as is 162 // dynamic linker has set l_name for the PIE to "" as is
163 // normal for the main executable. So the debugger doesn't 163 // normal for the main executable. So the debugger doesn't
164 // know which file it is. Fill in the actual file name, which 164 // know which file it is. Fill in the actual file name, which
165 // came in as our argv[0]. 165 // came in as our argv[0].
166 struct link_map *l = _r_debug.r_map; 166 link_map* l = _r_debug.r_map;
167 if (l->l_name[0] == '\0') 167 if (l->l_name[0] == '\0')
168 l->l_name = argv0; 168 l->l_name = argv0;
169 } 169 }
170 } 170 }
171 } 171 }
172 172
173 // The zygote passes --reserved_at_zero=0xXXXXXXXXXXXXXXXX. 173 // The zygote passes --reserved_at_zero=0xXXXXXXXXXXXXXXXX.
174 // nacl_helper_bootstrap replaces the Xs with the amount of prereserved 174 // nacl_helper_bootstrap replaces the Xs with the amount of prereserved
175 // sandbox memory. 175 // sandbox memory.
176 // 176 //
177 // CheckReservedAtZero parses the value of the argument reserved_at_zero 177 // CheckReservedAtZero parses the value of the argument reserved_at_zero
178 // and returns the amount of prereserved sandbox memory. 178 // and returns the amount of prereserved sandbox memory.
179 static size_t CheckReservedAtZero() { 179 static size_t CheckReservedAtZero() {
180 size_t prereserved_sandbox_size = 0; 180 size_t prereserved_sandbox_size = 0;
181 std::string reserved_at_zero_switch_value = 181 std::string reserved_at_zero_switch_value =
182 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 182 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
183 kNaClHelperReservedAtZero); 183 kNaClHelperReservedAtZero);
184 if (!reserved_at_zero_switch_value.empty()) { 184 if (!reserved_at_zero_switch_value.empty()) {
185 char *endp; 185 char* endp;
186 prereserved_sandbox_size = 186 prereserved_sandbox_size =
187 strtoul(reserved_at_zero_switch_value.c_str(), &endp, 0); 187 strtoul(reserved_at_zero_switch_value.c_str(), &endp, 0);
188 if (*endp != '\0') 188 if (*endp != '\0')
189 LOG(ERROR) << "Could not parse reserved_at_zero argument value of " 189 LOG(ERROR) << "Could not parse reserved_at_zero argument value of "
190 << reserved_at_zero_switch_value; 190 << reserved_at_zero_switch_value;
191 } 191 }
192 return prereserved_sandbox_size; 192 return prereserved_sandbox_size;
193 } 193 }
194 194
195 #if defined(ADDRESS_SANITIZER) 195 #if defined(ADDRESS_SANITIZER)
196 // Do not install the SIGSEGV handler in ASan. This should make the NaCl 196 // Do not install the SIGSEGV handler in ASan. This should make the NaCl
197 // platform qualification test pass. 197 // platform qualification test pass.
198 static const char kAsanDefaultOptionsNaCl[] = "handle_segv=0"; 198 static const char kAsanDefaultOptionsNaCl[] = "handle_segv=0";
199 199
200 // Override the default ASan options for the NaCl helper. 200 // Override the default ASan options for the NaCl helper.
201 // __asan_default_options should not be instrumented, because it is called 201 // __asan_default_options should not be instrumented, because it is called
202 // before ASan is initialized. 202 // before ASan is initialized.
203 extern "C" 203 extern "C"
204 __attribute__((no_address_safety_analysis)) 204 __attribute__((no_address_safety_analysis))
205 const char *__asan_default_options() { 205 const char* __asan_default_options() {
206 return kAsanDefaultOptionsNaCl; 206 return kAsanDefaultOptionsNaCl;
207 } 207 }
208 #endif 208 #endif
209 209
210 int main(int argc, char *argv[]) { 210 int main(int argc, char* argv[]) {
211 CommandLine::Init(argc, argv); 211 CommandLine::Init(argc, argv);
212 base::AtExitManager exit_manager; 212 base::AtExitManager exit_manager;
213 base::RandUint64(); // acquire /dev/urandom fd before sandbox is raised 213 base::RandUint64(); // acquire /dev/urandom fd before sandbox is raised
214 #if !defined(CHROMIUM_SELINUX) 214 #if !defined(CHROMIUM_SELINUX)
215 // Allows NSS to fopen() /dev/urandom. 215 // Allows NSS to fopen() /dev/urandom.
216 sandbox::InitLibcUrandomOverrides(); 216 sandbox::InitLibcUrandomOverrides();
217 #endif 217 #endif
218 #if defined(USE_NSS) 218 #if defined(USE_NSS)
219 // Configure NSS for use inside the NaCl process. 219 // Configure NSS for use inside the NaCl process.
220 // The fork check has not caused problems for NaCl, but this appears to be 220 // 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); 268 _exit(-1);
269 } 269 }
270 // if fork fails, send PID=-1 to zygote 270 // if fork fails, send PID=-1 to zygote
271 if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor, &badpid, 271 if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor, &badpid,
272 sizeof(badpid), empty)) { 272 sizeof(badpid), empty)) {
273 LOG(ERROR) << "*** send() to zygote failed"; 273 LOG(ERROR) << "*** send() to zygote failed";
274 } 274 }
275 } 275 }
276 CHECK(false); // This routine must not return 276 CHECK(false); // This routine must not return
277 } 277 }
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