Skip to content

Commit c9f1d2c

Browse files
authored
[compiler-rt][Mips] Fix mips SP register definition (#124493)
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 --------- Signed-off-by: Jens Reidel <[email protected]>
1 parent ea6827c commit c9f1d2c

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,28 @@
3737
# include <asm/ptrace.h>
3838
#endif
3939
#include <sys/user.h> // for user_regs_struct
40-
#if SANITIZER_ANDROID && SANITIZER_MIPS
41-
# include <asm/reg.h> // for mips SP register in sys/user.h
42-
#endif
43-
#include <sys/wait.h> // for signal-related stuff
44-
45-
#ifdef sa_handler
46-
# undef sa_handler
47-
#endif
48-
49-
#ifdef sa_sigaction
50-
# undef sa_sigaction
51-
#endif
52-
53-
#include "sanitizer_common.h"
54-
#include "sanitizer_flags.h"
55-
#include "sanitizer_libc.h"
56-
#include "sanitizer_linux.h"
57-
#include "sanitizer_mutex.h"
58-
#include "sanitizer_placement_new.h"
40+
# if SANITIZER_MIPS
41+
// clang-format off
42+
# include <asm/sgidefs.h> // <asm/sgidefs.h> must be included before <asm/reg.h>
43+
# include <asm/reg.h> // for mips SP register
44+
// clang-format on
45+
# endif
46+
# include <sys/wait.h> // for signal-related stuff
47+
48+
# ifdef sa_handler
49+
# undef sa_handler
50+
# endif
51+
52+
# ifdef sa_sigaction
53+
# undef sa_sigaction
54+
# endif
55+
56+
# include "sanitizer_common.h"
57+
# include "sanitizer_flags.h"
58+
# include "sanitizer_libc.h"
59+
# include "sanitizer_linux.h"
60+
# include "sanitizer_mutex.h"
61+
# include "sanitizer_placement_new.h"
5962

6063
// Sufficiently old kernel headers don't provide this value, but we can still
6164
// call prctl with it. If the runtime kernel is new enough, the prctl call will
@@ -510,11 +513,7 @@ typedef pt_regs regs_struct;
510513

511514
#elif defined(__mips__)
512515
typedef struct user regs_struct;
513-
# if SANITIZER_ANDROID
514-
# define REG_SP regs[EF_R29]
515-
# else
516-
# define REG_SP regs[EF_REG29]
517-
# endif
516+
# define REG_SP regs[EF_R29]
518517

519518
#elif defined(__aarch64__)
520519
typedef struct user_pt_regs regs_struct;

0 commit comments

Comments
 (0)