Skip to content

Commit 28f9575

Browse files
authored
[compiler-rt] Require glibc for DumpAllRegisters on Linux (#101131)
For example musl doesn't provide REG_R* definitions for ARM #100398
1 parent 3fcc4f2 commit 28f9575

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ bool SignalContext::IsTrueFaultingAddress() const {
21212121
UNUSED
21222122
static const char *RegNumToRegName(int reg) {
21232123
switch (reg) {
2124-
# if SANITIZER_LINUX
2124+
# if SANITIZER_LINUX && SANITIZER_GLIBC
21252125
# if defined(__x86_64__)
21262126
case REG_RAX:
21272127
return "rax";
@@ -2240,14 +2240,15 @@ static const char *RegNumToRegName(int reg) {
22402240
case 31:
22412241
return "sp";
22422242
# endif
2243-
# endif // SANITIZER_LINUX
2243+
# endif // SANITIZER_LINUX && SANITIZER_GLIBC
22442244
default:
22452245
return NULL;
22462246
}
22472247
return NULL;
22482248
}
22492249

2250-
# if SANITIZER_LINUX && (defined(__arm__) || defined(__aarch64__))
2250+
# if SANITIZER_LINUX && SANITIZER_GLIBC && \
2251+
(defined(__arm__) || defined(__aarch64__))
22512252
static uptr GetArmRegister(ucontext_t *ctx, int RegNum) {
22522253
switch (RegNum) {
22532254
# if defined(__arm__)
@@ -2289,7 +2290,8 @@ static uptr GetArmRegister(ucontext_t *ctx, int RegNum) {
22892290
}
22902291
return 0;
22912292
}
2292-
# endif // SANITIZER_LINUX && (defined(__arm__) || defined(__aarch64__))
2293+
# endif // SANITIZER_LINUX && SANITIZER_GLIBC && (defined(__arm__) ||
2294+
// defined(__aarch64__))
22932295

22942296
UNUSED
22952297
static void DumpSingleReg(ucontext_t *ctx, int RegNum) {
@@ -2312,7 +2314,7 @@ static void DumpSingleReg(ucontext_t *ctx, int RegNum) {
23122314

23132315
void SignalContext::DumpAllRegisters(void *context) {
23142316
ucontext_t *ucontext = (ucontext_t *)context;
2315-
# if SANITIZER_LINUX
2317+
# if SANITIZER_LINUX && SANITIZER_GLIBC
23162318
# if defined(__x86_64__)
23172319
Report("Register values:\n");
23182320
DumpSingleReg(ucontext, REG_RAX);

compiler-rt/test/sanitizer_common/TestCases/Linux/dump_registers_aarch64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %env_tool_opts=dump_registers=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NODUMP
44
// RUN: not %run %t 2>&1 | FileCheck %s --strict-whitespace --check-prefix=CHECK-DUMP
55
//
6-
// REQUIRES: aarch64-target-arch
6+
// REQUIRES: aarch64-target-arch && glibc
77

88
#include <signal.h>
99

compiler-rt/test/sanitizer_common/TestCases/Linux/dump_registers_arm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %env_tool_opts=dump_registers=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NODUMP
44
// RUN: not %run %t 2>&1 | FileCheck %s --strict-whitespace --check-prefix=CHECK-DUMP
55
//
6-
// REQUIRES: arm-target-arch
6+
// REQUIRES: arm-target-arch && glibc
77

88
#include <signal.h>
99

compiler-rt/test/sanitizer_common/TestCases/Linux/dump_registers_i386.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %env_tool_opts=dump_registers=0 not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-NODUMP --strict-whitespace
44
// RUN: not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-DUMP --strict-whitespace
55
//
6-
// REQUIRES: i386-target-arch
6+
// REQUIRES: i386-target-arch && glibc
77

88
#include <signal.h>
99

compiler-rt/test/sanitizer_common/TestCases/Linux/dump_registers_x86_64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %env_tool_opts=dump_registers=0 not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-NODUMP --strict-whitespace
44
// RUN: not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-DUMP --strict-whitespace
55
//
6-
// REQUIRES: x86_64-target-arch
6+
// REQUIRES: x86_64-target-arch && glibc
77

88
#include <signal.h>
99

0 commit comments

Comments
 (0)