aboutsummaryrefslogtreecommitdiff
path: root/libsanitizer
diff options
context:
space:
mode:
authorH.J. Lu <hongjiu.lu@intel.com>2013-11-06 21:49:36 +0000
committerH.J. Lu <hjl@gcc.gnu.org>2013-11-06 13:49:36 -0800
commit38693e39b6de02d0e868e18a73de39e62fee3936 (patch)
tree9f673c770c0056fd051200261678d64649b1e506 /libsanitizer
parente2baa574d5c09d9425fafaca92c7a287403a7d0b (diff)
downloadgcc-38693e39b6de02d0e868e18a73de39e62fee3936.zip
gcc-38693e39b6de02d0e868e18a73de39e62fee3936.tar.gz
gcc-38693e39b6de02d0e868e18a73de39e62fee3936.tar.bz2
Cast pointers to uptr for 64-bit syscalls
PR sanitizer/59018 * sanitizer_common/sanitizer_linux.cc (internal_mmap, internal_munmap, internal_open, internal_read, internal_write, internal_stat, internal_lstat, internal_fstat, internal_readlink, internal_unlink, internal_execve, NanoTime, BlockingMutex::Lock, BlockingMutex::Unlock, internal_ptrace, internal_getdents, internal_sigaltstack): Cast pointers to uptr for 64-bit syscalls. From-SVN: r204480
Diffstat (limited to 'libsanitizer')
-rw-r--r--libsanitizer/ChangeLog10
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_linux.cc38
2 files changed, 29 insertions, 19 deletions
diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index c7871e3..b874b13 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,3 +1,13 @@
+2013-11-05 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR sanitizer/59018
+ * sanitizer_common/sanitizer_linux.cc (internal_mmap,
+ internal_munmap, internal_open, internal_read, internal_write,
+ internal_stat, internal_lstat, internal_fstat, internal_readlink,
+ internal_unlink, internal_execve, NanoTime, BlockingMutex::Lock,
+ BlockingMutex::Unlock, internal_ptrace, internal_getdents,
+ internal_sigaltstack): Cast pointers to uptr for 64-bit syscalls.
+
2013-11-04 Kostya Serebryany <kcc@google.com>
* All source files: Merge from upstream r191666.
diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cc b/libsanitizer/sanitizer_common/sanitizer_linux.cc
index 666f15b..e48bee5 100644
--- a/libsanitizer/sanitizer_common/sanitizer_linux.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_linux.cc
@@ -77,14 +77,14 @@ namespace __sanitizer {
uptr internal_mmap(void *addr, uptr length, int prot, int flags,
int fd, u64 offset) {
#if SANITIZER_LINUX_USES_64BIT_SYSCALLS
- return internal_syscall(__NR_mmap, addr, length, prot, flags, fd, offset);
+ return internal_syscall(__NR_mmap, (uptr)addr, length, prot, flags, fd, offset);
#else
return internal_syscall(__NR_mmap2, addr, length, prot, flags, fd, offset);
#endif
}
uptr internal_munmap(void *addr, uptr length) {
- return internal_syscall(__NR_munmap, addr, length);
+ return internal_syscall(__NR_munmap, (uptr)addr, length);
}
uptr internal_close(fd_t fd) {
@@ -92,11 +92,11 @@ uptr internal_close(fd_t fd) {
}
uptr internal_open(const char *filename, int flags) {
- return internal_syscall(__NR_open, filename, flags);
+ return internal_syscall(__NR_open, (uptr)filename, flags);
}
uptr internal_open(const char *filename, int flags, u32 mode) {
- return internal_syscall(__NR_open, filename, flags, mode);
+ return internal_syscall(__NR_open, (uptr)filename, flags, mode);
}
uptr OpenFile(const char *filename, bool write) {
@@ -106,13 +106,13 @@ uptr OpenFile(const char *filename, bool write) {
uptr internal_read(fd_t fd, void *buf, uptr count) {
sptr res;
- HANDLE_EINTR(res, (sptr)internal_syscall(__NR_read, fd, buf, count));
+ HANDLE_EINTR(res, (sptr)internal_syscall(__NR_read, fd, (uptr)buf, count));
return res;
}
uptr internal_write(fd_t fd, const void *buf, uptr count) {
sptr res;
- HANDLE_EINTR(res, (sptr)internal_syscall(__NR_write, fd, buf, count));
+ HANDLE_EINTR(res, (sptr)internal_syscall(__NR_write, fd, (uptr)buf, count));
return res;
}
@@ -138,7 +138,7 @@ static void stat64_to_stat(struct stat64 *in, struct stat *out) {
uptr internal_stat(const char *path, void *buf) {
#if SANITIZER_LINUX_USES_64BIT_SYSCALLS
- return internal_syscall(__NR_stat, path, buf);
+ return internal_syscall(__NR_stat, (uptr)path, (uptr)buf);
#else
struct stat64 buf64;
int res = internal_syscall(__NR_stat64, path, &buf64);
@@ -149,7 +149,7 @@ uptr internal_stat(const char *path, void *buf) {
uptr internal_lstat(const char *path, void *buf) {
#if SANITIZER_LINUX_USES_64BIT_SYSCALLS
- return internal_syscall(__NR_lstat, path, buf);
+ return internal_syscall(__NR_lstat, (uptr)path, (uptr)buf);
#else
struct stat64 buf64;
int res = internal_syscall(__NR_lstat64, path, &buf64);
@@ -160,7 +160,7 @@ uptr internal_lstat(const char *path, void *buf) {
uptr internal_fstat(fd_t fd, void *buf) {
#if SANITIZER_LINUX_USES_64BIT_SYSCALLS
- return internal_syscall(__NR_fstat, fd, buf);
+ return internal_syscall(__NR_fstat, fd, (uptr)buf);
#else
struct stat64 buf64;
int res = internal_syscall(__NR_fstat64, fd, &buf64);
@@ -181,11 +181,11 @@ uptr internal_dup2(int oldfd, int newfd) {
}
uptr internal_readlink(const char *path, char *buf, uptr bufsize) {
- return internal_syscall(__NR_readlink, path, buf, bufsize);
+ return internal_syscall(__NR_readlink, (uptr)path, (uptr)buf, bufsize);
}
uptr internal_unlink(const char *path) {
- return internal_syscall(__NR_unlink, path);
+ return internal_syscall(__NR_unlink, (uptr)path);
}
uptr internal_sched_yield() {
@@ -199,7 +199,7 @@ void internal__exit(int exitcode) {
uptr internal_execve(const char *filename, char *const argv[],
char *const envp[]) {
- return internal_syscall(__NR_execve, filename, argv, envp);
+ return internal_syscall(__NR_execve, (uptr)filename, (uptr)argv, (uptr)envp);
}
// ----------------- sanitizer_common.h
@@ -217,7 +217,7 @@ uptr GetTid() {
u64 NanoTime() {
kernel_timeval tv = {};
- internal_syscall(__NR_gettimeofday, &tv, 0);
+ internal_syscall(__NR_gettimeofday, (uptr)&tv, 0);
return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000;
}
@@ -539,7 +539,7 @@ void BlockingMutex::Lock() {
if (atomic_exchange(m, MtxLocked, memory_order_acquire) == MtxUnlocked)
return;
while (atomic_exchange(m, MtxSleeping, memory_order_acquire) != MtxUnlocked)
- internal_syscall(__NR_futex, m, FUTEX_WAIT, MtxSleeping, 0, 0, 0);
+ internal_syscall(__NR_futex, (uptr)m, FUTEX_WAIT, MtxSleeping, 0, 0, 0);
}
void BlockingMutex::Unlock() {
@@ -547,7 +547,7 @@ void BlockingMutex::Unlock() {
u32 v = atomic_exchange(m, MtxUnlocked, memory_order_relaxed);
CHECK_NE(v, MtxUnlocked);
if (v == MtxSleeping)
- internal_syscall(__NR_futex, m, FUTEX_WAKE, 1, 0, 0, 0);
+ internal_syscall(__NR_futex, (uptr)m, FUTEX_WAKE, 1, 0, 0, 0);
}
void BlockingMutex::CheckLocked() {
@@ -568,11 +568,11 @@ struct linux_dirent {
// Syscall wrappers.
uptr internal_ptrace(int request, int pid, void *addr, void *data) {
- return internal_syscall(__NR_ptrace, request, pid, addr, data);
+ return internal_syscall(__NR_ptrace, request, pid, (uptr)addr, (uptr)data);
}
uptr internal_waitpid(int pid, int *status, int options) {
- return internal_syscall(__NR_wait4, pid, status, options, 0 /* rusage */);
+ return internal_syscall(__NR_wait4, pid, (uptr)status, options, 0 /* rusage */);
}
uptr internal_getpid() {
@@ -584,7 +584,7 @@ uptr internal_getppid() {
}
uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count) {
- return internal_syscall(__NR_getdents, fd, dirp, count);
+ return internal_syscall(__NR_getdents, fd, (uptr)dirp, count);
}
uptr internal_lseek(fd_t fd, OFF_T offset, int whence) {
@@ -597,7 +597,7 @@ uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5) {
uptr internal_sigaltstack(const struct sigaltstack *ss,
struct sigaltstack *oss) {
- return internal_syscall(__NR_sigaltstack, ss, oss);
+ return internal_syscall(__NR_sigaltstack, (uptr)ss, (uptr)oss);
}
// ThreadLister implementation.