summaryrefslogtreecommitdiff
path: root/system/gcc/401-libsanitizer-linux.patch
blob: 8a662a2685993d02912c84445b7a7e8a15107fe2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
--- gcc-8.3.0/libsanitizer/sanitizer_common/sanitizer_linux.cc.old	2017-10-19 11:23:59.000000000 +0000
+++ gcc-8.3.0/libsanitizer/sanitizer_common/sanitizer_linux.cc	2019-06-27 05:39:48.258332316 +0000
@@ -752,7 +752,9 @@
 }
 
 #if SANITIZER_LINUX
+#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) {
@@ -1687,65 +1689,59 @@
 }
 
 static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
-#if defined(__arm__)
   ucontext_t *ucontext = (ucontext_t*)context;
+#if defined(__arm__)
   *pc = ucontext->uc_mcontext.arm_pc;
   *bp = ucontext->uc_mcontext.arm_fp;
   *sp = ucontext->uc_mcontext.arm_sp;
 #elif defined(__aarch64__)
-  ucontext_t *ucontext = (ucontext_t*)context;
   *pc = ucontext->uc_mcontext.pc;
   *bp = ucontext->uc_mcontext.regs[29];
   *sp = ucontext->uc_mcontext.sp;
 #elif defined(__hppa__)
-  ucontext_t *ucontext = (ucontext_t*)context;
   *pc = ucontext->uc_mcontext.sc_iaoq[0];
   /* GCC uses %r3 whenever a frame pointer is needed.  */
   *bp = ucontext->uc_mcontext.sc_gr[3];
   *sp = ucontext->uc_mcontext.sc_gr[30];
 #elif defined(__x86_64__)
 # if SANITIZER_FREEBSD
-  ucontext_t *ucontext = (ucontext_t*)context;
   *pc = ucontext->uc_mcontext.mc_rip;
   *bp = ucontext->uc_mcontext.mc_rbp;
   *sp = ucontext->uc_mcontext.mc_rsp;
 #elif SANITIZER_NETBSD
-  ucontext_t *ucontext = (ucontext_t *)context;
   *pc = ucontext->uc_mcontext.__gregs[_REG_RIP];
   *bp = ucontext->uc_mcontext.__gregs[_REG_RBP];
   *sp = ucontext->uc_mcontext.__gregs[_REG_RSP];
 # else
-  ucontext_t *ucontext = (ucontext_t*)context;
   *pc = ucontext->uc_mcontext.gregs[REG_RIP];
   *bp = ucontext->uc_mcontext.gregs[REG_RBP];
   *sp = ucontext->uc_mcontext.gregs[REG_RSP];
 # endif
 #elif defined(__i386__)
 # if SANITIZER_FREEBSD
-  ucontext_t *ucontext = (ucontext_t*)context;
   *pc = ucontext->uc_mcontext.mc_eip;
   *bp = ucontext->uc_mcontext.mc_ebp;
   *sp = ucontext->uc_mcontext.mc_esp;
 #elif SANITIZER_NETBSD
-  ucontext_t *ucontext = (ucontext_t *)context;
   *pc = ucontext->uc_mcontext.__gregs[_REG_EIP];
   *bp = ucontext->uc_mcontext.__gregs[_REG_EBP];
   *sp = ucontext->uc_mcontext.__gregs[_REG_ESP];
 # else
-  ucontext_t *ucontext = (ucontext_t*)context;
   *pc = ucontext->uc_mcontext.gregs[REG_EIP];
   *bp = ucontext->uc_mcontext.gregs[REG_EBP];
   *sp = ucontext->uc_mcontext.gregs[REG_ESP];
 # endif
-#elif defined(__powerpc__) || defined(__powerpc64__)
-  ucontext_t *ucontext = (ucontext_t*)context;
-  *pc = ucontext->uc_mcontext.regs->nip;
-  *sp = ucontext->uc_mcontext.regs->gpr[PT_R1];
+#elif defined(__powerpc64__)
+  *pc = ucontext->uc_mcontext.gp_regs[32];
+  *sp = ucontext->uc_mcontext.gp_regs[1];
+  *bp = ucontext->uc_mcontext.gp_regs[31];
+#elif defined(__powerpc__)
+  *pc = ucontext->uc_mcontext.gregs[32];
+  *sp = ucontext->uc_mcontext.gregs[1];
   // The powerpc{,64}-linux ABIs do not specify r31 as the frame
   // pointer, but GCC always uses r31 when we need a frame pointer.
-  *bp = ucontext->uc_mcontext.regs->gpr[PT_R31];
+  *bp = ucontext->uc_mcontext.gregs[31];
 #elif defined(__sparc__)
-  ucontext_t *ucontext = (ucontext_t*)context;
   uptr *stk_ptr;
 # if defined (__arch64__)
   *pc = ucontext->uc_mcontext.mc_gregs[MC_PC];
@@ -1759,12 +1755,10 @@
   *bp = stk_ptr[15];
 # endif
 #elif defined(__mips__)
-  ucontext_t *ucontext = (ucontext_t*)context;
   *pc = ucontext->uc_mcontext.pc;
   *bp = ucontext->uc_mcontext.gregs[30];
   *sp = ucontext->uc_mcontext.gregs[29];
 #elif defined(__s390__)
-  ucontext_t *ucontext = (ucontext_t*)context;
 # if defined(__s390x__)
   *pc = ucontext->uc_mcontext.psw.addr;
 # else