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

Unified Diff: src/trusted/service_runtime/sel_main_chrome.c

Issue 153453002: Expose NaClAppSetDesc() to Chromium for use at startup (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Rebase and fix Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/trusted/service_runtime/sel_ldr.c ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/service_runtime/sel_main_chrome.c
diff --git a/src/trusted/service_runtime/sel_main_chrome.c b/src/trusted/service_runtime/sel_main_chrome.c
index 7baf924bc21f42464009afdd481be79a3ada6ac2..9f5eb6b98ea985d74e4ada1e86cf23bad859a306 100644
--- a/src/trusted/service_runtime/sel_main_chrome.c
+++ b/src/trusted/service_runtime/sel_main_chrome.c
@@ -18,6 +18,7 @@
#include <string.h>
#include "native_client/src/include/nacl_macros.h"
+#include "native_client/src/public/nacl_app.h"
#include "native_client/src/shared/platform/nacl_check.h"
#include "native_client/src/shared/platform/nacl_exit.h"
#include "native_client/src/shared/platform/nacl_log.h"
@@ -43,6 +44,20 @@
#include "native_client/src/trusted/service_runtime/win/exception_patch/ntdll_patch.h"
#include "native_client/src/trusted/validator/validation_metadata.h"
+static int g_initialized = 0;
+
+#if NACL_LINUX || NACL_OSX
+void NaClChromeMainSetUrandomFd(int urandom_fd) {
+ NaClSecureRngModuleSetUrandomFd(urandom_fd);
+}
+#endif
+
+void NaClChromeMainInit(void) {
+ CHECK(!g_initialized);
+ NaClAllModulesInit();
+ g_initialized = 1;
+}
+
struct NaClChromeMainArgs *NaClChromeMainArgsCreate(void) {
struct NaClChromeMainArgs *args = malloc(sizeof(*args));
if (args == NULL)
@@ -73,8 +88,11 @@ struct NaClChromeMainArgs *NaClChromeMainArgsCreate(void) {
/*
* Initialize NaClLog so that Chromium can call
- * NaClDescMakeCustomDesc() between calling
- * NaClChromeMainArgsCreate() and NaClChromeMainStart().
+ * NaClDescMakeCustomDesc(), before NaClAllModulesInit() gets
+ * called.
+ *
+ * TODO(mseaborn): Remove this once Chromium calls
+ * NaClChromeMainInit() before NaClChromeMainArgsCreate().
*/
NaClLogModuleInit();
@@ -124,12 +142,11 @@ static void NaClLoadIrt(struct NaClApp *nap, int irt_fd) {
NaClDescUnref(nd);
}
-void NaClChromeMainStart(struct NaClChromeMainArgs *args) {
+void NaClChromeMainStartApp(struct NaClApp *nap,
+ struct NaClChromeMainArgs *args) {
char *av[1];
int ac = 1;
const char **envp;
- struct NaClApp state;
- struct NaClApp *nap = &state;
NaClErrorCode errcode = LOAD_INTERNAL;
int ret_code = 1;
struct NaClEnvCleanser env_cleanser;
@@ -150,24 +167,18 @@ void NaClChromeMainStart(struct NaClChromeMainArgs *args) {
if (args->urandom_fd != -1)
NaClSecureRngModuleSetUrandomFd(args->urandom_fd);
#endif
+ /* TODO(mseaborn): Remove this when NaClChromeMainStart() is removed. */
+ if (nap == NULL) {
+ NaClChromeMainInit();
+ nap = NaClAppCreate();
+ }
- /*
- * Clear state so that NaClBootstrapChannelErrorReporter will be
- * able to know if the bootstrap channel is available or not.
- */
- memset(&state, 0, sizeof state);
- NaClAllModulesInit();
NaClBootstrapChannelErrorReporterInit();
- NaClErrorLogHookInit(NaClBootstrapChannelErrorReporter, &state);
+ NaClErrorLogHookInit(NaClBootstrapChannelErrorReporter, nap);
/* to be passed to NaClMain, eventually... */
av[0] = "NaClMain";
- if (NACL_FI_ERROR_COND("AppCtor", !NaClAppCtor(&state))) {
- NaClLog(LOG_FATAL, "Error while constructing app state\n");
- goto done;
- }
-
errcode = LOAD_OK;
/* Allow or disallow dyncode API based on args. */
@@ -269,7 +280,7 @@ void NaClChromeMainStart(struct NaClChromeMainArgs *args) {
#endif
/* Give debuggers a well known point at which xlate_base is known. */
- NaClGdbHook(&state);
+ NaClGdbHook(nap);
NaClCreateServiceSocket(nap);
/*
@@ -406,3 +417,7 @@ void NaClChromeMainStart(struct NaClChromeMainArgs *args) {
NaClExit(ret_code);
}
+
+void NaClChromeMainStart(struct NaClChromeMainArgs *args) {
+ NaClChromeMainStartApp(NULL, args);
+}
« no previous file with comments | « src/trusted/service_runtime/sel_ldr.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698