Module Name:    src
Committed By:   joerg
Date:           Mon Jul 17 19:53:10 UTC 2017

Modified Files:
        src/external/gpl3/gcc/dist/gcc: varasm.c

Log Message:
A const declaration with explicit section attribute should create a
read-only section, whether it is initialized or not.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.6 -r1.2 src/external/gpl3/gcc/dist/gcc/varasm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gcc/dist/gcc/varasm.c
diff -u src/external/gpl3/gcc/dist/gcc/varasm.c:1.1.1.6 src/external/gpl3/gcc/dist/gcc/varasm.c:1.2
--- src/external/gpl3/gcc/dist/gcc/varasm.c:1.1.1.6	Tue Jun  7 05:58:06 2016
+++ src/external/gpl3/gcc/dist/gcc/varasm.c	Mon Jul 17 19:53:10 2017
@@ -978,11 +978,17 @@ decode_reg_name (const char *name)
 }
 
 
-/* Return true if DECL's initializer is suitable for a BSS section.  */
+/*
+ * Return true if DECL's initializer is suitable for a BSS section.
+ * If there is an explicit section name attribute, assume that it is not
+ * for a BSS section, independent of the name.
+ */
 
 bool
 bss_initializer_p (const_tree decl)
 {
+  if (DECL_SECTION_NAME (decl) != NULL)
+    return false;
   return (DECL_INITIAL (decl) == NULL
 	  /* In LTO we have no errors in program; error_mark_node is used
 	     to mark offlined constructors.  */
@@ -6402,7 +6408,7 @@ categorize_decl_for_section (const_tree 
 	ret = SECCAT_BSS;
       else if (! TREE_READONLY (decl)
 	       || TREE_SIDE_EFFECTS (decl)
-	       || ! TREE_CONSTANT (DECL_INITIAL (decl)))
+	       || (DECL_INITIAL(decl) != NULL && ! 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
@@ -6446,6 +6452,7 @@ categorize_decl_for_section (const_tree 
 	 no concept of a read-only thread-local-data section.  */
       if (ret == SECCAT_BSS
 	       || (flag_zero_initialized_in_bss
+		   && DECL_INITIAL(decl) != NULL
 		   && initializer_zerop (DECL_INITIAL (decl))))
 	ret = SECCAT_TBSS;
       else

Reply via email to