From 8904ed80c262e973c0da7758337f586c9854f38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Thu, 15 Jun 2023 09:28:57 +0200 Subject: [PATCH] msan: fix ifdef guard for getrlimit etc interceptors These interceptors need struct_ustat_sz, struct_rlimit64_sz, and struct_statvfs64_sz which are defined in the following file: compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp However, these variables are only defined for GLIBC sanitizers. As such, if we attempt to use MSAN on a Linux system that does not utilize glibc (e.g. Alpine Linux) then we will get a linker error complaining about undefined references to __sanitizer::struct_rlimit64_sz and __sanitizer::struct_rlimit64_sz. This patch fixes this by only defining the interceptors that require these constants if SANITIZER_GLIBC is defined. Thereby aligning the macro guards of msan_interceptors.cpp with those of sanitizer_platform_limits_posix.cpp. --- compiler-rt/lib/msan/msan_interceptors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler-rt/lib/msan/msan_interceptors.cpp b/compiler-rt/lib/msan/msan_interceptors.cpp index 6f57c33ee..349eff549 100644 --- a/compiler-rt/lib/msan/msan_interceptors.cpp +++ b/compiler-rt/lib/msan/msan_interceptors.cpp @@ -822,7 +822,7 @@ INTERCEPTOR(int, getrlimit, int resource, void *rlim) { INTERCEPTOR_GETRLIMIT_BODY(getrlimit, resource, rlim); } -#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD +#if SANITIZER_GLIBC INTERCEPTOR(int, __getrlimit, int resource, void *rlim) { INTERCEPTOR_GETRLIMIT_BODY(__getrlimit, resource, rlim); }