| Index: src/untrusted/nacl/nacl_irt.c
|
| diff --git a/src/untrusted/nacl/nacl_irt.c b/src/untrusted/nacl/nacl_irt.c
|
| index 888f38d6b32ea3ce804ec46c7e43b961245e0ea9..3202f1009252dac7e21a1a4909bdbadf38fe6209 100644
|
| --- a/src/untrusted/nacl/nacl_irt.c
|
| +++ b/src/untrusted/nacl/nacl_irt.c
|
| @@ -7,6 +7,9 @@
|
| #include <string.h>
|
| #include <unistd.h>
|
|
|
| +#include "native_client/src/include/elf_auxv.h"
|
| +#include "native_client/src/include/elf32.h"
|
| +#include "native_client/src/include/nacl_macros.h"
|
| #include "native_client/src/untrusted/irt/irt_interfaces.h"
|
| #include "native_client/src/untrusted/nacl/nacl_irt.h"
|
|
|
| @@ -43,6 +46,7 @@ static int stub_getdents(int fd, struct dirent *dirent, size_t count,
|
| return ENOSYS;
|
| }
|
|
|
| +struct nacl_irt_instance __libnacl_irt_instance;
|
| struct nacl_irt_basic __libnacl_irt_basic;
|
| struct nacl_irt_memory __libnacl_irt_memory;
|
| struct nacl_irt_tls __libnacl_irt_tls;
|
| @@ -65,6 +69,43 @@ struct nacl_irt_fdio __libnacl_irt_fdio = {
|
|
|
| TYPE_nacl_irt_query __nacl_irt_query;
|
|
|
| +struct nacl_interface_table {
|
| + const char *name;
|
| + void *table;
|
| + size_t size;
|
| +};
|
| +
|
| +static const struct nacl_interface_table irt_interfaces[] = {
|
| + { NACL_IRT_INSTANCE_v0_1, &__libnacl_irt_instance, sizeof(__libnacl_irt_instance) },
|
| + { NACL_IRT_BASIC_v0_1, &__libnacl_irt_basic, sizeof(__libnacl_irt_basic) },
|
| + { NACL_IRT_DEV_FDIO_v0_1, &__libnacl_irt_fdio, sizeof(__libnacl_irt_fdio) },
|
| + { NACL_IRT_FILENAME_v0_1, &__libnacl_irt_dev_filename, sizeof(struct nacl_irt_filename) },
|
| + { NACL_IRT_DEV_FILENAME_v0_2, &__libnacl_irt_dev_filename, sizeof(__libnacl_irt_dev_filename) },
|
| + { NACL_IRT_MEMORY_v0_1, &__libnacl_irt_memory, sizeof(struct nacl_irt_memory_v0_1) },
|
| + { NACL_IRT_MEMORY_v0_2, &__libnacl_irt_memory, sizeof(struct nacl_irt_memory_v0_2) },
|
| + { NACL_IRT_MEMORY_v0_3, &__libnacl_irt_memory, sizeof(struct nacl_irt_memory) },
|
| + { NACL_IRT_TLS_v0_1, &__libnacl_irt_tls, sizeof(__libnacl_irt_tls) },
|
| + { NACL_IRT_CLOCK_v0_1, &__libnacl_irt_clock, sizeof(__libnacl_irt_clock) },
|
| + { NACL_IRT_DEV_GETPID_v0_1, &__libnacl_irt_dev_getpid,
|
| + sizeof(__libnacl_irt_dev_getpid) },
|
| +};
|
| +
|
| +int nacl_irt_interface_set(const char *interface_ident,
|
| + void *table, size_t tablesize, void *old_table) {
|
| + int i;
|
| + for (i = 0; i < NACL_ARRAY_SIZE(irt_interfaces); ++i) {
|
| + if (0 == strcmp(interface_ident, irt_interfaces[i].name)) {
|
| + const size_t size = irt_interfaces[i].size;
|
| + if (size <= tablesize) {
|
| + memcpy(old_table, irt_interfaces[i].table, size);
|
| + memcpy(irt_interfaces[i].table, table, size);
|
| + return size;
|
| + }
|
| + break;
|
| + }
|
| + }
|
| + return 0;
|
| +}
|
|
|
| /*
|
| * Avoid a dependency on libc's strlen function.
|
| @@ -106,7 +147,6 @@ static void __libnacl_fatal(const char* message) {
|
|
|
| }
|
|
|
| -
|
| int __libnacl_irt_query(const char *interface,
|
| void *table, size_t table_size) {
|
| if (NULL == __nacl_irt_query) {
|
| @@ -125,9 +165,6 @@ void __libnacl_mandatory_irt_query(const char *interface,
|
| }
|
| }
|
|
|
| -/*
|
| - * Used to lazily initialize an IRT interface function.
|
| - */
|
| int __libnacl_irt_init_fn(void *interface_field, void (*init)(void)) {
|
| if (*((void **) interface_field) == NULL) {
|
| init();
|
|
|