summaryrefslogblamecommitdiff
path: root/system/gcc/sanitation.patch
blob: 861f5d08eb8e106d24367d6fb951f2c992ff0305 (plain) (tree)








































































                                                                                                           
                       


                                               



                                                

                                             
       

                                                                    


                                                 
                                             
       























































                                                                                                                                   
--- gcc-13.3.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp.old	2024-05-21 07:47:42.000000000 +0000
+++ gcc-13.3.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp	2024-06-20 23:28:49.290053800 +0000
@@ -82,6 +82,10 @@
 #  include <sys/sysmacros.h>
 #endif
 
+#if SANITIZER_LINUX && defined(__powerpc__)
+#  include <asm/ptrace.h>
+#endif
+
 #if SANITIZER_FREEBSD
 #include <sys/exec.h>
 #include <sys/procctl.h>
@@ -277,7 +281,7 @@
   return res;
 }
 
-#if (!SANITIZER_LINUX_USES_64BIT_SYSCALLS || SANITIZER_SPARC) && SANITIZER_LINUX
+#if (!SANITIZER_LINUX_USES_64BIT_SYSCALLS || SANITIZER_SPARC) && SANITIZER_LINUX && defined(__glibc__)
 static void stat64_to_stat(struct stat64 *in, struct stat *out) {
   internal_memset(out, 0, sizeof(*out));
   out->st_dev = in->st_dev;
@@ -384,11 +388,8 @@
   return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path, (uptr)buf,
                           0);
 #    else
-  struct stat64 buf64;
-  int res = internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path,
-                             (uptr)&buf64, 0);
-  stat64_to_stat(&buf64, (struct stat *)buf);
-  return res;
+  return internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path, (uptr)buf,
+                          0);
 #    endif
 #  else
   struct stat64 buf64;
@@ -416,11 +417,8 @@
   return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path, (uptr)buf,
                           AT_SYMLINK_NOFOLLOW);
 #    else
-  struct stat64 buf64;
-  int res = internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path,
-                             (uptr)&buf64, AT_SYMLINK_NOFOLLOW);
-  stat64_to_stat(&buf64, (struct stat *)buf);
-  return res;
+  return internal_syscall(SYSCALL(fstatat64), AT_FDCWD, (uptr)path, (uptr)buf,
+                          AT_SYMLINK_NOFOLLOW);
 #    endif
 #  else
   struct stat64 buf64;
@@ -448,10 +446,7 @@
   return internal_syscall(SYSCALL(fstat), fd, (uptr)buf);
 #      endif
 #else
-  struct stat64 buf64;
-  int res = internal_syscall(SYSCALL(fstat64), fd, &buf64);
-  stat64_to_stat(&buf64, (struct stat *)buf);
-  return res;
+  return internal_syscall(SYSCALL(fstat64), fd, (uptr)buf);
 #endif
 }
 
@@ -871,7 +866,9 @@
 #endif
 
 #if SANITIZER_LINUX
-#define SA_RESTORER 0x04000000
+#  ifndef SA_RESTORER
+#    define SA_RESTORER 0x04000000
+#  endif
 // Doesn't set sa_restorer if the caller did not set it, so use with caution
 //(see below).
 int internal_sigaction_norestorer(int signum, const void *act, void *oldact) {
@@ -2173,11 +2170,20 @@
   *bp = ucontext->uc_mcontext.mc_frame[31];
 #    else
   ucontext_t *ucontext = (ucontext_t*)context;
+#ifdef __powerpc64__
   *pc = ucontext->uc_mcontext.regs->nip;
   *sp = ucontext->uc_mcontext.regs->gpr[PT_R1];
+#else
+  *pc = ucontext->uc_mcontext.gregs[PT_NIP];
+  *sp = ucontext->uc_mcontext.gregs[PT_R1];
+#endif
   // The powerpc{,64}-linux ABIs do not specify r31 as the frame
   // pointer, but GCC always uses r31 when we need a frame pointer.
+#ifdef __powerpc64__
   *bp = ucontext->uc_mcontext.regs->gpr[PT_R31];
+#else
+  *bp = ucontext->uc_mcontext.gregs[PT_R31];
+#endif
 #    endif
 #elif defined(__sparc__)
 #if defined(__arch64__) || defined(__sparcv9)
--- gcc-13.3.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp.old	2024-06-20 14:03:27.437916098 -0500
+++ gcc-13.3.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp	2024-07-09 03:28:44.101087267 -0500
@@ -51,7 +51,7 @@
 #include <time.h>
 #include <wchar.h>
 #include <regex.h>
-#if !SANITIZER_APPLE
+#if HAVE_UTMP_H
 #include <utmp.h>
 #endif
 
@@ -62,7 +62,6 @@
 #if !SANITIZER_ANDROID
 #include <sys/mount.h>
 #include <sys/timeb.h>
-#include <utmpx.h>
 #endif
 
 #if SANITIZER_LINUX
@@ -94,7 +93,7 @@
 # include <utime.h>
 # include <sys/ptrace.h>
 #    if defined(__mips64) || defined(__aarch64__) || defined(__arm__) || \
-        defined(__hexagon__) || SANITIZER_RISCV64
+        defined(__hexagon__) || defined(__powerpc__) || SANITIZER_RISCV64
 #      include <asm/ptrace.h>
 #      ifdef __arm__
 typedef struct user_fpregs elf_fpregset_t;
@@ -313,11 +312,11 @@
   int shmctl_shm_stat = (int)SHM_STAT;
 #endif
 
-#if !SANITIZER_APPLE && !SANITIZER_FREEBSD
+#if HAVE_UTMP_H
   unsigned struct_utmp_sz = sizeof(struct utmp);
 #endif
 #if !SANITIZER_ANDROID
-  unsigned struct_utmpx_sz = sizeof(struct utmpx);
+  unsigned struct_utmpx_sz = 400;
 #endif
 
   int map_fixed = MAP_FIXED;
--- gcc-13.3.0/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp.old	2024-05-21 02:47:42.000000000 -0500
+++ gcc-13.3.0/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp	2024-06-20 16:23:27.115377319 -0500
@@ -31,7 +31,7 @@
 #include <sys/types.h> // for pid_t
 #include <sys/uio.h> // for iovec
 #include <elf.h> // for NT_PRSTATUS
-#if (defined(__aarch64__) || SANITIZER_RISCV64) && !SANITIZER_ANDROID
+#if (defined(__aarch64__) || defined(__powerpc__) || SANITIZER_RISCV64) && !SANITIZER_ANDROID
 // GLIBC 2.20+ sys/user does not include asm/ptrace.h
 # include <asm/ptrace.h>
 #endif