From ebd06e5ca705e69711eb58277b6f820132bb7b67 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 9 Feb 2018 06:47:24 +0100 Subject: [PATCH] re PR middle-end/84237 (xen build faiulre only zero initializers are allowed in section '.bss.page_aligned.const') 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. * gcc.dg/pr84237.c: New test. From-SVN: r257513 --- gcc/ChangeLog | 9 +++++++++ gcc/output.h | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr84237.c | 5 +++++ gcc/varasm.c | 9 +++++---- 5 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr84237.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d9c544387fc..cacb10e9a84 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2018-02-09 Jakub Jelinek + + 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 Jakub Jelinek diff --git a/gcc/output.h b/gcc/output.h index 51ac149b811..f708cc75fa7 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -552,7 +552,7 @@ extern void output_file_directive (FILE *, const char *); 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 --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 49a2275c732..0177e2b4270 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-09 Jakub Jelinek + + PR middle-end/84237 + * gcc.dg/pr84237.c: New test. + 2018-02-09 Marek Polacek Jakub Jelinek diff --git a/gcc/testsuite/gcc.dg/pr84237.c b/gcc/testsuite/gcc.dg/pr84237.c new file mode 100644 index 00000000000..5a2697f3167 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr84237.c @@ -0,0 +1,5 @@ +/* PR middle-end/84237 */ +/* { dg-do compile { target *-*-linux* } } */ +/* { dg-options "" } */ + +const char __attribute__((__section__(".bss.page_aligned.const"), __aligned__(4096))) zero_page[4096]; diff --git a/gcc/varasm.c b/gcc/varasm.c index b045efaabf5..6e345d39d31 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -983,11 +983,11 @@ decode_reg_name (const char *name) /* 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. */ @@ -1165,7 +1165,8 @@ get_variable_section (tree decl, bool prefer_noswitch_p) { 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", -- 2.30.2