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/nacl/nacl_irt.h" | 10 #include "native_client/src/untrusted/nacl/nacl_irt.h" |
11 #include "native_client/src/untrusted/nacl/nacl_startup.h" | 11 #include "native_client/src/untrusted/nacl/nacl_startup.h" |
12 #include "native_client/src/untrusted/nacl/start.h" | 12 #include "native_client/src/untrusted/nacl/start.h" |
13 #include "native_client/src/untrusted/nacl/tls.h" | 13 #include "native_client/src/untrusted/nacl/tls.h" |
14 | 14 |
15 | 15 |
16 void __libc_init_array(void); | 16 void __libc_init_array(void); |
17 void __libc_fini_array(void); | 17 void __libc_fini_array(void); |
18 | 18 |
19 /* | 19 /* |
20 * Alternative NaCl main entry point. If this symbol name is found at | 20 * Alternative NaCl main entry point. If this symbol name is found at |
21 * link time it is used in favour of 'main' as the program entry point. | 21 * link time it is used in favour of 'main' as the program entry point. |
22 */ | 22 */ |
23 int __nacl_main(int argc, char **argv, char **envp) __attribute__((weak)); | 23 int __nacl_main(int argc, char **argv, char **envp) __attribute__((weak)); |
24 | 24 |
25 int main(int argc, char **argv, char **envp); | |
26 | |
27 void *__nacl_initial_thread_stack_end; | 25 void *__nacl_initial_thread_stack_end; |
28 | 26 |
29 /* | 27 /* |
30 * This is the true entry point for untrusted code. | 28 * This is the true entry point for untrusted code. |
31 * See nacl_startup.h for the layout at the argument pointer. | 29 * See nacl_startup.h for the layout at the argument pointer. |
32 */ | 30 */ |
33 void _start(uint32_t *info) { | 31 void _start(uint32_t *info) { |
34 void (*fini)(void) = nacl_startup_fini(info); | 32 void (*fini)(void) = nacl_startup_fini(info); |
35 int argc = nacl_startup_argc(info); | 33 int argc = nacl_startup_argc(info); |
36 char **argv = nacl_startup_argv(info); | 34 char **argv = nacl_startup_argv(info); |
(...skipping 26 matching lines...) Expand all Loading... |
63 | 61 |
64 int (*main_ptr)(int argc, char **argv, char **envp) = &__nacl_main; | 62 int (*main_ptr)(int argc, char **argv, char **envp) = &__nacl_main; |
65 if (main_ptr == NULL) | 63 if (main_ptr == NULL) |
66 main_ptr = &main; | 64 main_ptr = &main; |
67 | 65 |
68 exit(main_ptr(argc, argv, envp)); | 66 exit(main_ptr(argc, argv, envp)); |
69 | 67 |
70 /*NOTREACHED*/ | 68 /*NOTREACHED*/ |
71 __builtin_trap(); | 69 __builtin_trap(); |
72 } | 70 } |
OLD | NEW |