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

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: Header update 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/trusted/service_runtime/sel_main_chrome.h" 7 #include "native_client/src/trusted/service_runtime/sel_main_chrome.h"
8 8
9 #include "native_client/src/include/portability.h" 9 #include "native_client/src/include/portability.h"
10 #include "native_client/src/include/portability_io.h" 10 #include "native_client/src/include/portability_io.h"
(...skipping 13 matching lines...) Expand all
24 #include "native_client/src/trusted/gio/gio_nacl_desc.h" 24 #include "native_client/src/trusted/gio/gio_nacl_desc.h"
25 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" 25 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h"
26 #include "native_client/src/trusted/service_runtime/nacl_globals.h" 26 #include "native_client/src/trusted/service_runtime/nacl_globals.h"
27 #include "native_client/src/trusted/service_runtime/env_cleanser.h" 27 #include "native_client/src/trusted/service_runtime/env_cleanser.h"
28 #include "native_client/src/trusted/service_runtime/nacl_app.h" 28 #include "native_client/src/trusted/service_runtime/nacl_app.h"
29 #include "native_client/src/trusted/service_runtime/nacl_all_modules.h" 29 #include "native_client/src/trusted/service_runtime/nacl_all_modules.h"
30 #include "native_client/src/trusted/service_runtime/nacl_signal.h" 30 #include "native_client/src/trusted/service_runtime/nacl_signal.h"
31 #include "native_client/src/trusted/service_runtime/sel_ldr.h" 31 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
32 #include "native_client/src/trusted/service_runtime/sel_qualify.h" 32 #include "native_client/src/trusted/service_runtime/sel_qualify.h"
33 #include "native_client/src/trusted/service_runtime/win/exception_patch/ntdll_pa tch.h" 33 #include "native_client/src/trusted/service_runtime/win/exception_patch/ntdll_pa tch.h"
34 #include "native_client/src/trusted/validator/validation_cache.h"
34 35
35 static int const kSrpcFd = 5; 36 static int const kSrpcFd = 5;
36 37
37 int verbosity = 0; 38 int verbosity = 0;
38 39
39 static int g_irt_file_desc = -1; 40 static int g_irt_file_desc = -1;
40 41
42 static NaClValidationCache *g_validation_cache = NULL;
41 43
42 void NaClSetIrtFileDesc(int fd) { 44 void NaClSetIrtFileDesc(int fd) {
43 CHECK(g_irt_file_desc == -1); 45 CHECK(g_irt_file_desc == -1);
44 g_irt_file_desc = fd; 46 g_irt_file_desc = fd;
45 } 47 }
46 48
47 static void NaClLoadIrt(struct NaClApp *nap) { 49 static void NaClLoadIrt(struct NaClApp *nap) {
48 int file_desc; 50 int file_desc;
49 struct GioPio gio_pio; 51 struct GioPio gio_pio;
50 struct Gio *gio_desc; 52 struct Gio *gio_desc;
(...skipping 19 matching lines...) Expand all
70 if (NaClAppLoadFileDynamically(nap, gio_desc) != LOAD_OK) { 72 if (NaClAppLoadFileDynamically(nap, gio_desc) != LOAD_OK) {
71 NaClLog(LOG_FATAL, 73 NaClLog(LOG_FATAL,
72 "NaClLoadIrt: Failed to load the integrated runtime (IRT). " 74 "NaClLoadIrt: Failed to load the integrated runtime (IRT). "
73 "The user executable was probably not built to use the IRT.\n"); 75 "The user executable was probably not built to use the IRT.\n");
74 } 76 }
75 77
76 (*NACL_VTBL(Gio, gio_desc)->Close)(gio_desc); 78 (*NACL_VTBL(Gio, gio_desc)->Close)(gio_desc);
77 (*NACL_VTBL(Gio, gio_desc)->Dtor)(gio_desc); 79 (*NACL_VTBL(Gio, gio_desc)->Dtor)(gio_desc);
78 } 80 }
79 81
82 /* TODO(ncbray) consolidate Chrome's sel_ldr setup to a single function. */
83 void NaClSetValidationCache(NaClValidationCache *cache) {
84 g_validation_cache = cache;
85 }
86
80 void NaClMainForChromium(int handle_count, const NaClHandle *handles, 87 void NaClMainForChromium(int handle_count, const NaClHandle *handles,
81 int debug) { 88 int debug) {
82 char *av[1]; 89 char *av[1];
83 int ac = 1; 90 int ac = 1;
84 const char **envp; 91 const char **envp;
85 struct NaClApp state; 92 struct NaClApp state;
86 int export_addr_to = kSrpcFd; /* Used to be set by -X. */ 93 int export_addr_to = kSrpcFd; /* Used to be set by -X. */
87 struct NaClApp *nap = &state; 94 struct NaClApp *nap = &state;
88 NaClErrorCode errcode = LOAD_INTERNAL; 95 NaClErrorCode errcode = LOAD_INTERNAL;
89 int ret_code = 1; 96 int ret_code = 1;
(...skipping 15 matching lines...) Expand all
105 /* to be passed to NaClMain, eventually... */ 112 /* to be passed to NaClMain, eventually... */
106 av[0] = "NaClMain"; 113 av[0] = "NaClMain";
107 114
108 if (!NaClAppCtor(&state)) { 115 if (!NaClAppCtor(&state)) {
109 fprintf(stderr, "Error while constructing app state\n"); 116 fprintf(stderr, "Error while constructing app state\n");
110 goto done_ctor; 117 goto done_ctor;
111 } 118 }
112 119
113 errcode = LOAD_OK; 120 errcode = LOAD_OK;
114 121
122 /* Inject the validation caching interface, if it exists. */
123 nap->validation_cache = g_validation_cache;
124
115 NaClAppInitialDescriptorHookup(nap); 125 NaClAppInitialDescriptorHookup(nap);
116 126
117 /* 127 /*
118 * NACL_SERVICE_PORT_DESCRIPTOR and NACL_SERVICE_ADDRESS_DESCRIPTOR 128 * NACL_SERVICE_PORT_DESCRIPTOR and NACL_SERVICE_ADDRESS_DESCRIPTOR
119 * are 3 and 4. 129 * are 3 and 4.
120 */ 130 */
121 131
122 /* import IMC handle - used to be "-i" */ 132 /* import IMC handle - used to be "-i" */
123 CHECK(handle_count == 3); 133 CHECK(handle_count == 3);
124 NaClAddImcHandle(nap, handles[0], export_addr_to); 134 NaClAddImcHandle(nap, handles[0], export_addr_to);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 if (LOAD_OK != errcode) { 306 if (LOAD_OK != errcode) {
297 NaClBlockIfCommandChannelExists(nap); 307 NaClBlockIfCommandChannelExists(nap);
298 } 308 }
299 309
300 done_ctor: 310 done_ctor:
301 311
302 NaClAllModulesFini(); 312 NaClAllModulesFini();
303 313
304 NaClExit(ret_code); 314 NaClExit(ret_code);
305 } 315 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698