]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/i386/mmap64.S
Remove unused pseudo_end label
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / i386 / mmap64.S
1 /* Copyright (C) 1995-2012 Free Software Foundation, Inc.
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
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.
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
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18 #include <sysdep.h>
19 #include <bp-sym.h>
20 #include <bp-asm.h>
21
22 #include <kernel-features.h>
23
24 #define EINVAL 22
25 #define ENOSYS 38
26
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
36
37 .text
38 ENTRY (BP_SYM (__mmap64))
39
40 #ifdef __NR_mmap2
41
42 /* Save registers. */
43 pushl %ebp
44 cfi_adjust_cfa_offset (4)
45 pushl %ebx
46 cfi_adjust_cfa_offset (4)
47 pushl %esi
48 cfi_adjust_cfa_offset (4)
49 pushl %edi
50 cfi_adjust_cfa_offset (4)
51
52 movl OFFLO(%esp), %edx
53 movl OFFHI(%esp), %ecx
54 testl $0xfff, %edx
55 jne L(einval)
56 shrdl $12, %ecx, %edx /* mmap2 takes the offset in pages. */
57 shrl $12, %ecx
58 jne L(einval)
59 movl %edx, %ebp
60 cfi_rel_offset (ebp, 12)
61
62 movl ADDR(%esp), %ebx
63 cfi_rel_offset (ebx, 8)
64 movl LEN(%esp), %ecx
65 movl PROT(%esp), %edx
66 movl FLAGS(%esp), %esi
67 cfi_rel_offset (esi, 4)
68 movl FD(%esp), %edi
69 cfi_rel_offset (edi, 0)
70
71 movl $SYS_ify(mmap2), %eax /* System call number in %eax. */
72
73 /* Do the system call trap. */
74 L(do_syscall):
75 ENTER_KERNEL
76
77 /* Restore registers. */
78 popl %edi
79 cfi_adjust_cfa_offset (-4)
80 cfi_restore (edi)
81 popl %esi
82 cfi_adjust_cfa_offset (-4)
83 cfi_restore (esi)
84 popl %ebx
85 cfi_adjust_cfa_offset (-4)
86 cfi_restore (ebx)
87 popl %ebp
88 cfi_adjust_cfa_offset (-4)
89 cfi_restore (ebp)
90
91 #ifndef __ASSUME_MMAP2_SYSCALL
92 2:
93 cmp $-ENOSYS, %eax
94 je 3f
95 #endif
96
97 /* If 0 > %eax > -4096 there was an error. */
98 cmpl $-4096, %eax
99 ja SYSCALL_ERROR_LABEL
100
101 /* Successful; return the syscall's value. */
102 ret
103
104 cfi_adjust_cfa_offset (16)
105 cfi_rel_offset (ebp, 12)
106 cfi_rel_offset (ebx, 8)
107 cfi_rel_offset (esi, 4)
108 cfi_rel_offset (edi, 0)
109 /* This means the offset value is too large. */
110 L(einval):
111 popl %edi
112 cfi_adjust_cfa_offset (-4)
113 cfi_restore (edi)
114 popl %esi
115 cfi_adjust_cfa_offset (-4)
116 cfi_restore (esi)
117 popl %ebx
118 cfi_adjust_cfa_offset (-4)
119 cfi_restore (ebx)
120 popl %ebp
121 cfi_adjust_cfa_offset (-4)
122 cfi_restore (ebp)
123 movl $-EINVAL, %eax
124 jmp SYSCALL_ERROR_LABEL
125 #endif
126
127 #if !defined __ASSUME_MMAP2_SYSCALL || !defined __NR_mmap2
128 3:
129 /* Save registers. */
130 movl %ebx, %edx
131 cfi_register (ebx, edx)
132
133 cmpl $0, OFFHI-SVRSP(%esp)
134 jne L(einval2)
135
136 movl $SYS_ify(mmap), %eax /* System call number in %eax. */
137
138 lea ADDR-SVRSP(%esp), %ebx /* Address of args is 1st arg. */
139
140 /* Do the system call trap. */
141 ENTER_KERNEL
142
143 /* Restore registers. */
144 movl %edx, %ebx
145 cfi_restore (ebx)
146
147 /* If 0 > %eax > -4096 there was an error. */
148 cmpl $-4096, %eax
149 ja SYSCALL_ERROR_LABEL
150
151 /* Successful; return the syscall's value. */
152 ret
153
154 cfi_register (ebx, edx)
155 L(einval2):
156 movl %edx, %ebx
157 cfi_restore (ebx)
158 movl $-EINVAL, %eax
159 jmp SYSCALL_ERROR_LABEL
160 #endif
161
162 PSEUDO_END (BP_SYM (__mmap64))
163
164 weak_alias (BP_SYM (__mmap64), BP_SYM (mmap64))