Skip to content

Commit 910dde5

Browse files
heihertru
authored andcommitted
[LoongArch][sanitizer] Fix SC_ADDRERR_{RD,WR} missing in the musl environment (#108557)
Fixes #108550 (cherry picked from commit 1825cf2)
1 parent 22139b3 commit 910dde5

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
@@ -2014,6 +2014,18 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
20142014
return Unknown;
20152015
return esr & ESR_ELx_WNR ? Write : Read;
20162016
# elif defined(__loongarch__)
2017+
// In the musl environment, the Linux kernel uapi sigcontext.h is not
2018+
// included in signal.h. To avoid missing the SC_ADDRERR_{RD,WR} macros,
2019+
// copy them here. The LoongArch Linux kernel uapi is already stable,
2020+
// so there's no need to worry about the value changing.
2021+
# ifndef SC_ADDRERR_RD
2022+
// Address error was due to memory load
2023+
# define SC_ADDRERR_RD (1 << 30)
2024+
# endif
2025+
# ifndef SC_ADDRERR_WR
2026+
// Address error was due to memory store
2027+
# define SC_ADDRERR_WR (1 << 31)
2028+
# endif
20172029
u32 flags = ucontext->uc_mcontext.__flags;
20182030
if (flags & SC_ADDRERR_RD)
20192031
return SignalContext::Read;

0 commit comments

Comments
 (0)