diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-10-05 21:04:39 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-10-05 21:04:39 +0200 |
commit | 2e69f143e34f5c82caf1072f5a34784237b9f0a2 (patch) | |
tree | 95ac17961ff15889a5a6b03662531a2b2ece6b74 /gcc | |
parent | 875825211ba723311fa12b2c8aaa7c808bfa972f (diff) | |
download | gcc-2e69f143e34f5c82caf1072f5a34784237b9f0a2.zip gcc-2e69f143e34f5c82caf1072f5a34784237b9f0a2.tar.gz gcc-2e69f143e34f5c82caf1072f5a34784237b9f0a2.tar.bz2 |
re PR sanitizer/66343 ("Error: .Lubsan_type3 already defined" with UBSan and precompiled headers)
PR sanitizer/66343
* ubsan.c (ubsan_create_data): Call initialize_sanitizer_builtins here.
(ubsan_instrument_float_cast): And not here.
* c-ubsan.c (ubsan_instrument_return): Don't call
initialize_sanitizer_builtins here.
* gcc.dg/pch/pr66343-3.c: New test.
* gcc.dg/pch/pr66343-3.hs: New file.
From-SVN: r240804
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-ubsan.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pch/pr66343-3.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pch/pr66343-3.hs | 4 | ||||
-rw-r--r-- | gcc/ubsan.c | 5 |
7 files changed, 37 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8f7eb38..9be5e48 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,10 @@ 2016-10-05 Jakub Jelinek <jakub@redhat.com> PR sanitizer/66343 + * ubsan.c (ubsan_create_data): Call initialize_sanitizer_builtins here. + (ubsan_instrument_float_cast): And not here. + + PR sanitizer/66343 * ubsan.c (ubsan_ids): New GTY(()) array. (ubsan_type_descriptor, ubsan_create_data): Use ubsan_ids instead of static local counters. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 2bfce86..6474a6d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2016-10-05 Jakub Jelinek <jakub@redhat.com> + + PR sanitizer/66343 + * c-ubsan.c (ubsan_instrument_return): Don't call + initialize_sanitizer_builtins here. + 2016-10-05 Bernd Edlinger <bernd.edlinger@hotmail.de> * c-common.c (c_common_truthvalue_conversion): Warn also for suspicious diff --git a/gcc/c-family/c-ubsan.c b/gcc/c-family/c-ubsan.c index df7b932..482cce1 100644 --- a/gcc/c-family/c-ubsan.c +++ b/gcc/c-family/c-ubsan.c @@ -235,9 +235,6 @@ ubsan_instrument_return (location_t loc) { if (flag_sanitize_undefined_trap_on_error) return build_call_expr_loc (loc, builtin_decl_explicit (BUILT_IN_TRAP), 0); - /* It is possible that PCH zapped table with definitions of sanitizer - builtins. Reinitialize them if needed. */ - initialize_sanitizer_builtins (); tree data = ubsan_create_data ("__ubsan_missing_return_data", 1, &loc, NULL_TREE, NULL_TREE); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fabe4c8..8a7e21e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,10 @@ 2016-10-05 Jakub Jelinek <jakub@redhat.com> PR sanitizer/66343 + * gcc.dg/pch/pr66343-3.c: New test. + * gcc.dg/pch/pr66343-3.hs: New file. + + PR sanitizer/66343 * gcc.dg/pch/pr66343-1.c: New test. * gcc.dg/pch/pr66343-1.hs: New file. * gcc.dg/pch/pr66343-2.c: New test. diff --git a/gcc/testsuite/gcc.dg/pch/pr66343-3.c b/gcc/testsuite/gcc.dg/pch/pr66343-3.c new file mode 100644 index 0000000..67186e2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/pr66343-3.c @@ -0,0 +1,15 @@ +/* PR sanitizer/66343 */ +/* { dg-do assemble } */ +/* { dg-options "-fsanitize=undefined" } */ + +#include "pr66343-3.h" + +void +bar (int a, int b) +{ + a / b; +} + +/* Hack to turn off PCH assembly comparison, as it is incompatible + with dg-do assemble. The target condition will be always false. */ +/* { dg-error "" "" { target { lp64 && { ! lp64 } } } } */ diff --git a/gcc/testsuite/gcc.dg/pch/pr66343-3.hs b/gcc/testsuite/gcc.dg/pch/pr66343-3.hs new file mode 100644 index 0000000..2f86a02 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/pr66343-3.hs @@ -0,0 +1,4 @@ +/* PR sanitizer/66343 */ +/* { dg-options "-fno-sanitize=undefined" } */ + +/* Empty. */ diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 059c6aa..8818de4 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -511,6 +511,10 @@ ubsan_create_data (const char *name, int loccnt, const location_t *ploc, ...) size_t i = 0; int j; + /* It is possible that PCH zapped table with definitions of sanitizer + builtins. Reinitialize them if needed. */ + initialize_sanitizer_builtins (); + /* Firstly, create a pointer to type descriptor type. */ tree td_type = ubsan_get_type_descriptor_type (); td_type = build_pointer_type (td_type); @@ -1589,7 +1593,6 @@ ubsan_instrument_float_cast (location_t loc, tree type, tree expr) { location_t *loc_ptr = NULL; unsigned num_locations = 0; - initialize_sanitizer_builtins (); /* Figure out if we can propagate location to ubsan_data and use new style handlers in libubsan. */ if (ubsan_use_new_style_p (loc)) |