diff options
| author | Vitaly Buka <vitalybuka@google.com> | 2019-01-22 05:23:48 +0000 |
|---|---|---|
| committer | Vitaly Buka <vitalybuka@google.com> | 2019-01-22 05:23:48 +0000 |
| commit | 096ee9159f791b49f3db0caab8b50afe9d413786 (patch) | |
| tree | 455915e64370cafc3e0d7066fdf98c2efd412010 /compiler-rt/lib/safestack/safestack_platform.h | |
| parent | b96b755c4da5c10fa134ec7c40b0014c0edf204d (diff) | |
| download | bcm5719-llvm-096ee9159f791b49f3db0caab8b50afe9d413786.tar.gz bcm5719-llvm-096ee9159f791b49f3db0caab8b50afe9d413786.zip | |
[safestack] Return syscalls for mmap, munmap and mprotect
This function can be already intercepted by instrumented code.
llvm-svn: 351783
Diffstat (limited to 'compiler-rt/lib/safestack/safestack_platform.h')
| -rw-r--r-- | compiler-rt/lib/safestack/safestack_platform.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/compiler-rt/lib/safestack/safestack_platform.h b/compiler-rt/lib/safestack/safestack_platform.h index 6b042f4b493..b906d52d56e 100644 --- a/compiler-rt/lib/safestack/safestack_platform.h +++ b/compiler-rt/lib/safestack/safestack_platform.h @@ -16,6 +16,7 @@ #include "sanitizer_common/sanitizer_platform.h" #include <stdint.h> +#include <sys/mman.h> #include <sys/syscall.h> #include <sys/types.h> #include <unistd.h> @@ -59,6 +60,33 @@ inline int TgKill(pid_t pid, ThreadId tid, int sig) { #endif } +inline void *Mmap(void *addr, size_t length, int prot, int flags, int fd, + off_t offset) { +#if SANITIZER_NETBSD + return mmap(addr, length, prot, flags, fd, offset); +#elif defined(__x86_64__) && (SANITIZER_FREEBSD) + return (void *)__syscall(SYS_mmap, addr, length, prot, flags, fd, offset); +#else + return (void *)syscall(SYS_mmap, addr, length, prot, flags, fd, offset); +#endif +} + +inline int Munmap(void *addr, size_t length) { +#if SANITIZER_NETBSD + return munmap(addr, length); +#else + return syscall(SYS_munmap, addr, length); +#endif +} + +inline int Mprotect(void *addr, size_t length, int prot) { +#if SANITIZER_NETBSD + return mprotect(addr, length, prot); +#else + return syscall(SYS_mprotect, addr, length, prot); +#endif +} + } // namespace safestack #endif // SAFESTACK_PLATFORM_H |

