]>
Commit | Line | Data |
---|---|---|
d4697bc9 | 1 | /* Copyright (C) 1995-2014 Free Software Foundation, Inc. |
d587d83b UD |
2 | This file is part of the GNU C Library. |
3 | ||
4 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
d587d83b UD |
8 | |
9 | The GNU C Library is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
d587d83b | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
15 | License along with the GNU C Library; if not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
d587d83b UD |
17 | |
18 | #include <sysdep.h> | |
19 | ||
6ddd37a4 | 20 | #include <kernel-features.h> |
d587d83b UD |
21 | |
22 | #define EINVAL 22 | |
af1680f1 | 23 | #define ENOSYS 38 |
f1d8b804 | 24 | |
9e25f6e2 | 25 | #define SVRSP 16 /* saved register space */ |
2366713d | 26 | #define PARMS 4+SVRSP /* space for 4 saved regs */ |
9e25f6e2 | 27 | #define ADDR PARMS |
2366713d | 28 | #define LEN ADDR+4 |
9e25f6e2 GM |
29 | #define PROT LEN+4 |
30 | #define FLAGS PROT+4 | |
31 | #define FD FLAGS+4 | |
32 | #define OFFLO FD+4 | |
33 | #define OFFHI OFFLO+4 | |
d587d83b | 34 | |
9e25f6e2 | 35 | .text |
2366713d | 36 | ENTRY (__mmap64) |
d587d83b | 37 | |
d587d83b UD |
38 | /* Save registers. */ |
39 | pushl %ebp | |
1ad9da69 | 40 | cfi_adjust_cfa_offset (4) |
d587d83b | 41 | pushl %ebx |
1ad9da69 | 42 | cfi_adjust_cfa_offset (4) |
d587d83b | 43 | pushl %esi |
1ad9da69 | 44 | cfi_adjust_cfa_offset (4) |
d587d83b | 45 | pushl %edi |
1ad9da69 | 46 | cfi_adjust_cfa_offset (4) |
d587d83b | 47 | |
9e25f6e2 GM |
48 | movl OFFLO(%esp), %edx |
49 | movl OFFHI(%esp), %ecx | |
b0af120f | 50 | testl $0xfff, %edx |
29b3c4f2 | 51 | jne L(einval) |
af1680f1 | 52 | shrdl $12, %ecx, %edx /* mmap2 takes the offset in pages. */ |
d587d83b UD |
53 | shrl $12, %ecx |
54 | jne L(einval) | |
af1680f1 | 55 | movl %edx, %ebp |
1ad9da69 | 56 | cfi_rel_offset (ebp, 12) |
d587d83b | 57 | |
9e25f6e2 | 58 | movl ADDR(%esp), %ebx |
1ad9da69 | 59 | cfi_rel_offset (ebx, 8) |
9e25f6e2 GM |
60 | movl LEN(%esp), %ecx |
61 | movl PROT(%esp), %edx | |
62 | movl FLAGS(%esp), %esi | |
1ad9da69 | 63 | cfi_rel_offset (esi, 4) |
9e25f6e2 | 64 | movl FD(%esp), %edi |
1ad9da69 | 65 | cfi_rel_offset (edi, 0) |
d587d83b | 66 | |
29b3c4f2 UD |
67 | movl $SYS_ify(mmap2), %eax /* System call number in %eax. */ |
68 | ||
d587d83b | 69 | /* Do the system call trap. */ |
f1d8b804 | 70 | L(do_syscall): |
f051627f | 71 | ENTER_KERNEL |
d587d83b | 72 | |
d587d83b UD |
73 | /* Restore registers. */ |
74 | popl %edi | |
1ad9da69 UD |
75 | cfi_adjust_cfa_offset (-4) |
76 | cfi_restore (edi) | |
d587d83b | 77 | popl %esi |
1ad9da69 UD |
78 | cfi_adjust_cfa_offset (-4) |
79 | cfi_restore (esi) | |
d587d83b | 80 | popl %ebx |
1ad9da69 UD |
81 | cfi_adjust_cfa_offset (-4) |
82 | cfi_restore (ebx) | |
d587d83b | 83 | popl %ebp |
1ad9da69 UD |
84 | cfi_adjust_cfa_offset (-4) |
85 | cfi_restore (ebp) | |
d587d83b | 86 | |
56b6e214 UD |
87 | /* If 0 > %eax > -4096 there was an error. */ |
88 | cmpl $-4096, %eax | |
89 | ja SYSCALL_ERROR_LABEL | |
90 | ||
d587d83b | 91 | /* Successful; return the syscall's value. */ |
d587d83b UD |
92 | ret |
93 | ||
1ad9da69 UD |
94 | cfi_adjust_cfa_offset (16) |
95 | cfi_rel_offset (ebp, 12) | |
96 | cfi_rel_offset (ebx, 8) | |
97 | cfi_rel_offset (esi, 4) | |
98 | cfi_rel_offset (edi, 0) | |
d587d83b UD |
99 | /* This means the offset value is too large. */ |
100 | L(einval): | |
101 | popl %edi | |
1ad9da69 UD |
102 | cfi_adjust_cfa_offset (-4) |
103 | cfi_restore (edi) | |
d587d83b | 104 | popl %esi |
1ad9da69 UD |
105 | cfi_adjust_cfa_offset (-4) |
106 | cfi_restore (esi) | |
d587d83b | 107 | popl %ebx |
1ad9da69 UD |
108 | cfi_adjust_cfa_offset (-4) |
109 | cfi_restore (ebx) | |
d587d83b | 110 | popl %ebp |
1ad9da69 UD |
111 | cfi_adjust_cfa_offset (-4) |
112 | cfi_restore (ebp) | |
d587d83b UD |
113 | movl $-EINVAL, %eax |
114 | jmp SYSCALL_ERROR_LABEL | |
d587d83b | 115 | |
2366713d | 116 | PSEUDO_END (__mmap64) |
d587d83b | 117 | |
2366713d | 118 | weak_alias (__mmap64, mmap64) |