| 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
|
|
|