| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2010 The Native Client Authors. All rights reserved. | |
| 3 * Use of this source code is governed by a BSD-style license that can | |
| 4 * be found in the LICENSE file. | |
| 5 */ | |
| 6 | |
| 7 /* Native Client crt0 startup code for x86-64*/ | |
| 8 | |
| 9 .text | |
| 10 .p2align NACLENTRYALIGN,0xf4 | |
| 11 | |
| 12 .global _start | |
| 13 _start: | |
| 14 /* | |
| 15 * The i386 ELF ABI specifies that on entry the stack looks like: | |
| 16 * -------------------------------- | |
| 17 * | Unspecified | | |
| 18 * -------------------------------- | |
| 19 * | Information block, including | | |
| 20 * | argument strings, | | |
| 21 * | environment strings, | | |
| 22 * | auxiliary information | | |
| 23 * | ... | | |
| 24 * | (size varies) | | |
| 25 * -------------------------------- | |
| 26 * | Unspecified | | |
| 27 * -------------------------------- | |
| 28 * | Null auxiliary vector entry | | |
| 29 * -------------------------------- | |
| 30 * | Auxiliary vector | | |
| 31 * | ... | | |
| 32 * | (2-word entries) | | |
| 33 * -------------------------------- | |
| 34 * | 0 word | | |
| 35 * -------------------------------- | |
| 36 * | Environment pointers | | |
| 37 * | ... | | |
| 38 * | (one word each) | | |
| 39 * -------------------------------- | |
| 40 * | Argument pointers | | |
| 41 * | ... | | |
| 42 * 4(%esp) | (Argument count words) | | |
| 43 * -------------------------------- | |
| 44 * 0(%esp) | Argument count | | |
| 45 * -------------------------------- | |
| 46 * | Undefined | | |
| 47 * -------------------------------- | |
| 48 * TODO(sehr): fix stack alignments of atexit, _init, _fini, and | |
| 49 * exit. | |
| 50 */ | |
| 51 | |
| 52 /* | |
| 53 * Because we are going to align the stack 0mod16 for SSE2, | |
| 54 * We need to gather the argc, argv, and envp pointers before | |
| 55 * moving esp. | |
| 56 */ | |
| 57 popq %rsi /* Remove argc from the top of the stack */ | |
| 58 movq %rsp, %rcx /* Save the argv pointer */ | |
| 59 | |
| 60 /* | |
| 61 * Finding envp requires skipping over argc+1 words. | |
| 62 */ | |
| 63 | |
| 64 /* NOTE(khim): we are using ILP32 model in x86-64 mode! */ | |
| 65 leal 4(%rsp, %rsi, 4), %ebx | |
| 66 | |
| 67 /* | |
| 68 * Align the stack 0mod16, for SSE2 | |
| 69 */ | |
| 70 andq $0xfffffffffffffff0, %rsp | |
| 71 | |
| 72 /* | |
| 73 *Save the arguments in spare registers. | |
| 74 */ | |
| 75 movq %rsi, %rdi | |
| 76 movq %rcx, %rsi | |
| 77 movl %ebx, %edx | |
| 78 naclcall __nacl_startup | |
| 79 | |
| 80 halt_loop: | |
| 81 hlt | |
| 82 jmp halt_loop | |
| 83 .p2align 5 | |
| 84 | |
| OLD | NEW |