| 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 * The ABI uses a null frame pointer to say when to stop backtracing. | |
| 54 * In x86-64 case we don't need this because RBP handling is special | |
| 55 * and so loader will load proper value in RBP. | |
| 56 */ | |
| 57 | |
| 58 xorl %ebp, %ebp | |
| 59 | |
| 60 /* | |
| 61 * Because we are going to align the stack 0mod16 for SSE2, | |
| 62 * We need to gather the argc, argv, and envp pointers before | |
| 63 * moving esp. | |
| 64 */ | |
| 65 popl %esi /* Remove argc from the top of the stack */ | |
| 66 movl %esp, %ecx /* Save the argv pointer */ | |
| 67 | |
| 68 /* | |
| 69 * Finding envp requires skipping over argc+1 words. | |
| 70 */ | |
| 71 leal 4(%esp, %esi, 4), %ebx | |
| 72 | |
| 73 /* | |
| 74 * Align the stack 0mod16, for SSE2 | |
| 75 */ | |
| 76 andl $0xfffffff0, %esp | |
| 77 | |
| 78 /* | |
| 79 * Push the arguments to main. | |
| 80 */ | |
| 81 pushl %ebp /* Padding to maintain 0mod16 alignment */ | |
| 82 pushl %ebx /* Push envp onto the stack */ | |
| 83 pushl %ecx /* Push argv onto the stack */ | |
| 84 pushl %esi /* Push argc back onto the stack */ | |
| 85 | |
| 86 naclcall __nacl_startup | |
| 87 | |
| 88 halt_loop: | |
| 89 hlt | |
| 90 jmp halt_loop | |
| 91 .p2align 5 | |
| 92 | |
| OLD | NEW |