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

Unified Diff: src/untrusted/nacl/start.c

Issue 7276050: Change startup ABI for untrusted code to be C-compatible (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: disable bogus stack_frame.cc test for now Created 9 years, 6 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/untrusted/nacl/pthread_initialize_minimal.c ('k') | src/untrusted/stubs/crt1.x » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/untrusted/nacl/start.c
diff --git a/src/untrusted/nacl/start.c b/src/untrusted/nacl/start.c
new file mode 100644
index 0000000000000000000000000000000000000000..1d8fef980161653355949c1515572f3f50c0e82a
--- /dev/null
+++ b/src/untrusted/nacl/start.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 The Native Client Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <unistd.h>
+
+#include "native_client/src/include/elf32.h"
+#include "native_client/src/untrusted/nacl/nacl_irt.h"
+#include "native_client/src/untrusted/nacl/nacl_startup.h"
+
+
+void __libc_init_array(void);
+void __libc_fini_array(void);
+
+void __pthread_initialize(void);
+void __pthread_shutdown(void);
+
+int main(int argc, char **argv, char **envp);
+
+/*
+ * This is the true entry point for untrusted code.
+ * See nacl_startup.h for the layout at the argument pointer.
+ */
+void _start(uint32_t *info) {
+ void (*fini)(void) = nacl_startup_fini(info);
+ int argc = nacl_startup_argc(info);
+ char **argv = nacl_startup_argv(info);
+ char **envp = nacl_startup_envp(info);
+ Elf32_auxv_t *auxv = nacl_startup_auxv(info);
+
+ environ = envp;
+
+ __libnacl_irt_init(auxv);
+
+ /*
+ * If we were started by a dynamic linker, then it passed its finalizer
+ * function here. For static linking, this is always NULL.
+ */
+ if (fini != NULL)
+ atexit(fini);
+
+ atexit(&__libc_fini_array);
+
+ __pthread_initialize();
+ atexit(&__pthread_shutdown);
+
+ __libc_init_array();
+
+ exit(main(argc, argv, envp));
+
+ /*NOTREACHED*/
+ while (1) *(volatile int *) 0; /* Crash. */
+}
« no previous file with comments | « src/untrusted/nacl/pthread_initialize_minimal.c ('k') | src/untrusted/stubs/crt1.x » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698