Skip to content

Commit b0b4906

Browse files
authored
[compiler-rt] Call __sys_mmap in internal_mmap on FreeBSD
Due to the slightly non-standard interface that returns a pointer rather than just an integer, the __syscall() utility cannot be used on all architectures. This change is required for example to use the sanitizers on Arm Morello. Pull Request: llvm#84438
1 parent 0b92e70 commit b0b4906

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ const int FUTEX_WAKE_PRIVATE = FUTEX_WAKE | FUTEX_PRIVATE_FLAG;
152152

153153
# if SANITIZER_FREEBSD
154154
# define SANITIZER_USE_GETENTROPY 1
155+
extern "C" void *__sys_mmap(void *addr, size_t len, int prot, int flags, int fd,
156+
off_t offset);
155157
# endif
156158

157159
namespace __sanitizer {
@@ -218,7 +220,9 @@ ScopedBlockSignals::~ScopedBlockSignals() { SetSigProcMask(&saved_, nullptr); }
218220
# if !SANITIZER_S390
219221
uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd,
220222
u64 offset) {
221-
# if SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS
223+
# if SANITIZER_FREEBSD
224+
return (uptr)__sys_mmap(addr, length, prot, flags, fd, offset);
225+
# elif SANITIZER_LINUX_USES_64BIT_SYSCALLS
222226
return internal_syscall(SYSCALL(mmap), (uptr)addr, length, prot, flags, fd,
223227
offset);
224228
# else

0 commit comments

Comments
 (0)