Skip to content

[LoongArch][sanitizer] Fix SC_ADDRERR_{RD,WR} missing in the musl environment #108557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,18 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
return Unknown;
return esr & ESR_ELx_WNR ? Write : Read;
# elif defined(__loongarch__)
// In the musl environment, the Linux kernel uapi sigcontext.h is not
// included in signal.h. To avoid missing the SC_ADDRERR_{RD,WR} macros,
// copy them here. The LoongArch Linux kernel uapi is already stable,
// so there's no need to worry about the value changing.
# ifndef SC_ADDRERR_RD
// Address error was due to memory load
# define SC_ADDRERR_RD (1 << 30)
# endif
# ifndef SC_ADDRERR_WR
// Address error was due to memory store
# define SC_ADDRERR_WR (1 << 31)
# endif
u32 flags = ucontext->uc_mcontext.__flags;
if (flags & SC_ADDRERR_RD)
return SignalContext::Read;
Expand Down
Loading