[compiler-rt] [compiler-rt][Mips] Fix mips SP register definition (PR #124493)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 26 16:05:29 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Jens Reidel (Gelbpunkt)

<details>
<summary>Changes</summary>

The mainline Linux kernel defines EF_R29, not EF_REG29 [1]. Further, the asm/reg.h header requires `_MIPS_SIM_*` to be defined, which reside in asm/sgidefs.h [2].

[1]: https://github.com/torvalds/linux/blob/v6.13/arch/mips/include/uapi/asm/reg.h#L151
[2]: https://github.com/torvalds/linux/blob/v6.13/arch/mips/include/uapi/asm/sgidefs.h#L33-L35

---
Full diff: https://github.com/llvm/llvm-project/pull/124493.diff


1 Files Affected:

- (modified) compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp (+23-24) 


``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
index 945da99d41f4ea..95483cb79db263 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
@@ -37,25 +37,28 @@
 # include <asm/ptrace.h>
 #endif
 #include <sys/user.h>  // for user_regs_struct
-#if SANITIZER_ANDROID && SANITIZER_MIPS
-# include <asm/reg.h>  // for mips SP register in sys/user.h
-#endif
-#include <sys/wait.h> // for signal-related stuff
-
-#ifdef sa_handler
-# undef sa_handler
-#endif
-
-#ifdef sa_sigaction
-# undef sa_sigaction
-#endif
-
-#include "sanitizer_common.h"
-#include "sanitizer_flags.h"
-#include "sanitizer_libc.h"
-#include "sanitizer_linux.h"
-#include "sanitizer_mutex.h"
-#include "sanitizer_placement_new.h"
+#  if SANITIZER_MIPS
+// clang-format off
+#    include <asm/sgidefs.h>  // for _MIPS_SIM_* defines used in asm/reg.h
+#    include <asm/reg.h>      // for mips SP register in sys/user.h
+// clang-format on
+#  endif
+#  include <sys/wait.h>  // for signal-related stuff
+
+#  ifdef sa_handler
+#    undef sa_handler
+#  endif
+
+#  ifdef sa_sigaction
+#    undef sa_sigaction
+#  endif
+
+#  include "sanitizer_common.h"
+#  include "sanitizer_flags.h"
+#  include "sanitizer_libc.h"
+#  include "sanitizer_linux.h"
+#  include "sanitizer_mutex.h"
+#  include "sanitizer_placement_new.h"
 
 // Sufficiently old kernel headers don't provide this value, but we can still
 // call prctl with it. If the runtime kernel is new enough, the prctl call will
@@ -510,11 +513,7 @@ typedef pt_regs regs_struct;
 
 #elif defined(__mips__)
 typedef struct user regs_struct;
-# if SANITIZER_ANDROID
-#  define REG_SP regs[EF_R29]
-# else
-#  define REG_SP regs[EF_REG29]
-# endif
+#    define REG_SP regs[EF_R29]
 
 #elif defined(__aarch64__)
 typedef struct user_pt_regs regs_struct;

``````````

</details>


https://github.com/llvm/llvm-project/pull/124493


More information about the llvm-commits mailing list