OLD | NEW |
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 Loading... |
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 Loading... |
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; |
| 78 static void *g_validation_cache_context = NULL; |
| 79 |
| 80 /* TODO(ncbray) consolidate Chrome's sel_ldr setup to a single function. */ |
| 81 void NaClSetValidationCache(NaClValidationCache *cache, void *cache_context) { |
| 82 g_validation_cache = cache; |
| 83 g_validation_cache_context = cache_context; |
| 84 } |
| 85 |
76 void NaClMainForChromium(int handle_count, const NaClHandle *handles, | 86 void NaClMainForChromium(int handle_count, const NaClHandle *handles, |
77 int debug) { | 87 int debug) { |
78 char *av[1]; | 88 char *av[1]; |
79 int ac = 1; | 89 int ac = 1; |
80 const char **envp; | 90 const char **envp; |
81 struct NaClApp state; | 91 struct NaClApp state; |
82 int export_addr_to = (int) handles[0]; /* Used to be set by -X. */ | 92 int export_addr_to = (int) handles[0]; /* Used to be set by -X. */ |
83 struct NaClApp *nap = &state; | 93 struct NaClApp *nap = &state; |
84 NaClErrorCode errcode = LOAD_INTERNAL; | 94 NaClErrorCode errcode = LOAD_INTERNAL; |
85 int ret_code = 1; | 95 int ret_code = 1; |
(...skipping 15 matching lines...) Expand all Loading... |
101 /* to be passed to NaClMain, eventually... */ | 111 /* to be passed to NaClMain, eventually... */ |
102 av[0] = "NaClMain"; | 112 av[0] = "NaClMain"; |
103 | 113 |
104 if (!NaClAppCtor(&state)) { | 114 if (!NaClAppCtor(&state)) { |
105 fprintf(stderr, "Error while constructing app state\n"); | 115 fprintf(stderr, "Error while constructing app state\n"); |
106 goto done_ctor; | 116 goto done_ctor; |
107 } | 117 } |
108 | 118 |
109 errcode = LOAD_OK; | 119 errcode = LOAD_OK; |
110 | 120 |
| 121 /* Inject the validation caching interface, if it exists. */ |
| 122 nap->validation_cache = g_validation_cache; |
| 123 nap->validation_cache_context = g_validation_cache_context; |
| 124 |
111 NaClAppInitialDescriptorHookup(nap); | 125 NaClAppInitialDescriptorHookup(nap); |
112 | 126 |
113 /* | 127 /* |
114 * NACL_SERVICE_PORT_DESCRIPTOR and NACL_SERVICE_ADDRESS_DESCRIPTOR | 128 * NACL_SERVICE_PORT_DESCRIPTOR and NACL_SERVICE_ADDRESS_DESCRIPTOR |
115 * are 3 and 4. | 129 * are 3 and 4. |
116 */ | 130 */ |
117 | 131 |
118 /* import IMC handle - used to be "-i" */ | 132 /* import IMC handle - used to be "-i" */ |
119 CHECK(handle_count == 1); | 133 CHECK(handle_count == 1); |
120 NaClAddImcHandle(nap, handles[0], export_addr_to); | 134 NaClAddImcHandle(nap, handles[0], export_addr_to); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 if (LOAD_OK != errcode) { | 304 if (LOAD_OK != errcode) { |
291 NaClBlockIfCommandChannelExists(nap); | 305 NaClBlockIfCommandChannelExists(nap); |
292 } | 306 } |
293 | 307 |
294 done_ctor: | 308 done_ctor: |
295 | 309 |
296 NaClAllModulesFini(); | 310 NaClAllModulesFini(); |
297 | 311 |
298 NaClExit(ret_code); | 312 NaClExit(ret_code); |
299 } | 313 } |
OLD | NEW |