Skip to content

Commit d3e7ee3

Browse files
committed
[sanitizer] Define MAP_NORESERVE to 0 and hide mremap for FreeBSD
1 parent e5f2898 commit d3e7ee3

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,13 @@ uptr internal_munmap(void *addr, uptr length) {
183183
return internal_syscall(SYSCALL(munmap), (uptr)addr, length);
184184
}
185185

186+
#if SANITIZER_LINUX
186187
uptr internal_mremap(void *old_address, uptr old_size, uptr new_size, int flags,
187188
void *new_address) {
188189
return internal_syscall(SYSCALL(mremap), (uptr)old_address, old_size,
189190
new_size, flags, (uptr)new_address);
190191
}
192+
#endif
191193

192194
int internal_mprotect(void *addr, uptr length, int prot) {
193195
return internal_syscall(SYSCALL(mprotect), (uptr)addr, length, prot);

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
#include <osreldate.h>
5050
#include <sys/sysctl.h>
5151
#define pthread_getattr_np pthread_attr_get_np
52+
// The MAP_NORESERVE define has been removed in FreeBSD 11.x, and even before
53+
// that, it was never implemented. So just define it to zero.
54+
#undef MAP_NORESERVE
55+
#define MAP_NORESERVE 0
5256
#endif
5357

5458
#if SANITIZER_NETBSD
@@ -883,6 +887,7 @@ static uptr MremapCreateAlias(uptr base_addr, uptr alias_addr,
883887
reinterpret_cast<void *>(alias_addr));
884888
#else
885889
CHECK(false && "mremap is not supported outside of Linux");
890+
return 0;
886891
#endif
887892
}
888893

compiler-rt/lib/sanitizer_common/sanitizer_posix.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ uptr internal_write(fd_t fd, const void *buf, uptr count);
4040
uptr internal_mmap(void *addr, uptr length, int prot, int flags,
4141
int fd, u64 offset);
4242
uptr internal_munmap(void *addr, uptr length);
43+
#if SANITIZER_LINUX
4344
uptr internal_mremap(void *old_address, uptr old_size, uptr new_size, int flags,
4445
void *new_address);
46+
#endif
4547
int internal_mprotect(void *addr, uptr length, int prot);
4648
int internal_madvise(uptr addr, uptr length, int advice);
4749

0 commit comments

Comments
 (0)