aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2016-02-01 18:20:21 +0000
committerJoseph Myers <joseph@codesourcery.com>2016-02-01 18:20:21 +0000
commit5163b4b76f61e361f0f4bbe3b96732b12e5c9b1a (patch)
treeb773950fc66e6323c51b5b427d077c05033362e5 /sysdeps/unix
parent0f0f4db5b76c27a7fe5a4247e09c314d4e15c34f (diff)
downloadglibc-5163b4b76f61e361f0f4bbe3b96732b12e5c9b1a.zip
glibc-5163b4b76f61e361f0f4bbe3b96732b12e5c9b1a.tar.gz
glibc-5163b4b76f61e361f0f4bbe3b96732b12e5c9b1a.tar.bz2
Fix MIPS mmap negative offset handling for consistency (bug 19550).
The handling of negative offsets in MIPS mmap is inconsistent with other architectures, as shown by failure of the test posix/tst-mmap-offset for o32 and n32. The MIPS mmap syscall uses a signed argument and does a signed arithmetic shift on it, whereas the glibc semantics expected by that test are for the offset to be considered as a large positive offset. This patch makes MIPS consistent with other architectures as far as possible by using the mmap2 syscall on o32 (#including the generic implementation), and making mmap not an alias for mmap64 for n32, with a custom implementation for n32 that zero-extends the offset argument to 64-bit before calling the mmap syscall. Tested for MIPS64 (o32, n32, n64). [BZ #19550] * sysdeps/unix/sysv/linux/mips/mips32/mmap.c: New file. * sysdeps/unix/sysv/linux/mips/mips64/mmap64.c: Move to .... * sysdeps/unix/sysv/linux/mips/mips64/n64/mmap64.c: ... here. * sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c: New file. * sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list (mmap64): New syscall entry. * sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list (mmap): New syscall entry. * sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (mmap): Remove syscall entry.
Diffstat (limited to 'sysdeps/unix')
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/mmap.c1
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c35
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n64/mmap64.c (renamed from sysdeps/unix/sysv/linux/mips/mips64/mmap64.c)0
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/syscalls.list2
6 files changed, 40 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/mmap.c b/sysdeps/unix/sysv/linux/mips/mips32/mmap.c
new file mode 100644
index 0000000..f30b1da
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips32/mmap.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c>
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c b/sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c
new file mode 100644
index 0000000..7afe776
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c
@@ -0,0 +1,35 @@
+/* mmap for MIPS n32.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <stdint.h>
+#include <sysdep.h>
+
+__ptr_t
+__mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
+{
+ /* To handle negative offsets consistently with other architectures,
+ the offset must be zero-extended to 64-bit. */
+ uint64_t offset_adj = (uint64_t) (uint32_t) offset;
+ return (__ptr_t) INLINE_SYSCALL (mmap, 6, addr, len, prot, flags, fd,
+ offset_adj);
+}
+
+weak_alias (__mmap, mmap)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
index 584ad1f..f55a94a 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
@@ -1,5 +1,7 @@
# File name Caller Syscall name # args Strong name Weak names
+mmap64 - mmap b:aniiii __mmap64 mmap64
+
readahead - readahead i:iii __readahead readahead
sync_file_range - sync_file_range Ci:iiii sync_file_range
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/mmap64.c b/sysdeps/unix/sysv/linux/mips/mips64/n64/mmap64.c
index 0dbd384..0dbd384 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/mmap64.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/mmap64.c
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
index b23a2a1..890a744 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
@@ -1,5 +1,7 @@
# File name Caller Syscall name # args Strong name Weak names
+mmap - mmap b:aniiii __mmap mmap __mmap64 mmap64
+
sync_file_range - sync_file_range Ci:iiii sync_file_range
prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
index 6c80e27..66cc687 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
@@ -2,8 +2,6 @@
lseek - lseek i:iii __libc_lseek __lseek lseek __llseek llseek __libc_lseek64 __lseek64 lseek64
-mmap - mmap b:aniiii __mmap mmap __mmap64 mmap64
-
ftruncate - ftruncate i:ii __ftruncate ftruncate ftruncate64 __ftruncate64
truncate - truncate i:si truncate truncate64