| OLD | NEW |
| (Empty) | |
| 1 /* This is the universal C startup code (crt1.o) for NaCl applications. |
| 2 The initial stack and register state is arranged by the NaCl trusted |
| 3 runtime as for a normal C function call of one argument. */ |
| 4 |
| 5 #include <stdint.h> |
| 6 |
| 7 int main (int argc, char **argv, char **envp); |
| 8 |
| 9 int __libc_csu_init (int argc, char **argv, char **envp); |
| 10 void __libc_csu_fini (void); |
| 11 |
| 12 void __libc_start_main (int (*main) (int argc, char **argv, char **envp), |
| 13 int argc, char **argv, |
| 14 int (*init) (int argc, char **argv, char **envp), |
| 15 void (*fini) (void), |
| 16 void (*rtld_fini) (void), |
| 17 void *stack_end); |
| 18 |
| 19 /* This is the true entry point for untrusted code. |
| 20 It's called with the normal C ABI, taking one argument. |
| 21 This is a pointer to stack space containing these words: |
| 22 [0] cleanup function pointer (always NULL in actual startup) |
| 23 [1] envc, count of envp[] pointers |
| 24 [2] argc, count of argv[] pointers |
| 25 [3] argv[0..argc] pointers, argv[argc] being NULL |
| 26 [3+argc] envp[0..envc] pointers, envp[envc] being NULL |
| 27 [3+argc+envc] auxv[] pairs |
| 28 */ |
| 29 void |
| 30 _start (uint32_t *info) |
| 31 { |
| 32 void (*rtld_fini) (void) = (void (*) (void)) info[0]; |
| 33 int argc = info[2]; |
| 34 char **argv = (void *) &info[3]; |
| 35 |
| 36 /* The generic code actually assumes that envp follows argv |
| 37 and that auxv follows envp. */ |
| 38 |
| 39 __libc_start_main (&main, argc, argv, |
| 40 &__libc_csu_init, &__libc_csu_fini, rtld_fini, |
| 41 __builtin_frame_address (0)); |
| 42 |
| 43 /* That should not return. Make sure we crash if it did. */ |
| 44 while (1) *(volatile int *) 0; |
| 45 } |
| OLD | NEW |