Skip to content

Commit 9d1857f

Browse files
committed
[msan] Guard FP_XSTATE_MAGIC1 usage with SANITIZER_GLIBC
Fix build for Linux musl. Reviewed By: #sanitizers, dvyukov Differential Revision: https://reviews.llvm.org/D118970
1 parent f3f8e3d commit 9d1857f

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ namespace __sanitizer {
217217
unsigned struct_sockaddr_sz = sizeof(struct sockaddr);
218218

219219
unsigned ucontext_t_sz(void *ctx) {
220-
# if SANITIZER_LINUX && SANITIZER_X64
220+
# if SANITIZER_GLIBC && SANITIZER_X64
221221
// See kernel arch/x86/kernel/fpu/signal.c for details.
222222
const auto *fpregs = static_cast<ucontext_t *>(ctx)->uc_mcontext.fpregs;
223223
// The member names differ across header versions, but the actual layout

compiler-rt/test/msan/Linux/signal_mcontext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
void handler(int sig, siginfo_t *info, void *uctx) {
1212
__msan_check_mem_is_initialized(uctx, sizeof(ucontext_t));
13-
#if defined(__x86_64__)
13+
#if defined(__GLIBC__) && defined(__x86_64__)
1414
auto *mctx = &static_cast<ucontext_t *>(uctx)->uc_mcontext;
1515
if (auto *fpregs = mctx->fpregs) {
1616
// The member names differ across header versions, but the actual layout

compiler-rt/test/msan/Linux/signal_mcontext2.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
22

3-
// REQUIRES: x86_64-target-arch
3+
// musl does not define FP_XSTATE_MAGIC1.
4+
// REQUIRES: x86_64-target-arch && glibc-2.27
45

56
#include <pthread.h>
67
#include <signal.h>

0 commit comments

Comments
 (0)