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

Unified Diff: src/untrusted/irt/irt_entry.c

Issue 19571003: IRT: Replace __attribute__((constructor)) with explicit call in _start() (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Fix + cleanup Created 7 years, 5 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/irt/irt_core_entry.c ('k') | src/untrusted/irt/nacl.scons » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/untrusted/irt/irt_entry.c
diff --git a/src/untrusted/irt/irt_entry.c b/src/untrusted/irt/irt_entry.c
index 89f51f62377551280c778096a071cba461fc4150..686d40bfbc0a5dcf7580e2e3c106d7e381445d5d 100644
--- a/src/untrusted/irt/irt_entry.c
+++ b/src/untrusted/irt/irt_entry.c
@@ -9,6 +9,8 @@
#include "native_client/src/include/elf32.h"
#include "native_client/src/include/elf_auxv.h"
+#include "native_client/src/shared/platform/nacl_log.h"
+#include "native_client/src/shared/srpc/nacl_srpc.h"
#include "native_client/src/untrusted/irt/irt_interfaces.h"
#include "native_client/src/untrusted/nacl/nacl_irt.h"
#include "native_client/src/untrusted/nacl/nacl_startup.h"
@@ -17,6 +19,25 @@
void __libc_init_array(void);
/*
+ * This is declared as weak because plugin_main_nacl.cc on the
+ * Chromium side has a copy of IrtInit().
+ * TODO(mseaborn): Remove IrtInit() from there and use this copy.
+ */
+__attribute__((weak))
+int IrtInit(void) {
+ static int initialized = 0;
+ if (initialized) {
+ return 0;
+ }
+ if (!NaClSrpcModuleInit()) {
+ return 1;
+ }
+ NaClLogModuleInit(); /* Enable NaClLog'ing used by CHECK(). */
+ initialized = 1;
+ return 0;
+}
+
+/*
* This is the true entry point for untrusted code.
* See nacl_startup.h for the layout at the argument pointer.
*/
@@ -40,6 +61,12 @@ void _start(uint32_t *info) {
__libc_init_array();
+ if (IrtInit()) {
+ static const char fatal_msg[] = "IrtInit() failed\n";
+ write(2, fatal_msg, sizeof(fatal_msg) - 1);
+ _exit(-1);
+ }
+
Elf32_auxv_t *entry = NULL;
for (Elf32_auxv_t *av = auxv; av->a_type != AT_NULL; ++av) {
if (av->a_type == AT_ENTRY) {
« no previous file with comments | « src/untrusted/irt/irt_core_entry.c ('k') | src/untrusted/irt/nacl.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698