From: Jakub Jelinek Date: Wed, 5 Oct 2016 19:04:39 +0000 (+0200) Subject: re PR sanitizer/66343 ("Error: .Lubsan_type3 already defined" with UBSan and precompi... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2e69f143e34f5c82caf1072f5a34784237b9f0a2;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8f7eb38f21e..9be5e48c567 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2016-10-05 Jakub Jelinek + 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 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 2bfce86c443..6474a6dd6f6 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2016-10-05 Jakub Jelinek + + PR sanitizer/66343 + * c-ubsan.c (ubsan_instrument_return): Don't call + initialize_sanitizer_builtins here. + 2016-10-05 Bernd Edlinger * 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 df7b9328d4c..482cce19f3c 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 fabe4c8db82..8a7e21e98d5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2016-10-05 Jakub Jelinek + 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. 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 00000000000..67186e2e77f --- /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 00000000000..2f86a02ec76 --- /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 059c6aa4a93..8818de4f372 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))