1
# DP: Enable libsanitizer on ARM.
5
2013-06-20 Christophe Lyon <christophe.lyon@linaro.org>
7
Backport from trunk r198683.
8
2013-05-07 Christophe Lyon <christophe.lyon@linaro.org>
10
* configure.tgt: Add ARM pattern.
14
2013-06-20 Christophe Lyon <christophe.lyon@linaro.org>
16
Backport from trunk r198683.
17
2013-05-07 Christophe Lyon <christophe.lyon@linaro.org>
19
* config/arm/arm.c (arm_asan_shadow_offset): New function.
20
(TARGET_ASAN_SHADOW_OFFSET): Define.
21
* config/arm/linux-eabi.h (ASAN_CC1_SPEC): Define.
22
(LINUX_OR_ANDROID_CC): Add ASAN_CC1_SPEC.
26
2013-06-20 Christophe Lyon <christophe.lyon@linaro.org>
28
Backport from trunk r198683.
29
2013-05-07 Christophe Lyon <christophe.lyon@linaro.org>
31
* lib/target-supports.exp (check_effective_target_hw): New
33
* c-c++-common/asan/clone-test-1.c: Call
34
check_effective_target_hw.
35
* c-c++-common/asan/rlimit-mmap-test-1.c: Likewise.
36
* c-c++-common/asan/heap-overflow-1.c: Update regexps to accept
38
* c-c++-common/asan/null-deref-1.c: Likewise.
39
* c-c++-common/asan/stack-overflow-1.c: Likewise.
40
* c-c++-common/asan/strncpy-overflow-1.c: Likewise.
41
* c-c++-common/asan/use-after-free-1.c: Likewise.
42
* g++.dg/asan/deep-thread-stack-1.C: Likewise.
43
* g++.dg/asan/large-func-test-1.C: Likewise.
45
Index: b/src/libsanitizer/configure.tgt
46
===================================================================
47
--- a/src/libsanitizer/configure.tgt
48
+++ b/src/libsanitizer/configure.tgt
49
@@ -32,6 +32,8 @@ case "${target}" in
55
x86_64-*-darwin[1]* | i?86-*-darwin[1]*)
58
Index: b/src/gcc/testsuite/lib/target-supports.exp
59
===================================================================
60
--- a/src/gcc/testsuite/lib/target-supports.exp
61
+++ b/src/gcc/testsuite/lib/target-supports.exp
62
@@ -4711,6 +4711,33 @@ proc check_effective_target_simulator {
66
+# Return 1 if programs are intended to be run on hardware rather than
69
+proc check_effective_target_hw { } {
71
+ # All "src/sim" simulators set this one.
72
+ if [board_info target exists is_simulator] {
73
+ if [board_info target is_simulator] {
80
+ # The "sid" simulators don't set that one, but at least they set
82
+ if [board_info target exists slow_simulator] {
83
+ if [board_info target slow_simulator] {
93
# Return 1 if the target is a VxWorks kernel.
95
proc check_effective_target_vxworks_kernel { } {
96
Index: b/src/gcc/testsuite/g++.dg/asan/large-func-test-1.C
97
===================================================================
98
--- a/src/gcc/testsuite/g++.dg/asan/large-func-test-1.C
99
+++ b/src/gcc/testsuite/g++.dg/asan/large-func-test-1.C
100
@@ -37,9 +37,9 @@ int main() {
102
// { dg-output "ERROR: AddressSanitizer:? heap-buffer-overflow on address\[^\n\r]*" }
103
// { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" }
104
-// { dg-output "READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" }
105
+// { dg-output "\[^\n\r]*READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" }
106
// { dg-output " #0 0x\[0-9a-f\]+ (in \[^\n\r]*LargeFunction\[^\n\r]*(large-func-test-1.C:18|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" }
107
-// { dg-output "0x\[0-9a-f\]+ is located 44 bytes to the right of 400-byte region.*(\n|\r\n|\r)" }
108
-// { dg-output "allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" }
109
+// { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 44 bytes to the right of 400-byte region.*(\n|\r\n|\r)" }
110
+// { dg-output "\[^\n\r]*allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" }
111
// { dg-output " #0( 0x\[0-9a-f\]+ (in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" }
112
// { dg-output " #1|) 0x\[0-9a-f\]+ (in (operator new|_*_Zn\[aw\]\[mj\])|\[(\])\[^\n\r]*(\n|\r\n|\r)" }
113
Index: b/src/gcc/testsuite/g++.dg/asan/deep-thread-stack-1.C
114
===================================================================
115
--- a/src/gcc/testsuite/g++.dg/asan/deep-thread-stack-1.C
116
+++ b/src/gcc/testsuite/g++.dg/asan/deep-thread-stack-1.C
117
@@ -45,9 +45,9 @@ int main(int argc, char *argv[]) {
120
// { dg-output "ERROR: AddressSanitizer: heap-use-after-free.*(\n|\r\n|\r)" }
121
-// { dg-output "WRITE of size 4 at 0x\[0-9a-f\]+ thread T(\[0-9\]+).*(\n|\r\n|\r)" }
122
-// { dg-output "freed by thread T(\[0-9\]+) here:.*(\n|\r\n|\r)" }
123
-// { dg-output "previously allocated by thread T(\[0-9\]+) here:.*(\n|\r\n|\r)" }
124
+// { dg-output "\[^\n\r]*WRITE of size 4 at 0x\[0-9a-f\]+ thread T(\[0-9\]+).*(\n|\r\n|\r)" }
125
+// { dg-output "\[^\n\r]*freed by thread T(\[0-9\]+) here:.*(\n|\r\n|\r)" }
126
+// { dg-output "\[^\n\r]*previously allocated by thread T(\[0-9\]+) here:.*(\n|\r\n|\r)" }
127
// { dg-output "Thread T\\2 created by T(\[0-9\]+) here:.*(\n|\r\n|\r)" }
128
// { dg-output "Thread T\\8 created by T0 here:.*(\n|\r\n|\r)" }
129
// { dg-output "Thread T\\4 created by T(\[0-9\]+) here:.*(\n|\r\n|\r)" }
130
Index: b/src/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
131
===================================================================
132
--- a/src/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
133
+++ b/src/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
134
@@ -15,7 +15,7 @@ int main(int argc, char **argv) {
135
/* { dg-output "WRITE of size \[0-9\]* at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */
136
/* { dg-output " #0 0x\[0-9a-f\]+ (in _*(interceptor_|)strncpy|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
137
/* { dg-output " #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*strncpy-overflow-1.c:11|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
138
-/* { dg-output "0x\[0-9a-f\]+ is located 0 bytes to the right of 9-byte region\[^\n\r]*(\n|\r\n|\r)" } */
139
-/* { dg-output "allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
140
+/* { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 0 bytes to the right of 9-byte region\[^\n\r]*(\n|\r\n|\r)" } */
141
+/* { dg-output "\[^\n\r]*allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
142
/* { dg-output " #0 0x\[0-9a-f\]+ (in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
143
/* { dg-output " #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*strncpy-overflow-1.c:10|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
144
Index: b/src/gcc/testsuite/c-c++-common/asan/rlimit-mmap-test-1.c
145
===================================================================
146
--- a/src/gcc/testsuite/c-c++-common/asan/rlimit-mmap-test-1.c
147
+++ b/src/gcc/testsuite/c-c++-common/asan/rlimit-mmap-test-1.c
150
/* { dg-do run { target setrlimit } } */
151
/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
152
+/* { dg-require-effective-target hw } */
153
/* { dg-shouldfail "asan" } */
156
Index: b/src/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c
157
===================================================================
158
--- a/src/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c
159
+++ b/src/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c
160
@@ -19,4 +19,4 @@ int main() {
162
/* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */
163
/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*stack-overflow-1.c:16|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
164
-/* { dg-output "Address 0x\[0-9a-f\]+ is\[^\n\r]*frame <main>" } */
165
+/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is\[^\n\r]*frame <main>" } */
166
Index: b/src/gcc/testsuite/c-c++-common/asan/use-after-free-1.c
167
===================================================================
168
--- a/src/gcc/testsuite/c-c++-common/asan/use-after-free-1.c
169
+++ b/src/gcc/testsuite/c-c++-common/asan/use-after-free-1.c
170
@@ -11,12 +11,12 @@ int main() {
172
/* { dg-output "ERROR: AddressSanitizer:? heap-use-after-free on address\[^\n\r]*" } */
173
/* { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */
174
-/* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */
175
+/* { dg-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */
176
/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*use-after-free-1.c:9|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
177
-/* { dg-output "0x\[0-9a-f\]+ is located 5 bytes inside of 10-byte region .0x\[0-9a-f\]+,0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */
178
-/* { dg-output "freed by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
179
+/* { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 5 bytes inside of 10-byte region .0x\[0-9a-f\]+,0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */
180
+/* { dg-output "\[^\n\r]*freed by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
181
/* { dg-output " #0 0x\[0-9a-f\]+ (in _*(interceptor_|)free|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
182
/* { dg-output " #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*use-after-free-1.c:8|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
183
-/* { dg-output "previously allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
184
+/* { dg-output "\[^\n\r]*previously allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
185
/* { dg-output " #0 0x\[0-9a-f\]+ (in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
186
/* { dg-output " #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*use-after-free-1.c:7|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
187
Index: b/src/gcc/testsuite/c-c++-common/asan/clone-test-1.c
188
===================================================================
189
--- a/src/gcc/testsuite/c-c++-common/asan/clone-test-1.c
190
+++ b/src/gcc/testsuite/c-c++-common/asan/clone-test-1.c
193
/* { dg-do run { target { *-*-linux* } } } */
194
/* { dg-require-effective-target clone } */
195
+/* { dg-require-effective-target hw } */
196
/* { dg-options "-D_GNU_SOURCE" } */
199
Index: b/src/gcc/testsuite/c-c++-common/asan/heap-overflow-1.c
200
===================================================================
201
--- a/src/gcc/testsuite/c-c++-common/asan/heap-overflow-1.c
202
+++ b/src/gcc/testsuite/c-c++-common/asan/heap-overflow-1.c
203
@@ -25,7 +25,7 @@ int main(int argc, char **argv) {
205
/* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0.*(\n|\r\n|\r)" } */
206
/* { dg-output " #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*heap-overflow-1.c:21|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
207
-/* { dg-output "0x\[0-9a-f\]+ is located 0 bytes to the right of 10-byte region\[^\n\r]*(\n|\r\n|\r)" } */
208
-/* { dg-output "allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
209
+/* { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 0 bytes to the right of 10-byte region\[^\n\r]*(\n|\r\n|\r)" } */
210
+/* { dg-output "\[^\n\r]*allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
211
/* { dg-output " #0 0x\[0-9a-f\]+ (in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
212
/* { dg-output " #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*heap-overflow-1.c:19|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
213
Index: b/src/gcc/testsuite/c-c++-common/asan/null-deref-1.c
214
===================================================================
215
--- a/src/gcc/testsuite/c-c++-common/asan/null-deref-1.c
216
+++ b/src/gcc/testsuite/c-c++-common/asan/null-deref-1.c
217
@@ -18,6 +18,6 @@ int main()
219
/* { dg-output "ERROR: AddressSanitizer:? SEGV on unknown address\[^\n\r]*" } */
220
/* { dg-output "0x\[0-9a-f\]+ \[^\n\r]*pc 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */
221
-/* { dg-output "AddressSanitizer can not provide additional info.*(\n|\r\n|\r)" } */
222
+/* { dg-output "\[^\n\r]*AddressSanitizer can not provide additional info.*(\n|\r\n|\r)" } */
223
/* { dg-output " #0 0x\[0-9a-f\]+ (in \[^\n\r]*NullDeref\[^\n\r]* (\[^\n\r]*null-deref-1.c:10|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
224
/* { dg-output " #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*null-deref-1.c:15|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
225
Index: b/src/gcc/config/arm/arm.c
226
===================================================================
227
--- a/src/gcc/config/arm/arm.c
228
+++ b/src/gcc/config/arm/arm.c
229
@@ -279,6 +279,7 @@ static unsigned arm_add_stmt_cost (void
231
static void arm_canonicalize_comparison (int *code, rtx *op0, rtx *op1,
232
bool op0_preserve_value);
233
+static unsigned HOST_WIDE_INT arm_asan_shadow_offset (void);
235
/* Table of machine attributes. */
236
static const struct attribute_spec arm_attribute_table[] =
237
@@ -648,6 +649,9 @@ static const struct attribute_spec arm_a
238
#define TARGET_CANONICALIZE_COMPARISON \
239
arm_canonicalize_comparison
241
+#undef TARGET_ASAN_SHADOW_OFFSET
242
+#define TARGET_ASAN_SHADOW_OFFSET arm_asan_shadow_offset
244
struct gcc_target targetm = TARGET_INITIALIZER;
246
/* Obstack for minipool constant handling. */
247
@@ -27462,4 +27466,12 @@ arm_validize_comparison (rtx *comparison
251
+/* Implement the TARGET_ASAN_SHADOW_OFFSET hook. */
253
+static unsigned HOST_WIDE_INT
254
+arm_asan_shadow_offset (void)
256
+ return (unsigned HOST_WIDE_INT) 1 << 29;
260
Index: b/src/gcc/config/arm/linux-eabi.h
261
===================================================================
262
--- a/src/gcc/config/arm/linux-eabi.h
263
+++ b/src/gcc/config/arm/linux-eabi.h
265
LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \
266
LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
268
+#undef ASAN_CC1_SPEC
269
+#define ASAN_CC1_SPEC "%{fsanitize=*:-funwind-tables}"
273
- LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
274
- GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
275
+ LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC " " ASAN_CC1_SPEC, \
276
+ GNU_USER_TARGET_CC1_SPEC " " ASAN_CC1_SPEC " " \
279
#define CC1PLUS_SPEC \
280
LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC)