[compiler-rt] r343988 - Remove remnant code of using indirect syscall on NetBSD
Kamil Rytarowski via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 8 11:04:47 PDT 2018
Author: kamil
Date: Mon Oct 8 11:04:46 2018
New Revision: 343988
URL: http://llvm.org/viewvc/llvm-project?rev=343988&view=rev
Log:
Remove remnant code of using indirect syscall on NetBSD
Summary:
The NetBSD version of internal routines no longer call
the indirect syscall interfaces, as these functions were
switched to lib calls.
Remove the remnant code complication that is no
longer needed after this change. Remove the variations
of internal_syscall, as they were NetBSD specific.
No functional change intended.
Reviewers: vitalybuka, joerg, javed.absar
Reviewed By: vitalybuka
Subscribers: kubamracek, fedor.sergeev, llvm-commits, #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D52955
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_generic.inc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_aarch64.inc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_arm.inc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_x86_64.inc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=343988&r1=343987&r2=343988&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Mon Oct 8 11:04:46 2018
@@ -188,11 +188,11 @@ uptr internal_mmap(void *addr, uptr leng
#if !SANITIZER_OPENBSD
uptr internal_munmap(void *addr, uptr length) {
- return internal_syscall_ptr(SYSCALL(munmap), (uptr)addr, length);
+ return internal_syscall(SYSCALL(munmap), (uptr)addr, length);
}
int internal_mprotect(void *addr, uptr length, int prot) {
- return internal_syscall_ptr(SYSCALL(mprotect), (uptr)addr, length, prot);
+ return internal_syscall(SYSCALL(mprotect), (uptr)addr, length, prot);
}
#endif
@@ -204,7 +204,7 @@ uptr internal_open(const char *filename,
#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
return internal_syscall(SYSCALL(openat), AT_FDCWD, (uptr)filename, flags);
#else
- return internal_syscall_ptr(SYSCALL(open), (uptr)filename, flags);
+ return internal_syscall(SYSCALL(open), (uptr)filename, flags);
#endif
}
@@ -213,21 +213,21 @@ uptr internal_open(const char *filename,
return internal_syscall(SYSCALL(openat), AT_FDCWD, (uptr)filename, flags,
mode);
#else
- return internal_syscall_ptr(SYSCALL(open), (uptr)filename, flags, mode);
+ return internal_syscall(SYSCALL(open), (uptr)filename, flags, mode);
#endif
}
uptr internal_read(fd_t fd, void *buf, uptr count) {
sptr res;
- HANDLE_EINTR(res, (sptr)internal_syscall_ptr(SYSCALL(read), fd, (uptr)buf,
- count));
+ HANDLE_EINTR(res,
+ (sptr)internal_syscall(SYSCALL(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_ptr(SYSCALL(write), fd, (uptr)buf,
- count));
+ HANDLE_EINTR(res,
+ (sptr)internal_syscall(SYSCALL(write), fd, (uptr)buf, count));
return res;
}
@@ -307,8 +307,7 @@ static void kernel_stat_to_stat(struct k
uptr internal_stat(const char *path, void *buf) {
#if SANITIZER_FREEBSD || SANITIZER_OPENBSD
- return internal_syscall_ptr(SYSCALL(fstatat), AT_FDCWD, (uptr)path, (uptr)buf,
- 0);
+ return internal_syscall(SYSCALL(fstatat), AT_FDCWD, (uptr)path, (uptr)buf, 0);
#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path, (uptr)buf,
0);
@@ -365,7 +364,7 @@ uptr internal_fstat(fd_t fd, void *buf)
kernel_stat_to_stat(&kbuf, (struct stat *)buf);
return res;
# else
- return internal_syscall_ptr(SYSCALL(fstat), fd, (uptr)buf);
+ return internal_syscall(SYSCALL(fstat), fd, (uptr)buf);
# endif
#else
struct stat64 buf64;
@@ -395,10 +394,10 @@ uptr internal_readlink(const char *path,
return internal_syscall(SYSCALL(readlinkat), AT_FDCWD, (uptr)path, (uptr)buf,
bufsize);
#elif SANITIZER_OPENBSD
- return internal_syscall_ptr(SYSCALL(readlinkat), AT_FDCWD, (uptr)path,
- (uptr)buf, bufsize);
+ return internal_syscall(SYSCALL(readlinkat), AT_FDCWD, (uptr)path, (uptr)buf,
+ bufsize);
#else
- return internal_syscall_ptr(SYSCALL(readlink), path, buf, bufsize);
+ return internal_syscall(SYSCALL(readlink), path, buf, bufsize);
#endif
}
@@ -406,7 +405,7 @@ uptr internal_unlink(const char *path) {
#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS || SANITIZER_OPENBSD
return internal_syscall(SYSCALL(unlinkat), AT_FDCWD, (uptr)path, 0);
#else
- return internal_syscall_ptr(SYSCALL(unlink), (uptr)path);
+ return internal_syscall(SYSCALL(unlink), (uptr)path);
#endif
}
@@ -415,7 +414,7 @@ uptr internal_rename(const char *oldpath
return internal_syscall(SYSCALL(renameat), AT_FDCWD, (uptr)oldpath, AT_FDCWD,
(uptr)newpath);
#else
- return internal_syscall_ptr(SYSCALL(rename), (uptr)oldpath, (uptr)newpath);
+ return internal_syscall(SYSCALL(rename), (uptr)oldpath, (uptr)newpath);
#endif
}
@@ -436,15 +435,15 @@ unsigned int internal_sleep(unsigned int
struct timespec ts;
ts.tv_sec = 1;
ts.tv_nsec = 0;
- int res = internal_syscall_ptr(SYSCALL(nanosleep), &ts, &ts);
+ int res = internal_syscall(SYSCALL(nanosleep), &ts, &ts);
if (res) return ts.tv_sec;
return 0;
}
uptr internal_execve(const char *filename, char *const argv[],
char *const envp[]) {
- return internal_syscall_ptr(SYSCALL(execve), (uptr)filename, (uptr)argv,
- (uptr)envp);
+ return internal_syscall(SYSCALL(execve), (uptr)filename, (uptr)argv,
+ (uptr)envp);
}
#endif // !SANITIZER_SOLARIS && !SANITIZER_NETBSD
@@ -499,12 +498,12 @@ u64 NanoTime() {
kernel_timeval tv;
#endif
internal_memset(&tv, 0, sizeof(tv));
- internal_syscall_ptr(SYSCALL(gettimeofday), &tv, 0);
+ internal_syscall(SYSCALL(gettimeofday), &tv, 0);
return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000;
}
uptr internal_clock_gettime(__sanitizer_clockid_t clk_id, void *tp) {
- return internal_syscall_ptr(SYSCALL(clock_gettime), clk_id, tp);
+ return internal_syscall(SYSCALL(clock_gettime), clk_id, tp);
}
#endif // !SANITIZER_SOLARIS && !SANITIZER_NETBSD
@@ -742,7 +741,7 @@ uptr internal_ptrace(int request, int pi
}
uptr internal_waitpid(int pid, int *status, int options) {
- return internal_syscall_ptr(SYSCALL(wait4), pid, (uptr)status, options,
+ return internal_syscall(SYSCALL(wait4), pid, (uptr)status, options,
0 /* rusage */);
}
@@ -760,7 +759,7 @@ uptr internal_getdents(fd_t fd, struct l
#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
return internal_syscall(SYSCALL(getdents64), fd, (uptr)dirp, count);
#else
- return internal_syscall_ptr(SYSCALL(getdents), fd, (uptr)dirp, count);
+ return internal_syscall(SYSCALL(getdents), fd, (uptr)dirp, count);
#endif
}
@@ -775,7 +774,7 @@ uptr internal_prctl(int option, uptr arg
#endif
uptr internal_sigaltstack(const void *ss, void *oss) {
- return internal_syscall_ptr(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
+ return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
}
int internal_fork() {
@@ -878,7 +877,7 @@ int internal_sigaction_syscall(int signu
uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
__sanitizer_sigset_t *oldset) {
#if SANITIZER_FREEBSD || SANITIZER_OPENBSD
- return internal_syscall_ptr(SYSCALL(sigprocmask), how, set, oldset);
+ return internal_syscall(SYSCALL(sigprocmask), how, set, oldset);
#else
__sanitizer_kernel_sigset_t *k_set = (__sanitizer_kernel_sigset_t *)set;
__sanitizer_kernel_sigset_t *k_oldset = (__sanitizer_kernel_sigset_t *)oldset;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_generic.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_generic.inc?rev=343988&r1=343987&r2=343988&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_generic.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_generic.inc Mon Oct 8 11:04:46 2018
@@ -11,46 +11,21 @@
//
//===----------------------------------------------------------------------===//
-#if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD || \
- SANITIZER_OPENBSD || SANITIZER_SOLARIS
+// NetBSD uses libc calls directly
+#if !SANITIZER_NETBSD
+
+#if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_OPENBSD || SANITIZER_SOLARIS
# define SYSCALL(name) SYS_ ## name
#else
# define SYSCALL(name) __NR_ ## name
#endif
-#if SANITIZER_NETBSD
-// We use 3 kinds of internal_syscall's for different types of retval in order
-// to address differences in calling conventions (e.g. registers to place the
-// return value in).
-// - internal_syscall for 32-bit length (int, pid_t)
-// - internal_syscall64 for 64-bit length (off_t)
-// - internal_syscall_ptr for pointer and (s)size_t
-# define internal_syscall syscall
-# define internal_syscall64 __syscall
-// Handle syscall renames manually
-# define SYS_stat SYS___stat50
-# define SYS_lstat SYS___lstat50
-# define SYS_fstat SYS___fstat50
-# define SYS_gettimeofday SYS___gettimeofday50
-# define SYS_wait4 SYS___wait450
-# define SYS_getdents SYS___getdents30
-# define SYS_sigaltstack SYS___sigaltstack14
-# define SYS_sigprocmask SYS___sigprocmask14
-# define SYS_nanosleep SYS___nanosleep50
-# define SYS_clock_gettime SYS___clock_gettime50
-# if SANITIZER_WORDSIZE == 64
-# define internal_syscall_ptr __syscall
-# else
-# define internal_syscall_ptr syscall
-# endif
-#elif defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_MAC)
+#if defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_MAC)
# define internal_syscall __syscall
-# define internal_syscall64 __syscall
-# define internal_syscall_ptr __syscall
# else
# define internal_syscall syscall
-# define internal_syscall64 syscall
-# define internal_syscall_ptr syscall
+#endif
+
#endif
bool internal_iserror(uptr retval, int *rverrno) {
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_aarch64.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_aarch64.inc?rev=343988&r1=343987&r2=343988&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_aarch64.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_aarch64.inc Mon Oct 8 11:04:46 2018
@@ -127,9 +127,6 @@ static uptr __internal_syscall(u64 nr, u
#define internal_syscall(...) __SYSCALL_DISP(__internal_syscall, __VA_ARGS__)
-#define internal_syscall_ptr internal_syscall
-#define internal_syscall64 internal_syscall
-
// Helper function used to avoid cobbler errno.
bool internal_iserror(uptr retval, int *rverrno) {
if (retval >= (uptr)-4095) {
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_arm.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_arm.inc?rev=343988&r1=343987&r2=343988&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_arm.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_arm.inc Mon Oct 8 11:04:46 2018
@@ -127,9 +127,6 @@ static uptr __internal_syscall(u32 nr, u
#define internal_syscall(...) __SYSCALL_DISP(__internal_syscall, __VA_ARGS__)
-#define internal_syscall_ptr internal_syscall
-#define internal_syscall64 internal_syscall
-
// Helper function used to avoid cobbler errno.
bool internal_iserror(uptr retval, int *rverrno) {
if (retval >= (uptr)-4095) {
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_x86_64.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_x86_64.inc?rev=343988&r1=343987&r2=343988&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_x86_64.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_syscall_linux_x86_64.inc Mon Oct 8 11:04:46 2018
@@ -20,9 +20,6 @@ static uptr internal_syscall(u64 nr) {
return retval;
}
-#define internal_syscall_ptr internal_syscall
-#define internal_syscall64 internal_syscall
-
template <typename T1>
static uptr internal_syscall(u64 nr, T1 arg1) {
u64 retval;
More information about the llvm-commits
mailing list