Commit | Line | Data |
---|---|---|
241e64e3 L |
1 | .text |
2 | .globl _start | |
3 | .type _start,@function | |
4 | .p2align 4 | |
5 | _start: | |
6 | xorl %ebp, %ebp | |
7 | #ifdef __LP64__ | |
8 | popq %rdi | |
9 | movq %rsp, %rsi | |
10 | andq $~15, %rsp | |
11 | #elif defined __x86_64__ | |
12 | mov (%rsp),%edi | |
13 | addl $4,%esp | |
14 | movl %esp, %esi | |
15 | andl $~15, %esp | |
16 | #else | |
17 | popl %esi | |
18 | movl %esp, %ecx | |
19 | andl $~15, %esp | |
20 | ||
21 | subl $8,%esp | |
22 | pushl %ecx | |
23 | pushl %esi | |
24 | #endif | |
25 | ||
26 | call main | |
27 | ||
28 | hlt | |
29 | ||
30 | .type syscall, @function | |
31 | .globl syscall | |
32 | .p2align 4 | |
33 | syscall: | |
34 | #ifdef __x86_64__ | |
35 | movq %rdi, %rax /* Syscall number -> rax. */ | |
36 | movq %rsi, %rdi /* shift arg1 - arg5. */ | |
37 | movq %rdx, %rsi | |
38 | movq %rcx, %rdx | |
39 | movq %r8, %r10 | |
40 | movq %r9, %r8 | |
41 | movq 8(%rsp),%r9 /* arg6 is on the stack. */ | |
42 | syscall /* Do the system call. */ | |
43 | #else | |
44 | push %ebp | |
45 | push %edi | |
46 | push %esi | |
47 | push %ebx | |
48 | mov 0x2c(%esp),%ebp | |
49 | mov 0x28(%esp),%edi | |
50 | mov 0x24(%esp),%esi | |
51 | mov 0x20(%esp),%edx | |
52 | mov 0x1c(%esp),%ecx | |
53 | mov 0x18(%esp),%ebx | |
54 | mov 0x14(%esp),%eax | |
55 | int $0x80 | |
56 | pop %ebx | |
57 | pop %esi | |
58 | pop %edi | |
59 | pop %ebp | |
60 | #endif | |
61 | ret /* Return to caller. */ | |
62 | .size syscall, .-syscall | |
63 | .section .note.GNU-stack,"",@progbits | |
ab9e3428 L |
64 | |
65 | .section ".note.gnu.property", "a" | |
66 | #ifdef __LP64__ | |
67 | .p2align 3 | |
68 | #else | |
69 | .p2align 2 | |
70 | #endif | |
71 | .long 1f - 0f /* name length */ | |
72 | .long 5f - 2f /* data length */ | |
73 | .long 5 /* note type */ | |
74 | 0: .asciz "GNU" /* vendor name */ | |
75 | 1: | |
76 | #ifdef __LP64__ | |
77 | .p2align 3 | |
78 | #else | |
79 | .p2align 2 | |
80 | #endif | |
81 | 2: .long 0xc0000002 /* pr_type. */ | |
82 | .long 4f - 3f /* pr_datasz. */ | |
83 | 3: | |
84 | .long 0x2 | |
85 | 4: | |
86 | #ifdef __LP64__ | |
87 | .p2align 3 | |
88 | #else | |
89 | .p2align 2 | |
90 | #endif | |
91 | 5: |