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

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

Powered by Google App Engine
This is Rietveld 408576698