Hi!

I've committed my last patch to unbreak aarch64 and powerpc* bootstrap
in a rush just after watching it passed bootstrap, not waiting for test
results.
Unfortunately, it seems the DECL_INITIAL (decl) = decl; hack wasn't used as
the comment suggested only by dw2_force_const_mem, but also by asan.c.
In that case forcing flag_section_anchors temporarily to 0 is too fragile,
so this patch instead reverts the varasm.c change (just provides a different
comment) and for good measure adds the DECL_INITIAL hack on the dw2 decl
after it is emitted (we still use the temporary flag_section_anchors = 0
on the assemble_variable, because at that point it really should have better
DECL_INITIAL to choose section right).

Bootstrapped/regtested on {x86_64,i686,powerpc64,powerpc64le}-linux,
bootstrapped on aarch64-linux (regtest still pending).
Ok for trunk?

2018-03-21  Jakub Jelinek  <ja...@redhat.com>

        PR sanitizer/85018
        * dwarf2asm.c (dw2_output_indirect_constant_1): Set
        DECL_INITIAL (decl) to decl at the end.
        * varasm.c (use_blocks_for_decl_p): Revert the 2018-03-20 change,
        adjust the comment.

--- gcc/dwarf2asm.c.jj  2018-03-20 14:00:19.863928902 +0100
+++ gcc/dwarf2asm.c     2018-03-21 11:52:13.523869188 +0100
@@ -982,6 +982,7 @@ dw2_output_indirect_constant_1 (const ch
   flag_section_anchors = save_flag_section_anchors;
   flag_sanitize = save_flag_sanitize;
   assemble_integer (sym_ref, POINTER_SIZE_UNITS, POINTER_SIZE, 1);
+  DECL_INITIAL (decl) = decl;
 
   return 0;
 }
--- gcc/varasm.c.jj     2018-03-20 14:00:20.278928898 +0100
+++ gcc/varasm.c        2018-03-21 11:51:01.838881084 +0100
@@ -1253,6 +1253,12 @@ use_blocks_for_decl_p (tree decl)
   if (!VAR_P (decl) && TREE_CODE (decl) != CONST_DECL)
     return false;
 
+  /* DECL_INITIAL (decl) set to decl is a hack used for some decls that
+     are never used from code directly and we never want object block handling
+     for those.  */
+  if (DECL_INITIAL (decl) == decl)
+    return false;
+
   /* If this decl is an alias, then we don't want to emit a
      definition.  */
   if (VAR_P (decl)

        Jakub

Reply via email to