Skip to content

Commit b707d52

Browse files
authored
[compiler-rt][Mips] Properly guard references to _ABIN32 (#124492)
When targeting ABIO32 (mips32), _ABIN32 is undefined and the preprocessor directives cause compile errors. Guard references to _ABIN32 with defined(_ABIN32), just like the references to _ABIO32. Signed-off-by: Jens Reidel <[email protected]>
1 parent aca08a8 commit b707d52

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

compiler-rt/lib/safestack/safestack_platform.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ extern "C" void *__mmap(void *, size_t, int, int, int, int, off_t);
5454
// but it still needs to use 64-bit syscalls.
5555
#if SANITIZER_LINUX && \
5656
(defined(__x86_64__) || defined(__powerpc64__) || \
57-
SANITIZER_WORDSIZE == 64 || (defined(__mips__) && _MIPS_SIM == _ABIN32))
57+
SANITIZER_WORDSIZE == 64 || \
58+
(defined(__mips__) && defined(_ABIN32) && _MIPS_SIM == _ABIN32))
5859
# define SANITIZER_LINUX_USES_64BIT_SYSCALLS 1
5960
#else
6061
# define SANITIZER_LINUX_USES_64BIT_SYSCALLS 0

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ const int FUTEX_WAKE_PRIVATE = FUTEX_WAKE | FUTEX_PRIVATE_FLAG;
134134
// Are we using 32-bit or 64-bit Linux syscalls?
135135
// x32 (which defines __x86_64__) has SANITIZER_WORDSIZE == 32
136136
// but it still needs to use 64-bit syscalls.
137-
# if SANITIZER_LINUX && (defined(__x86_64__) || defined(__powerpc64__) || \
138-
SANITIZER_WORDSIZE == 64 || \
139-
(defined(__mips__) && _MIPS_SIM == _ABIN32))
137+
# if SANITIZER_LINUX && \
138+
(defined(__x86_64__) || defined(__powerpc64__) || \
139+
SANITIZER_WORDSIZE == 64 || \
140+
(defined(__mips__) && defined(_ABIN32) && _MIPS_SIM == _ABIN32))
140141
# define SANITIZER_LINUX_USES_64BIT_SYSCALLS 1
141142
# else
142143
# define SANITIZER_LINUX_USES_64BIT_SYSCALLS 0
@@ -429,8 +430,9 @@ uptr internal_stat(const char *path, void *buf) {
429430
AT_NO_AUTOMOUNT, STATX_BASIC_STATS, (uptr)&bufx);
430431
statx_to_stat(&bufx, (struct stat *)buf);
431432
return res;
432-
# elif (SANITIZER_WORDSIZE == 64 || SANITIZER_X32 || \
433-
(defined(__mips__) && _MIPS_SIM == _ABIN32)) && \
433+
# elif ( \
434+
SANITIZER_WORDSIZE == 64 || SANITIZER_X32 || \
435+
(defined(__mips__) && defined(_ABIN32) && _MIPS_SIM == _ABIN32)) && \
434436
!SANITIZER_SPARC
435437
return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path, (uptr)buf,
436438
0);
@@ -467,8 +469,9 @@ uptr internal_lstat(const char *path, void *buf) {
467469
STATX_BASIC_STATS, (uptr)&bufx);
468470
statx_to_stat(&bufx, (struct stat *)buf);
469471
return res;
470-
# elif (defined(_LP64) || SANITIZER_X32 || \
471-
(defined(__mips__) && _MIPS_SIM == _ABIN32)) && \
472+
# elif ( \
473+
defined(_LP64) || SANITIZER_X32 || \
474+
(defined(__mips__) && defined(_ABIN32) && _MIPS_SIM == _ABIN32)) && \
472475
!SANITIZER_SPARC
473476
return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path, (uptr)buf,
474477
AT_SYMLINK_NOFOLLOW);

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,13 @@ const unsigned struct_kernel_stat64_sz = 104;
9898
const unsigned struct_kernel_stat_sz = 144;
9999
const unsigned struct_kernel_stat64_sz = 104;
100100
#elif defined(__mips__)
101-
const unsigned struct_kernel_stat_sz =
102-
SANITIZER_ANDROID
103-
? FIRST_32_SECOND_64(104, 128)
104-
: FIRST_32_SECOND_64((_MIPS_SIM == _ABIN32) ? 176 : 160, 216);
101+
const unsigned struct_kernel_stat_sz = SANITIZER_ANDROID
102+
? FIRST_32_SECOND_64(104, 128)
103+
# if defined(_ABIN32) && _MIPS_SIM == _ABIN32
104+
: FIRST_32_SECOND_64(176, 216);
105+
# else
106+
: FIRST_32_SECOND_64(160, 216);
107+
# endif
105108
const unsigned struct_kernel_stat64_sz = 104;
106109
#elif defined(__s390__) && !defined(__s390x__)
107110
const unsigned struct_kernel_stat_sz = 64;

0 commit comments

Comments
 (0)