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

Unified Diff: src/untrusted/pnacl_irt_shim/shim_entry.c

Issue 10870109: Change the pnacl shim from doing real shimming to just intercepting (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 4 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/pnacl_irt_shim/nacl.scons ('k') | src/untrusted/pnacl_irt_shim/shim_ppapi.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/untrusted/pnacl_irt_shim/shim_entry.c
===================================================================
--- src/untrusted/pnacl_irt_shim/shim_entry.c (revision 9574)
+++ src/untrusted/pnacl_irt_shim/shim_entry.c (working copy)
@@ -1,16 +1,45 @@
/*
- * Copyright (c) 2011 The Native Client Authors. All rights reserved.
+ * Copyright 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 <stddef.h>
#include "native_client/src/include/elf32.h"
#include "native_client/src/include/elf_auxv.h"
#include "native_client/src/include/nacl_macros.h"
-#include "native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.h"
+#include "native_client/src/untrusted/irt/irt.h"
+#include "native_client/src/untrusted/irt/irt_shim.h"
#include "native_client/src/untrusted/nacl/nacl_startup.h"
+/*
+ * For more information about this hack cf.
+ * src/untrusted/irt/irt_ppapi.c
+ */
+static TYPE_nacl_irt_query real_irt_interface;
+
+/* cf. src/untrusted/irt/irt.h NACL_IRT_PPAPIHOOK_(SHIMMED_)v0_1 */
+static const char prefix_search[] = "nacl-irt-ppapihook";
+static const char prefix_replace[] = "nacl-irt-ppapihook-shimmed";
+
+/* Do not make assumptions about strcmp being available. */
+static int my_strcmp(const char* s1, const char* s2) {
+ while (*s1 != '\0' && *s2 != '\0' && *s1 == *s2) {
+ s1++;
+ s2++;
+ }
+ return *s1 - *s2;
+}
+
+static size_t pnacl_irt_interface_interceptor(const char *interface_ident,
+ void *table, size_t tablesize) {
+ if (0 == my_strcmp(interface_ident, NACL_IRT_PPAPIHOOK_v0_1)) {
+ return real_irt_interface(NACL_IRT_PPAPIHOOK_SHIMMED_v0_1, table, tablesize);
+ }
+ return real_irt_interface(ident, table, tablesize);
+}
+
/*
* This is the true entry point for untrusted code.
* See nacl_startup.h for the layout at the argument pointer.
@@ -30,13 +59,13 @@
/*
* Save the real irt interface.
*/
- __pnacl_real_irt_interface = (TYPE_nacl_irt_query) entry->a_un.a_val;
+ real_irt_interface = (TYPE_nacl_irt_query) entry->a_un.a_val;
/*
* Overwrite the auxv slot with the pnacl IRT shim query function.
*/
entry->a_type = AT_SYSINFO;
- entry->a_un.a_val = (uintptr_t) __pnacl_irt_interface_wrapper;
+ entry->a_un.a_val = (uintptr_t) pnacl_irt_interface_interceptor;
}
/* If entry is NULL still allow startup to continue. It may be the case
« no previous file with comments | « src/untrusted/pnacl_irt_shim/nacl.scons ('k') | src/untrusted/pnacl_irt_shim/shim_ppapi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698