Hi!

If a PCH file is built without -fsanitize=address and a TU doesn't contain
any functions, only file scope ctor, then we ICE because sanitizer builtins
aren't yet initialized.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk and 6.2 as obvious.

2016-07-21  Jakub Jelinek  <ja...@redhat.com>

        PR sanitizer/71953
        * asan.c (asan_dynamic_init_call): Call asan_init_shadow_ptr_types
        before builtin_decl_implicit.

--- gcc/asan.c.jj       2016-07-11 22:18:08.000000000 +0200
+++ gcc/asan.c  2016-07-21 10:37:28.869914949 +0200
@@ -2159,6 +2159,9 @@ transform_statements (void)
 tree
 asan_dynamic_init_call (bool after_p)
 {
+  if (shadow_ptr_types[0] == NULL_TREE)
+    asan_init_shadow_ptr_types ();
+
   tree fn = builtin_decl_implicit (after_p
                                   ? BUILT_IN_ASAN_AFTER_DYNAMIC_INIT
                                   : BUILT_IN_ASAN_BEFORE_DYNAMIC_INIT);
@@ -2168,8 +2171,6 @@ asan_dynamic_init_call (bool after_p)
       pretty_printer module_name_pp;
       pp_string (&module_name_pp, main_input_filename);
 
-      if (shadow_ptr_types[0] == NULL_TREE)
-       asan_init_shadow_ptr_types ();
       module_name_cst = asan_pp_string (&module_name_pp);
       module_name_cst = fold_convert (const_ptr_type_node,
                                      module_name_cst);

        Jakub

Reply via email to