[compiler-rt] 70986ea - [sanitizer][aarch64] Add cast to drop reliance on the type of uc_mcontext.__reserved

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 6 23:26:10 PDT 2021


Author: Fangrui Song
Date: 2021-11-06T23:26:05-07:00
New Revision: 70986ea3d6aeacb5d10bfe3b75757611d4e7a379

URL: https://github.com/llvm/llvm-project/commit/70986ea3d6aeacb5d10bfe3b75757611d4e7a379
DIFF: https://github.com/llvm/llvm-project/commit/70986ea3d6aeacb5d10bfe3b75757611d4e7a379.diff

LOG: [sanitizer][aarch64] Add cast to drop reliance on the type of uc_mcontext.__reserved

https://sourceware.org/bugzilla/show_bug.cgi?id=22742
uc_mcontext.__reserved probably should not be considered user visible API but
unfortunate it is: it is the only way to access cpu states of some Linux
asm/sigcontext.h extensions. That said, the declaration may be
long double __reserved[256]; (used by musl)
instead of
unsigned char __reserved[4096] __attribute__((__aligned__(16))); (glibc)
to avoid dependency on a GNU variable attribute.

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 826c6d36e1b1d..d171e913250fe 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -1773,7 +1773,7 @@ struct __sanitizer_esr_context {
 
 static bool Aarch64GetESR(ucontext_t *ucontext, u64 *esr) {
   static const u32 kEsrMagic = 0x45535201;
-  u8 *aux = ucontext->uc_mcontext.__reserved;
+  u8 *aux = reinterpret_cast<u8 *>(ucontext->uc_mcontext.__reserved);
   while (true) {
     _aarch64_ctx *ctx = (_aarch64_ctx *)aux;
     if (ctx->size == 0) break;


        


More information about the llvm-commits mailing list