| OLD | NEW |
| (Empty) | |
| 1 /* |
| 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. |
| 5 */ |
| 6 |
| 7 #include <unistd.h> |
| 8 |
| 9 #include "native_client/src/include/elf32.h" |
| 10 #include "native_client/src/untrusted/nacl/nacl_irt.h" |
| 11 #include "native_client/src/untrusted/nacl/nacl_startup.h" |
| 12 |
| 13 |
| 14 void __libc_init_array(void); |
| 15 void __libc_fini_array(void); |
| 16 |
| 17 void __pthread_initialize(void); |
| 18 void __pthread_shutdown(void); |
| 19 |
| 20 int main(int argc, char **argv, char **envp); |
| 21 |
| 22 /* |
| 23 * This is the true entry point for untrusted code. |
| 24 * See nacl_startup.h for the layout at the argument pointer. |
| 25 */ |
| 26 void _start(uint32_t *info) { |
| 27 void (*fini)(void) = nacl_startup_fini(info); |
| 28 int argc = nacl_startup_argc(info); |
| 29 char **argv = nacl_startup_argv(info); |
| 30 char **envp = nacl_startup_envp(info); |
| 31 Elf32_auxv_t *auxv = nacl_startup_auxv(info); |
| 32 |
| 33 environ = envp; |
| 34 |
| 35 __libnacl_irt_init(auxv); |
| 36 |
| 37 /* |
| 38 * If we were started by a dynamic linker, then it passed its finalizer |
| 39 * function here. For static linking, this is always NULL. |
| 40 */ |
| 41 if (fini != NULL) |
| 42 atexit(fini); |
| 43 |
| 44 atexit(&__libc_fini_array); |
| 45 |
| 46 __pthread_initialize(); |
| 47 atexit(&__pthread_shutdown); |
| 48 |
| 49 __libc_init_array(); |
| 50 |
| 51 exit(main(argc, argv, envp)); |
| 52 |
| 53 /*NOTREACHED*/ |
| 54 while (1) *(volatile int *) 0; /* Crash. */ |
| 55 } |
| OLD | NEW |