https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98146

            Bug ID: 98146
           Summary: [11 Regression] section type conflict when "used"
                    attribute is applied to decl with specific section
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jozefl at gcc dot gnu.org
  Target Milestone: ---

For targets that support the SHF_GNU_RETAIN ELF section flag, the "used"
attribute will set the internal GCC SECTION_RETAIN flag on the section
containing the "used" decl.

If a "used" decl, and a decl without "used" both specify the same section with
the "section" attribute, GCC will emit an error:

$ cat tester.c
int __attribute__((section(".data.foo"))) foo1 = 1;
int __attribute__((used,section(".data.foo"))) foo2 = 2;

$ gcc -S tester.c
tester.c:2:48: error: 'foo2' causes a section type conflict with 'foo1'
    2 | int __attribute__((used,section(".data.foo"))) foo2 = 2;
      |                                                ^~~~
tester.c:1:43: note: 'foo1' was declared here
    1 | int __attribute__((section(".data.foo"))) foo1 = 1;
      |                                           ^~~~

This was originally reported in glibc PR 27002, but is actually a GCC bug.

Reply via email to