+2018-02-09 Jakub Jelinek <jakub@redhat.com>
+
+ 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.
+
2018-02-09 Marek Polacek <polacek@redhat.com>
Jakub Jelinek <jakub@redhat.com>
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);
+2018-02-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/84237
+ * gcc.dg/pr84237.c: New test.
+
2018-02-09 Marek Polacek <polacek@redhat.com>
Jakub Jelinek <jakub@redhat.com>
--- /dev/null
+/* PR middle-end/84237 */
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "" } */
+
+const char __attribute__((__section__(".bss.page_aligned.const"), __aligned__(4096))) zero_page[4096];
/* Return true if DECL's initializer is suitable for a BSS section. */
bool
-bss_initializer_p (const_tree 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. */
- return ((!TREE_READONLY (decl) || DECL_COMMON (decl))
+ 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. */
{
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",