Skip to content

Commit 1825cf2

Browse files
authored
[LoongArch][sanitizer] Fix SC_ADDRERR_{RD,WR} missing in the musl environment (#108557)
Fixes #108550
1 parent 00f239e commit 1825cf2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,18 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
20182018
return Unknown;
20192019
return esr & ESR_ELx_WNR ? Write : Read;
20202020
# elif defined(__loongarch__)
2021+
// In the musl environment, the Linux kernel uapi sigcontext.h is not
2022+
// included in signal.h. To avoid missing the SC_ADDRERR_{RD,WR} macros,
2023+
// copy them here. The LoongArch Linux kernel uapi is already stable,
2024+
// so there's no need to worry about the value changing.
2025+
# ifndef SC_ADDRERR_RD
2026+
// Address error was due to memory load
2027+
# define SC_ADDRERR_RD (1 << 30)
2028+
# endif
2029+
# ifndef SC_ADDRERR_WR
2030+
// Address error was due to memory store
2031+
# define SC_ADDRERR_WR (1 << 31)
2032+
# endif
20212033
u32 flags = ucontext->uc_mcontext.__flags;
20222034
if (flags & SC_ADDRERR_RD)
20232035
return SignalContext::Read;

0 commit comments

Comments
 (0)