| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include <unistd.h> | 7 #include <unistd.h> |
| 8 | 8 |
| 9 #include "native_client/src/include/elf32.h" | 9 #include "native_client/src/include/elf32.h" |
| 10 #include "native_client/src/untrusted/irt/irt_module.h" |
| 10 #include "native_client/src/untrusted/nacl/nacl_irt.h" | 11 #include "native_client/src/untrusted/nacl/nacl_irt.h" |
| 11 #include "native_client/src/untrusted/nacl/nacl_startup.h" | 12 #include "native_client/src/untrusted/nacl/nacl_startup.h" |
| 12 #include "native_client/src/untrusted/nacl/start.h" | 13 #include "native_client/src/untrusted/nacl/start.h" |
| 13 #include "native_client/src/untrusted/nacl/tls.h" | 14 #include "native_client/src/untrusted/nacl/tls.h" |
| 14 | 15 |
| 15 | 16 |
| 16 void __libc_init_array(void); | 17 void __libc_init_array(void); |
| 17 void __libc_fini_array(void); | 18 void __libc_fini_array(void); |
| 18 | 19 |
| 19 /* | 20 /* |
| (...skipping 19 matching lines...) Expand all Loading... |
| 39 | 40 |
| 40 environ = envp; | 41 environ = envp; |
| 41 | 42 |
| 42 /* | 43 /* |
| 43 * Record the approximate address from which the stack grows | 44 * Record the approximate address from which the stack grows |
| 44 * (usually downwards) so that libpthread can report it. Taking the | 45 * (usually downwards) so that libpthread can report it. Taking the |
| 45 * address of any stack-allocated variable will work here. | 46 * address of any stack-allocated variable will work here. |
| 46 */ | 47 */ |
| 47 __nacl_initial_thread_stack_end = &info; | 48 __nacl_initial_thread_stack_end = &info; |
| 48 | 49 |
| 49 __libnacl_irt_init(auxv); | 50 __libnacl_irt_init(argc, argv, auxv); |
| 50 | 51 |
| 51 /* | 52 /* |
| 52 * If we were started by a dynamic linker, then it passed its finalizer | 53 * If we were started by a dynamic linker, then it passed its finalizer |
| 53 * function here. For static linking, this is always NULL. | 54 * function here. For static linking, this is always NULL. |
| 54 */ | 55 */ |
| 55 if (fini != NULL) | 56 if (fini != NULL) |
| 56 atexit(fini); | 57 atexit(fini); |
| 57 | 58 |
| 58 atexit(&__libc_fini_array); | 59 atexit(&__libc_fini_array); |
| 59 | 60 |
| 60 __pthread_initialize(); | 61 __pthread_initialize(); |
| 61 | 62 |
| 62 __libc_init_array(); | 63 __libc_init_array(); |
| 63 | 64 |
| 65 /* |
| 66 { |
| 67 struct nacl_irt *irt = nacl_irt_new(NULL, __nacl_irt_query, NULL); |
| 68 if (irt != NULL) { |
| 69 nacl_irt_layer_init(irt->layer); |
| 70 } |
| 71 } |
| 72 */ |
| 73 |
| 64 int (*main_ptr)(int argc, char **argv, char **envp) = &__nacl_main; | 74 int (*main_ptr)(int argc, char **argv, char **envp) = &__nacl_main; |
| 65 if (main_ptr == NULL) | 75 if (main_ptr == NULL) |
| 66 main_ptr = &main; | 76 main_ptr = &main; |
| 67 | 77 |
| 68 exit(main_ptr(argc, argv, envp)); | 78 exit(main_ptr(argc, argv, envp)); |
| 69 | 79 |
| 70 /*NOTREACHED*/ | 80 /*NOTREACHED*/ |
| 71 while (1) *(volatile int *) 0; /* Crash. */ | 81 while (1) *(volatile int *) 0; /* Crash. */ |
| 72 } | 82 } |
| OLD | NEW |