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

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: More 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
38 static NaClValidationCache *g_validation_cache = NULL;
37 39
38 void NaClSetIrtFileDesc(int fd) { 40 void NaClSetIrtFileDesc(int fd) {
39 CHECK(g_irt_file_desc == -1); 41 CHECK(g_irt_file_desc == -1);
40 g_irt_file_desc = fd; 42 g_irt_file_desc = fd;
41 } 43 }
42 44
43 static void NaClLoadIrt(struct NaClApp *nap) { 45 static void NaClLoadIrt(struct NaClApp *nap) {
44 int file_desc; 46 int file_desc;
45 struct GioPio gio_pio; 47 struct GioPio gio_pio;
46 struct Gio *gio_desc; 48 struct Gio *gio_desc;
(...skipping 19 matching lines...) Expand all
66 if (NaClAppLoadFileDynamically(nap, gio_desc) != LOAD_OK) { 68 if (NaClAppLoadFileDynamically(nap, gio_desc) != LOAD_OK) {
67 NaClLog(LOG_FATAL, 69 NaClLog(LOG_FATAL,
68 "NaClLoadIrt: Failed to load the integrated runtime (IRT). " 70 "NaClLoadIrt: Failed to load the integrated runtime (IRT). "
69 "The user executable was probably not built to use the IRT.\n"); 71 "The user executable was probably not built to use the IRT.\n");
70 } 72 }
71 73
72 (*NACL_VTBL(Gio, gio_desc)->Close)(gio_desc); 74 (*NACL_VTBL(Gio, gio_desc)->Close)(gio_desc);
73 (*NACL_VTBL(Gio, gio_desc)->Dtor)(gio_desc); 75 (*NACL_VTBL(Gio, gio_desc)->Dtor)(gio_desc);
74 } 76 }
75 77
78 /* TODO(ncbray) consolidate Chrome's sel_ldr setup to a single function. */
79 void NaClSetValidationCache(NaClValidationCache *cache) {
80 g_validation_cache = cache;
81 }
82
76 void NaClMainForChromium(int handle_count, const NaClHandle *handles, 83 void NaClMainForChromium(int handle_count, const NaClHandle *handles,
77 int debug) { 84 int debug) {
78 char *av[1]; 85 char *av[1];
79 int ac = 1; 86 int ac = 1;
80 const char **envp; 87 const char **envp;
81 struct NaClApp state; 88 struct NaClApp state;
82 int export_addr_to = (int) handles[0]; /* Used to be set by -X. */ 89 int export_addr_to = (int) handles[0]; /* Used to be set by -X. */
83 struct NaClApp *nap = &state; 90 struct NaClApp *nap = &state;
84 NaClErrorCode errcode = LOAD_INTERNAL; 91 NaClErrorCode errcode = LOAD_INTERNAL;
85 int ret_code = 1; 92 int ret_code = 1;
(...skipping 15 matching lines...) Expand all
101 /* to be passed to NaClMain, eventually... */ 108 /* to be passed to NaClMain, eventually... */
102 av[0] = "NaClMain"; 109 av[0] = "NaClMain";
103 110
104 if (!NaClAppCtor(&state)) { 111 if (!NaClAppCtor(&state)) {
105 fprintf(stderr, "Error while constructing app state\n"); 112 fprintf(stderr, "Error while constructing app state\n");
106 goto done_ctor; 113 goto done_ctor;
107 } 114 }
108 115
109 errcode = LOAD_OK; 116 errcode = LOAD_OK;
110 117
118 /* Inject the validation caching interface, if it exists. */
119 nap->validation_cache = g_validation_cache;
120
111 NaClAppInitialDescriptorHookup(nap); 121 NaClAppInitialDescriptorHookup(nap);
112 122
113 /* 123 /*
114 * NACL_SERVICE_PORT_DESCRIPTOR and NACL_SERVICE_ADDRESS_DESCRIPTOR 124 * NACL_SERVICE_PORT_DESCRIPTOR and NACL_SERVICE_ADDRESS_DESCRIPTOR
115 * are 3 and 4. 125 * are 3 and 4.
116 */ 126 */
117 127
118 /* import IMC handle - used to be "-i" */ 128 /* import IMC handle - used to be "-i" */
119 CHECK(handle_count == 1); 129 CHECK(handle_count == 1);
120 NaClAddImcHandle(nap, handles[0], export_addr_to); 130 NaClAddImcHandle(nap, handles[0], export_addr_to);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 if (LOAD_OK != errcode) { 300 if (LOAD_OK != errcode) {
291 NaClBlockIfCommandChannelExists(nap); 301 NaClBlockIfCommandChannelExists(nap);
292 } 302 }
293 303
294 done_ctor: 304 done_ctor:
295 305
296 NaClAllModulesFini(); 306 NaClAllModulesFini();
297 307
298 NaClExit(ret_code); 308 NaClExit(ret_code);
299 } 309 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698