Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gcc/dist/gcc put joerg's varasm.c patch back w...



details:   https://anonhg.NetBSD.org/src/rev/9b44198f4a88
branches:  trunk
changeset: 996948:9b44198f4a88
user:      mrg <mrg%NetBSD.org@localhost>
date:      Thu Feb 14 10:29:58 2019 +0000

description:
put joerg's varasm.c patch back with additional upstream fixes.  now
crtbegin.o has a read-only .eh_frame, and libstdc++ builds.


2017-09-01  Joerg Sonnenberger  <joerg%bec.de@localhost>
            Jeff Law  <law%redhat.com@localhost>

        * varasm.c (bss_initializer_p): Do not put constants into .bss
        (categorize_decl_for_section): Handle bss_initializer_p returning
        false when DECL_INITIAL is NULL.

2017-11-27  Jakub Jelinek  <jakub%redhat.com@localhost>

        PR target/83100
        * varasm.c (bss_initializer_p): Return true for DECL_COMMON
        TREE_READONLY decls.

2018-02-09  Jakub Jelinek  <jakub%redhat.com@localhost>

        PR middle-end/84237
        * output.h (bss_initializer_p): Add NAMED argument, defaulted to false.
        * varasm.c (bss_initializer_p): Add NAMED argument, if true, ignore
        TREE_READONLY bit.
        (get_variable_section): For decls in named .bss* sections pass true as
        second argument to bss_initializer_p.

diffstat:

 external/gpl3/gcc/dist/gcc/output.h |   2 +-
 external/gpl3/gcc/dist/gcc/varasm.c |  33 ++++++++++++++++++---------------
 2 files changed, 19 insertions(+), 16 deletions(-)

diffs (76 lines):

diff -r 8635c8321b58 -r 9b44198f4a88 external/gpl3/gcc/dist/gcc/output.h
--- a/external/gpl3/gcc/dist/gcc/output.h       Thu Feb 14 09:37:31 2019 +0000
+++ b/external/gpl3/gcc/dist/gcc/output.h       Thu Feb 14 10:29:58 2019 +0000
@@ -556,7 +556,7 @@
 extern unsigned int default_section_type_flags (tree, const char *, int);
 
 extern bool have_global_bss_p (void);
-extern bool bss_initializer_p (const_tree);
+extern bool bss_initializer_p (const_tree, bool = false);
 
 extern void default_no_named_section (const char *, unsigned int, tree);
 extern void default_elf_asm_named_section (const char *, unsigned int, tree);
diff -r 8635c8321b58 -r 9b44198f4a88 external/gpl3/gcc/dist/gcc/varasm.c
--- a/external/gpl3/gcc/dist/gcc/varasm.c       Thu Feb 14 09:37:31 2019 +0000
+++ b/external/gpl3/gcc/dist/gcc/varasm.c       Thu Feb 14 10:29:58 2019 +0000
@@ -972,18 +972,18 @@
 /* Return true if DECL's initializer is suitable for a BSS section.  */
 
 bool
-bss_initializer_p (const_tree decl)
-{
-  return (DECL_INITIAL (decl) == NULL
-         /* In LTO we have no errors in program; error_mark_node is used
-            to mark offlined constructors.  */
-         || (DECL_INITIAL (decl) == error_mark_node
-             && !in_lto_p)
-         || (flag_zero_initialized_in_bss
-             /* Leave constant zeroes in .rodata so they
-                can be shared.  */
-             && !TREE_READONLY (decl)
-             && initializer_zerop (DECL_INITIAL (decl))));
+bss_initializer_p (const_tree decl, bool named)
+{
+  /* Do not put non-common constants into the .bss section, they belong in
+     a readonly section, except when NAMED is true.  */
+  return ((!TREE_READONLY (decl) || DECL_COMMON (decl) || named)
+         && (DECL_INITIAL (decl) == NULL
+             /* In LTO we have no errors in program; error_mark_node is used
+                to mark offlined constructors.  */
+             || (DECL_INITIAL (decl) == error_mark_node
+                 && !in_lto_p)
+             || (flag_zero_initialized_in_bss
+                 && initializer_zerop (DECL_INITIAL (decl)))));
 }
 
 /* Compute the alignment of variable specified by DECL.
@@ -1154,7 +1154,8 @@
     {
       section *sect = get_named_section (decl, NULL, reloc);
 
-      if ((sect->common.flags & SECTION_BSS) && !bss_initializer_p (decl))
+      if ((sect->common.flags & SECTION_BSS)
+         && !bss_initializer_p (decl, true))
        {
          error_at (DECL_SOURCE_LOCATION (decl),
                    "only zero initializers are allowed in section %qs",
@@ -6465,7 +6466,8 @@
        ret = SECCAT_BSS;
       else if (! TREE_READONLY (decl)
               || TREE_SIDE_EFFECTS (decl)
-              || ! TREE_CONSTANT (DECL_INITIAL (decl)))
+              || (DECL_INITIAL (decl)
+                  && ! TREE_CONSTANT (DECL_INITIAL (decl))))
        {
          /* Here the reloc_rw_mask is not testing whether the section should
             be read-only or not, but whether the dynamic link will have to
@@ -6485,7 +6487,8 @@
           location.  -fmerge-all-constants allows even that (at the
           expense of not conforming).  */
        ret = SECCAT_RODATA;
-      else if (TREE_CODE (DECL_INITIAL (decl)) == STRING_CST)
+      else if (DECL_INITIAL (decl)
+              && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST)
        ret = SECCAT_RODATA_MERGE_STR_INIT;
       else
        ret = SECCAT_RODATA_MERGE_CONST;



Home | Main Index | Thread Index | Old Index