fix the mremap signature
The mremap definition was incorrect (unsigned long instead of int) and it was missing the optional new_address parameter. Change-Id: Ib9d0675aaa098c21617cedc9b2b8cf267be3aec4
This commit is contained in:
parent
ef5e647891
commit
4200e260d2
@ -47,7 +47,6 @@ libc_common_src_files := \
|
|||||||
bionic/if_indextoname.c \
|
bionic/if_indextoname.c \
|
||||||
bionic/if_nametoindex.c \
|
bionic/if_nametoindex.c \
|
||||||
bionic/initgroups.c \
|
bionic/initgroups.c \
|
||||||
bionic/ioctl.c \
|
|
||||||
bionic/isatty.c \
|
bionic/isatty.c \
|
||||||
bionic/memmem.c \
|
bionic/memmem.c \
|
||||||
bionic/pututline.c \
|
bionic/pututline.c \
|
||||||
@ -151,6 +150,7 @@ libc_bionic_ndk_src_files := \
|
|||||||
bionic/gettid.cpp \
|
bionic/gettid.cpp \
|
||||||
bionic/__gnu_basename.cpp \
|
bionic/__gnu_basename.cpp \
|
||||||
bionic/inotify_init.cpp \
|
bionic/inotify_init.cpp \
|
||||||
|
bionic/ioctl.cpp \
|
||||||
bionic/lchown.cpp \
|
bionic/lchown.cpp \
|
||||||
bionic/lfs64_support.cpp \
|
bionic/lfs64_support.cpp \
|
||||||
bionic/__libc_current_sigrtmax.cpp \
|
bionic/__libc_current_sigrtmax.cpp \
|
||||||
@ -170,6 +170,7 @@ libc_bionic_ndk_src_files := \
|
|||||||
bionic/mkfifo.cpp \
|
bionic/mkfifo.cpp \
|
||||||
bionic/mknod.cpp \
|
bionic/mknod.cpp \
|
||||||
bionic/mntent.cpp \
|
bionic/mntent.cpp \
|
||||||
|
bionic/mremap.cpp \
|
||||||
bionic/NetdClientDispatch.cpp \
|
bionic/NetdClientDispatch.cpp \
|
||||||
bionic/open.cpp \
|
bionic/open.cpp \
|
||||||
bionic/pathconf.cpp \
|
bionic/pathconf.cpp \
|
||||||
|
@ -107,7 +107,7 @@ ssize_t pwritev|pwritev64(int, const struct iovec*, int, off_t) arm64,mips64
|
|||||||
int ___close:close(int) all
|
int ___close:close(int) all
|
||||||
pid_t __getpid:getpid() all
|
pid_t __getpid:getpid() all
|
||||||
int munmap(void*, size_t) all
|
int munmap(void*, size_t) all
|
||||||
void* mremap(void*, size_t, size_t, unsigned long) all
|
void* ___mremap:mremap(void*, size_t, size_t, int, void*) all
|
||||||
int msync(const void*, size_t, int) all
|
int msync(const void*, size_t, int) all
|
||||||
int mprotect(const void*, size_t, int) all
|
int mprotect(const void*, size_t, int) all
|
||||||
int madvise(void*, size_t, int) all
|
int madvise(void*, size_t, int) all
|
||||||
|
23
libc/arch-arm/syscalls/___mremap.S
Normal file
23
libc/arch-arm/syscalls/___mremap.S
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/* Generated by gensyscalls.py. Do not edit. */
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
ENTRY(___mremap)
|
||||||
|
mov ip, sp
|
||||||
|
stmfd sp!, {r4, r5, r6, r7}
|
||||||
|
.cfi_def_cfa_offset 16
|
||||||
|
.cfi_rel_offset r4, 0
|
||||||
|
.cfi_rel_offset r5, 4
|
||||||
|
.cfi_rel_offset r6, 8
|
||||||
|
.cfi_rel_offset r7, 12
|
||||||
|
ldmfd ip, {r4, r5, r6}
|
||||||
|
ldr r7, =__NR_mremap
|
||||||
|
swi #0
|
||||||
|
ldmfd sp!, {r4, r5, r6, r7}
|
||||||
|
.cfi_def_cfa_offset 0
|
||||||
|
cmn r0, #(MAX_ERRNO + 1)
|
||||||
|
bxls lr
|
||||||
|
neg r0, r0
|
||||||
|
b __set_errno_internal
|
||||||
|
END(___mremap)
|
||||||
|
.hidden ___mremap
|
@ -1,14 +0,0 @@
|
|||||||
/* Generated by gensyscalls.py. Do not edit. */
|
|
||||||
|
|
||||||
#include <private/bionic_asm.h>
|
|
||||||
|
|
||||||
ENTRY(mremap)
|
|
||||||
mov ip, r7
|
|
||||||
ldr r7, =__NR_mremap
|
|
||||||
swi #0
|
|
||||||
mov r7, ip
|
|
||||||
cmn r0, #(MAX_ERRNO + 1)
|
|
||||||
bxls lr
|
|
||||||
neg r0, r0
|
|
||||||
b __set_errno_internal
|
|
||||||
END(mremap)
|
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(mremap)
|
ENTRY(___mremap)
|
||||||
mov x8, __NR_mremap
|
mov x8, __NR_mremap
|
||||||
svc #0
|
svc #0
|
||||||
|
|
||||||
@ -11,4 +11,5 @@ ENTRY(mremap)
|
|||||||
b.hi __set_errno_internal
|
b.hi __set_errno_internal
|
||||||
|
|
||||||
ret
|
ret
|
||||||
END(mremap)
|
END(___mremap)
|
||||||
|
.hidden ___mremap
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(mremap)
|
ENTRY(___mremap)
|
||||||
.set noreorder
|
.set noreorder
|
||||||
.cpload t9
|
.cpload t9
|
||||||
li v0, __NR_mremap
|
li v0, __NR_mremap
|
||||||
@ -16,4 +16,5 @@ ENTRY(mremap)
|
|||||||
j t9
|
j t9
|
||||||
nop
|
nop
|
||||||
.set reorder
|
.set reorder
|
||||||
END(mremap)
|
END(___mremap)
|
||||||
|
.hidden ___mremap
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(mremap)
|
ENTRY(___mremap)
|
||||||
.set push
|
.set push
|
||||||
.set noreorder
|
.set noreorder
|
||||||
li v0, __NR_mremap
|
li v0, __NR_mremap
|
||||||
@ -22,4 +22,5 @@ ENTRY(mremap)
|
|||||||
j t9
|
j t9
|
||||||
move ra, t0
|
move ra, t0
|
||||||
.set pop
|
.set pop
|
||||||
END(mremap)
|
END(___mremap)
|
||||||
|
.hidden ___mremap
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(mremap)
|
ENTRY(___mremap)
|
||||||
pushl %ebx
|
pushl %ebx
|
||||||
.cfi_def_cfa_offset 8
|
.cfi_def_cfa_offset 8
|
||||||
.cfi_rel_offset ebx, 0
|
.cfi_rel_offset ebx, 0
|
||||||
@ -15,10 +15,14 @@ ENTRY(mremap)
|
|||||||
pushl %esi
|
pushl %esi
|
||||||
.cfi_adjust_cfa_offset 4
|
.cfi_adjust_cfa_offset 4
|
||||||
.cfi_rel_offset esi, 0
|
.cfi_rel_offset esi, 0
|
||||||
mov 20(%esp), %ebx
|
pushl %edi
|
||||||
mov 24(%esp), %ecx
|
.cfi_adjust_cfa_offset 4
|
||||||
mov 28(%esp), %edx
|
.cfi_rel_offset edi, 0
|
||||||
mov 32(%esp), %esi
|
mov 24(%esp), %ebx
|
||||||
|
mov 28(%esp), %ecx
|
||||||
|
mov 32(%esp), %edx
|
||||||
|
mov 36(%esp), %esi
|
||||||
|
mov 40(%esp), %edi
|
||||||
movl $__NR_mremap, %eax
|
movl $__NR_mremap, %eax
|
||||||
int $0x80
|
int $0x80
|
||||||
cmpl $-MAX_ERRNO, %eax
|
cmpl $-MAX_ERRNO, %eax
|
||||||
@ -28,9 +32,11 @@ ENTRY(mremap)
|
|||||||
call __set_errno_internal
|
call __set_errno_internal
|
||||||
addl $4, %esp
|
addl $4, %esp
|
||||||
1:
|
1:
|
||||||
|
popl %edi
|
||||||
popl %esi
|
popl %esi
|
||||||
popl %edx
|
popl %edx
|
||||||
popl %ecx
|
popl %ecx
|
||||||
popl %ebx
|
popl %ebx
|
||||||
ret
|
ret
|
||||||
END(mremap)
|
END(___mremap)
|
||||||
|
.hidden ___mremap
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(mremap)
|
ENTRY(___mremap)
|
||||||
movq %rcx, %r10
|
movq %rcx, %r10
|
||||||
movl $__NR_mremap, %eax
|
movl $__NR_mremap, %eax
|
||||||
syscall
|
syscall
|
||||||
@ -13,4 +13,5 @@ ENTRY(mremap)
|
|||||||
call __set_errno_internal
|
call __set_errno_internal
|
||||||
1:
|
1:
|
||||||
ret
|
ret
|
||||||
END(mremap)
|
END(___mremap)
|
||||||
|
.hidden ___mremap
|
@ -25,19 +25,16 @@
|
|||||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
extern int __ioctl(int, int, void *);
|
extern "C" int __ioctl(int, int, void *);
|
||||||
|
|
||||||
int ioctl(int fd, int request, ...)
|
int ioctl(int fd, int request, ...) {
|
||||||
{
|
va_list ap;
|
||||||
va_list ap;
|
va_start(ap, request);
|
||||||
void * arg;
|
void* arg = va_arg(ap, void*);
|
||||||
|
va_end(ap);
|
||||||
va_start(ap, request);
|
return __ioctl(fd, request, arg);
|
||||||
arg = va_arg(ap, void *);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
return __ioctl(fd, request, arg);
|
|
||||||
}
|
}
|
||||||
|
|
45
libc/bionic/mremap.cpp
Normal file
45
libc/bionic/mremap.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
extern "C" void* ___mremap(void*, size_t, size_t, int, void*);
|
||||||
|
|
||||||
|
void* mremap(void* old_address, size_t old_size, size_t new_size, int flags, ...) {
|
||||||
|
void* new_address = nullptr;
|
||||||
|
// The optional argument is only valid if the MREMAP_FIXED flag is set,
|
||||||
|
// so we assume it's not present otherwise.
|
||||||
|
if ((flags & MREMAP_FIXED) != 0) {
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, flags);
|
||||||
|
new_address = va_arg(ap, void*);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
return ___mremap(old_address, old_size, new_size, flags, new_address);
|
||||||
|
}
|
@ -59,7 +59,7 @@ extern void* mmap64(void*, size_t, int, int, int, off64_t);
|
|||||||
extern int munmap(void*, size_t);
|
extern int munmap(void*, size_t);
|
||||||
extern int msync(const void*, size_t, int);
|
extern int msync(const void*, size_t, int);
|
||||||
extern int mprotect(const void*, size_t, int);
|
extern int mprotect(const void*, size_t, int);
|
||||||
extern void* mremap(void*, size_t, size_t, unsigned long);
|
extern void* mremap(void*, size_t, size_t, int, ...);
|
||||||
|
|
||||||
extern int mlockall(int);
|
extern int mlockall(int);
|
||||||
extern int munlockall(void);
|
extern int munlockall(void);
|
||||||
|
@ -215,3 +215,7 @@ TEST(sys_mman, posix_madvise_POSIX_MADV_DONTNEED) {
|
|||||||
|
|
||||||
ASSERT_EQ(0, munmap(map, pagesize));
|
ASSERT_EQ(0, munmap(map, pagesize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(sys_mman, mremap) {
|
||||||
|
ASSERT_EQ(MAP_FAILED, mremap(nullptr, 0, 0, 0));
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user