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

Side by Side Diff: src/trusted/service_runtime/sel_main_chrome.c

Issue 9535001: Add validation caching interface. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Edits Created 8 years, 9 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) 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 "native_client/src/include/portability.h" 7 #include "native_client/src/include/portability.h"
8 #include "native_client/src/include/portability_io.h" 8 #include "native_client/src/include/portability_io.h"
9 9
10 #if NACL_OSX 10 #if NACL_OSX
(...skipping 11 matching lines...) Expand all
22 #include "native_client/src/trusted/gio/gio_nacl_desc.h" 22 #include "native_client/src/trusted/gio/gio_nacl_desc.h"
23 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" 23 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h"
24 #include "native_client/src/trusted/service_runtime/nacl_globals.h" 24 #include "native_client/src/trusted/service_runtime/nacl_globals.h"
25 #include "native_client/src/trusted/service_runtime/env_cleanser.h" 25 #include "native_client/src/trusted/service_runtime/env_cleanser.h"
26 #include "native_client/src/trusted/service_runtime/nacl_app.h" 26 #include "native_client/src/trusted/service_runtime/nacl_app.h"
27 #include "native_client/src/trusted/service_runtime/nacl_all_modules.h" 27 #include "native_client/src/trusted/service_runtime/nacl_all_modules.h"
28 #include "native_client/src/trusted/service_runtime/nacl_signal.h" 28 #include "native_client/src/trusted/service_runtime/nacl_signal.h"
29 #include "native_client/src/trusted/service_runtime/sel_ldr.h" 29 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
30 #include "native_client/src/trusted/service_runtime/sel_qualify.h" 30 #include "native_client/src/trusted/service_runtime/sel_qualify.h"
31 #include "native_client/src/trusted/service_runtime/win/exception_patch/ntdll_pa tch.h" 31 #include "native_client/src/trusted/service_runtime/win/exception_patch/ntdll_pa tch.h"
32 #include "native_client/src/trusted/validator/validation_cache.h"
32 33
33 int verbosity = 0; 34 int verbosity = 0;
34 35
35 static int g_irt_file_desc = -1; 36 static int g_irt_file_desc = -1;
36 37
37 38
38 void NaClSetIrtFileDesc(int fd) { 39 void NaClSetIrtFileDesc(int fd) {
39 CHECK(g_irt_file_desc == -1); 40 CHECK(g_irt_file_desc == -1);
40 g_irt_file_desc = fd; 41 g_irt_file_desc = fd;
41 } 42 }
(...skipping 24 matching lines...) Expand all
66 if (NaClAppLoadFileDynamically(nap, gio_desc) != LOAD_OK) { 67 if (NaClAppLoadFileDynamically(nap, gio_desc) != LOAD_OK) {
67 NaClLog(LOG_FATAL, 68 NaClLog(LOG_FATAL,
68 "NaClLoadIrt: Failed to load the integrated runtime (IRT). " 69 "NaClLoadIrt: Failed to load the integrated runtime (IRT). "
69 "The user executable was probably not built to use the IRT.\n"); 70 "The user executable was probably not built to use the IRT.\n");
70 } 71 }
71 72
72 (*NACL_VTBL(Gio, gio_desc)->Close)(gio_desc); 73 (*NACL_VTBL(Gio, gio_desc)->Close)(gio_desc);
73 (*NACL_VTBL(Gio, gio_desc)->Dtor)(gio_desc); 74 (*NACL_VTBL(Gio, gio_desc)->Dtor)(gio_desc);
74 } 75 }
75 76
77 static NaClValidationCache *g_validation_cache = NULL;
Mark Seaborn 2012/03/01 00:26:20 Move this to the global vars block at the top
Nick Bray (chromium) 2012/03/01 01:25:16 Done.
78
79 /* TODO(ncbray) consolidate Chrome's sel_ldr setup to a single function. */
Mark Seaborn 2012/03/01 00:26:20 NaClSetIrtFileDesc() is in sel_ldr.h so this shoul
80 void NaClSetValidationCache(NaClValidationCache *cache) {
81 g_validation_cache = cache;
82 }
83
76 void NaClMainForChromium(int handle_count, const NaClHandle *handles, 84 void NaClMainForChromium(int handle_count, const NaClHandle *handles,
77 int debug) { 85 int debug) {
78 char *av[1]; 86 char *av[1];
79 int ac = 1; 87 int ac = 1;
80 const char **envp; 88 const char **envp;
81 struct NaClApp state; 89 struct NaClApp state;
82 int export_addr_to = (int) handles[0]; /* Used to be set by -X. */ 90 int export_addr_to = (int) handles[0]; /* Used to be set by -X. */
83 struct NaClApp *nap = &state; 91 struct NaClApp *nap = &state;
84 NaClErrorCode errcode = LOAD_INTERNAL; 92 NaClErrorCode errcode = LOAD_INTERNAL;
85 int ret_code = 1; 93 int ret_code = 1;
(...skipping 15 matching lines...) Expand all
101 /* to be passed to NaClMain, eventually... */ 109 /* to be passed to NaClMain, eventually... */
102 av[0] = "NaClMain"; 110 av[0] = "NaClMain";
103 111
104 if (!NaClAppCtor(&state)) { 112 if (!NaClAppCtor(&state)) {
105 fprintf(stderr, "Error while constructing app state\n"); 113 fprintf(stderr, "Error while constructing app state\n");
106 goto done_ctor; 114 goto done_ctor;
107 } 115 }
108 116
109 errcode = LOAD_OK; 117 errcode = LOAD_OK;
110 118
119 /* Inject the validation caching interface, if it exists. */
120 nap->validation_cache = g_validation_cache;
121
111 NaClAppInitialDescriptorHookup(nap); 122 NaClAppInitialDescriptorHookup(nap);
112 123
113 /* 124 /*
114 * NACL_SERVICE_PORT_DESCRIPTOR and NACL_SERVICE_ADDRESS_DESCRIPTOR 125 * NACL_SERVICE_PORT_DESCRIPTOR and NACL_SERVICE_ADDRESS_DESCRIPTOR
115 * are 3 and 4. 126 * are 3 and 4.
116 */ 127 */
117 128
118 /* import IMC handle - used to be "-i" */ 129 /* import IMC handle - used to be "-i" */
119 CHECK(handle_count == 1); 130 CHECK(handle_count == 1);
120 NaClAddImcHandle(nap, handles[0], export_addr_to); 131 NaClAddImcHandle(nap, handles[0], export_addr_to);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 if (LOAD_OK != errcode) { 301 if (LOAD_OK != errcode) {
291 NaClBlockIfCommandChannelExists(nap); 302 NaClBlockIfCommandChannelExists(nap);
292 } 303 }
293 304
294 done_ctor: 305 done_ctor:
295 306
296 NaClAllModulesFini(); 307 NaClAllModulesFini();
297 308
298 NaClExit(ret_code); 309 NaClExit(ret_code);
299 } 310 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698