Skip to content

Commit 801b519

Browse files
authored
[sanitizer_common] Fix build on ppc64+musl (#120036)
In powerpc64-unknown-linux-musl, signal.h does not include asm/ptrace.h, which causes "member access into incomplete type 'struct pt_regs'" errors. Include the header explicitly to fix this. Also in sanitizer_linux_libcdep.cpp, there is a usage of TlsPreTcbSize which is not defined in such a platform. Guard the branch with macro.
1 parent e4a79b7 commit 801b519

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ extern "C" SANITIZER_WEAK_ATTRIBUTE const char *strerrorname_np(int);
9292
# include <sys/sysmacros.h>
9393
# endif
9494

95+
# if SANITIZER_LINUX && defined(__powerpc64__)
96+
# include <asm/ptrace.h>
97+
# endif
98+
9599
# if SANITIZER_FREEBSD
96100
# include <machine/atomic.h>
97101
# include <sys/exec.h>

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -611,21 +611,22 @@ static void GetTls(uptr *addr, uptr *size) {
611611
*addr = tp - RoundUpTo(*size, align);
612612
*size = tp - *addr + ThreadDescriptorSize();
613613
# else
614-
if (SANITIZER_GLIBC)
615-
*size += 1664;
616-
else if (SANITIZER_FREEBSD)
617-
*size += 128; // RTLD_STATIC_TLS_EXTRA
618-
# if defined(__mips__) || defined(__powerpc64__) || SANITIZER_RISCV64
614+
# if SANITIZER_GLIBC
615+
*size += 1664;
616+
# elif SANITIZER_FREEBSD
617+
*size += 128; // RTLD_STATIC_TLS_EXTRA
618+
# if defined(__mips__) || defined(__powerpc64__) || SANITIZER_RISCV64
619619
const uptr pre_tcb_size = TlsPreTcbSize();
620620
*addr -= pre_tcb_size;
621621
*size += pre_tcb_size;
622-
# else
622+
# else
623623
// arm and aarch64 reserve two words at TP, so this underestimates the range.
624624
// However, this is sufficient for the purpose of finding the pointers to
625625
// thread-specific data keys.
626626
const uptr tcb_size = ThreadDescriptorSize();
627627
*addr -= tcb_size;
628628
*size += tcb_size;
629+
# endif
629630
# endif
630631
# endif
631632
# elif SANITIZER_NETBSD

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
# include <sys/ptrace.h>
9797
# if defined(__mips64) || defined(__aarch64__) || defined(__arm__) || \
9898
defined(__hexagon__) || defined(__loongarch__) || SANITIZER_RISCV64 || \
99-
defined(__sparc__)
99+
defined(__sparc__) || defined(__powerpc64__)
100100
# include <asm/ptrace.h>
101101
# ifdef __arm__
102102
typedef struct user_fpregs elf_fpregset_t;

compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
#include <sys/types.h> // for pid_t
3232
#include <sys/uio.h> // for iovec
3333
#include <elf.h> // for NT_PRSTATUS
34-
#if (defined(__aarch64__) || SANITIZER_RISCV64 || SANITIZER_LOONGARCH64) && \
34+
#if (defined(__aarch64__) || defined(__powerpc64__) || \
35+
SANITIZER_RISCV64 || SANITIZER_LOONGARCH64) && \
3536
!SANITIZER_ANDROID
3637
// GLIBC 2.20+ sys/user does not include asm/ptrace.h
3738
# include <asm/ptrace.h>

0 commit comments

Comments
 (0)