summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <mcgrathr@google.com>2018-02-26 15:46:39 -0800
committerRoland McGrath <mcgrathr@google.com>2018-02-26 15:52:35 -0800
commit2a1ebe0b1d58adcd16d4786bab18fca11f672cab (patch)
treeca99bdd577ea47853cd7abd505117abf2d8d74bd
parent4b5e15daff8b54440e3fda451c318ad31e532fab (diff)
downloadgcc-roland/6.3.0/pr77609.tar.gz
PR other/77609: Let the assembler choose ELF section types for miscellaneous named sectionsroland/6.3.0/pr77609
gcc/ PR other/77609 * varasm.c (default_section_type_flags): Set SECTION_NOTYPE for any section for which we don't know a specific type it should have, regardless of name. Previously this was done only for the exact names ".init_array", ".fini_array", and ".preinit_array". (cherry picked from commit b9a216a984df9f9fc676261886b5f394547d0a3d)
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/varasm.c23
2 files changed, 22 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 06ebfb1a548..7927c0ddeef 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2018-02-26 Roland McGrath <mcgrathr@google.com>
+
+ PR other/77609
+ * varasm.c (default_section_type_flags): Set SECTION_NOTYPE for
+ any section for which we don't know a specific type it should have,
+ regardless of name. Previously this was done only for the exact
+ names ".init_array", ".fini_array", and ".preinit_array".
+
2016-12-21 Release Manager
* GCC 6.3.0 released.
diff --git a/gcc/varasm.c b/gcc/varasm.c
index b0f2af03de4..4d36fb6898e 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -6193,15 +6193,20 @@ default_section_type_flags (tree decl, const char *name, int reloc)
|| strncmp (name, ".gnu.linkonce.tb.", 17) == 0)
flags |= SECTION_TLS | SECTION_BSS;
- /* These three sections have special ELF types. They are neither
- SHT_PROGBITS nor SHT_NOBITS, so when changing sections we don't
- want to print a section type (@progbits or @nobits). If someone
- is silly enough to emit code or TLS variables to one of these
- sections, then don't handle them specially. */
- if (!(flags & (SECTION_CODE | SECTION_BSS | SECTION_TLS))
- && (strcmp (name, ".init_array") == 0
- || strcmp (name, ".fini_array") == 0
- || strcmp (name, ".preinit_array") == 0))
+ /* Various sections have special ELF types that the assembler will
+ assign by default based on the name. They are neither SHT_PROGBITS
+ nor SHT_NOBITS, so when changing sections we don't want to print a
+ section type (@progbits or @nobits). Rather than duplicating the
+ assembler's knowledge of what those special name patterns are, just
+ let the assembler choose the type if we don't know a specific
+ reason to set it to something other than the default. SHT_PROGBITS
+ is the default for sections whose name is not specially known to
+ the assembler, so it does no harm to leave the choice to the
+ assembler when @progbits is the best thing we know to use. If
+ someone is silly enough to emit code or TLS variables to one of
+ these sections, then don't handle them specially. */
+ if (!(flags & (SECTION_CODE | SECTION_BSS | SECTION_TLS | SECTION_ENTSIZE))
+ && !(HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)))
flags |= SECTION_NOTYPE;
return flags;