On March 19, 2018 9:01:53 PM GMT+01:00, Jakub Jelinek <ja...@redhat.com> wrote: >Hi! > >When Maxim posted his patch today, I had a look and found that we emit >these indirect constants into .data sections, even when they always >contain >just some pointer that needs relocation, but shouldn't be changed >afterwards; after all, the indirect constants have TREE_READONLY set. > >The problem is that we use DECL_INITIAL (decl) = decl; and that isn't >something the section selection code recognizes as valid or reasonable >initializer. This patch uses ADDR_EXPR of the decl instead, i.e. >something >that needs a relocation if -fpic/-fpie, but can be relro, and in >position >dependent binaries can be .rodata from the beginning. This will make >it >harder from somebody trying to change these. > >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK. Richard. >2018-03-19 Jakub Jelinek <ja...@redhat.com> > > PR sanitizer/78651 > * dwarf2asm.c: Include fold-const.c. > (dw2_output_indirect_constant_1): Set DECL_INITIAL (decl) to ADDR_EXPR > of decl rather than decl itself. > >--- gcc/dwarf2asm.c.jj 2018-02-09 06:44:29.952809199 +0100 >+++ gcc/dwarf2asm.c 2018-03-19 17:18:09.824000048 +0100 >@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. > #include "dwarf2.h" > #include "function.h" > #include "emit-rtl.h" >+#include "fold-const.h" > > #ifndef XCOFF_DEBUGGING_INFO > #define XCOFF_DEBUGGING_INFO 0 >@@ -954,7 +955,7 @@ dw2_output_indirect_constant_1 (const ch > SET_DECL_ASSEMBLER_NAME (decl, id); > DECL_ARTIFICIAL (decl) = 1; > DECL_IGNORED_P (decl) = 1; >- DECL_INITIAL (decl) = decl; >+ DECL_INITIAL (decl) = build_fold_addr_expr (decl); > TREE_READONLY (decl) = 1; > TREE_STATIC (decl) = 1; > > > Jakub