https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81457
Bug ID: 81457 Summary: Inconsistent section flags for section attribute Product: gcc Version: 5.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: joerg at netbsd dot org Target Milestone: --- Created attachment 41767 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41767&action=edit Potential fix, relative to GCC 5.4.0. Assemble the following input for any ELF target: __attribute__((section("foo1s"))) const int foo1; __attribute__((section("foo2s"))) const int foo2 = 42; Note that foo1s has flags "AW", but foo2s has flags "A". Bug reproduces on the GCC snapshot option of godbolt.org. The attached patch applies against GCC 5.4.0, it might need shuffling for newer versions. The additional null checks are required for correct handling of e.g. __thread variables.