]>
Commit | Line | Data |
---|---|---|
568035b7 | 1 | /* Copyright (C) 1995-2013 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> | |
9e25f6e2 GM |
19 | #include <bp-sym.h> |
20 | #include <bp-asm.h> | |
d587d83b | 21 | |
6ddd37a4 | 22 | #include <kernel-features.h> |
d587d83b UD |
23 | |
24 | #define EINVAL 22 | |
af1680f1 | 25 | #define ENOSYS 38 |
f1d8b804 | 26 | |
9e25f6e2 GM |
27 | #define SVRSP 16 /* saved register space */ |
28 | #define PARMS LINKAGE+SVRSP /* space for 4 saved regs */ | |
29 | #define ADDR PARMS | |
30 | #define LEN ADDR+PTR_SIZE | |
31 | #define PROT LEN+4 | |
32 | #define FLAGS PROT+4 | |
33 | #define FD FLAGS+4 | |
34 | #define OFFLO FD+4 | |
35 | #define OFFHI OFFLO+4 | |
d587d83b | 36 | |
9e25f6e2 GM |
37 | .text |
38 | ENTRY (BP_SYM (__mmap64)) | |
d587d83b | 39 | |
d587d83b UD |
40 | /* Save registers. */ |
41 | pushl %ebp | |
1ad9da69 | 42 | cfi_adjust_cfa_offset (4) |
d587d83b | 43 | pushl %ebx |
1ad9da69 | 44 | cfi_adjust_cfa_offset (4) |
d587d83b | 45 | pushl %esi |
1ad9da69 | 46 | cfi_adjust_cfa_offset (4) |
d587d83b | 47 | pushl %edi |
1ad9da69 | 48 | cfi_adjust_cfa_offset (4) |
d587d83b | 49 | |
9e25f6e2 GM |
50 | movl OFFLO(%esp), %edx |
51 | movl OFFHI(%esp), %ecx | |
b0af120f | 52 | testl $0xfff, %edx |
29b3c4f2 | 53 | jne L(einval) |
af1680f1 | 54 | shrdl $12, %ecx, %edx /* mmap2 takes the offset in pages. */ |
d587d83b UD |
55 | shrl $12, %ecx |
56 | jne L(einval) | |
af1680f1 | 57 | movl %edx, %ebp |
1ad9da69 | 58 | cfi_rel_offset (ebp, 12) |
d587d83b | 59 | |
9e25f6e2 | 60 | movl ADDR(%esp), %ebx |
1ad9da69 | 61 | cfi_rel_offset (ebx, 8) |
9e25f6e2 GM |
62 | movl LEN(%esp), %ecx |
63 | movl PROT(%esp), %edx | |
64 | movl FLAGS(%esp), %esi | |
1ad9da69 | 65 | cfi_rel_offset (esi, 4) |
9e25f6e2 | 66 | movl FD(%esp), %edi |
1ad9da69 | 67 | cfi_rel_offset (edi, 0) |
d587d83b | 68 | |
29b3c4f2 UD |
69 | movl $SYS_ify(mmap2), %eax /* System call number in %eax. */ |
70 | ||
d587d83b | 71 | /* Do the system call trap. */ |
f1d8b804 | 72 | L(do_syscall): |
f051627f | 73 | ENTER_KERNEL |
d587d83b | 74 | |
d587d83b UD |
75 | /* Restore registers. */ |
76 | popl %edi | |
1ad9da69 UD |
77 | cfi_adjust_cfa_offset (-4) |
78 | cfi_restore (edi) | |
d587d83b | 79 | popl %esi |
1ad9da69 UD |
80 | cfi_adjust_cfa_offset (-4) |
81 | cfi_restore (esi) | |
d587d83b | 82 | popl %ebx |
1ad9da69 UD |
83 | cfi_adjust_cfa_offset (-4) |
84 | cfi_restore (ebx) | |
d587d83b | 85 | popl %ebp |
1ad9da69 UD |
86 | cfi_adjust_cfa_offset (-4) |
87 | cfi_restore (ebp) | |
d587d83b | 88 | |
56b6e214 UD |
89 | /* If 0 > %eax > -4096 there was an error. */ |
90 | cmpl $-4096, %eax | |
91 | ja SYSCALL_ERROR_LABEL | |
92 | ||
d587d83b | 93 | /* Successful; return the syscall's value. */ |
d587d83b UD |
94 | ret |
95 | ||
1ad9da69 UD |
96 | cfi_adjust_cfa_offset (16) |
97 | cfi_rel_offset (ebp, 12) | |
98 | cfi_rel_offset (ebx, 8) | |
99 | cfi_rel_offset (esi, 4) | |
100 | cfi_rel_offset (edi, 0) | |
d587d83b UD |
101 | /* This means the offset value is too large. */ |
102 | L(einval): | |
103 | popl %edi | |
1ad9da69 UD |
104 | cfi_adjust_cfa_offset (-4) |
105 | cfi_restore (edi) | |
d587d83b | 106 | popl %esi |
1ad9da69 UD |
107 | cfi_adjust_cfa_offset (-4) |
108 | cfi_restore (esi) | |
d587d83b | 109 | popl %ebx |
1ad9da69 UD |
110 | cfi_adjust_cfa_offset (-4) |
111 | cfi_restore (ebx) | |
d587d83b | 112 | popl %ebp |
1ad9da69 UD |
113 | cfi_adjust_cfa_offset (-4) |
114 | cfi_restore (ebp) | |
d587d83b UD |
115 | movl $-EINVAL, %eax |
116 | jmp SYSCALL_ERROR_LABEL | |
d587d83b | 117 | |
9e25f6e2 | 118 | PSEUDO_END (BP_SYM (__mmap64)) |
d587d83b | 119 | |
9e25f6e2 | 120 | weak_alias (BP_SYM (__mmap64), BP_SYM (mmap64)) |