public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/98146] New: [11 Regression] section type conflict when "used" attribute is applied to decl with specific section
@ 2020-12-04 14:47 jozefl at gcc dot gnu.org
  2020-12-07  7:49 ` [Bug target/98146] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jozefl at gcc dot gnu.org @ 2020-12-04 14:47 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/98146] [11 Regression] section type conflict when "used" attribute is applied to decl with specific section
  2020-12-04 14:47 [Bug target/98146] New: [11 Regression] section type conflict when "used" attribute is applied to decl with specific section jozefl at gcc dot gnu.org
@ 2020-12-07  7:49 ` rguenth at gcc dot gnu.org
  2020-12-07 21:11 ` hjl.tools at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-12-07  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/98146] [11 Regression] section type conflict when "used" attribute is applied to decl with specific section
  2020-12-04 14:47 [Bug target/98146] New: [11 Regression] section type conflict when "used" attribute is applied to decl with specific section jozefl at gcc dot gnu.org
  2020-12-07  7:49 ` [Bug target/98146] " rguenth at gcc dot gnu.org
@ 2020-12-07 21:11 ` hjl.tools at gmail dot com
  2020-12-11 15:41 ` hjl.tools at gmail dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2020-12-07 21:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
Also affecting Linux kernel build:

In file included from ./include/trace/define_trace.h:102,
                 from ./include/trace/events/tlb.h:62,
                 from arch/x86/mm/init.c:35:
./include/trace/trace_events.h:41:9: error:
??__TRACE_SYSTEM_TLB_REMOTE_SEND_IPI?? causes a section type conflict with
??can_use_brk_pgt??
   41 |         __##TRACE_SYSTEM##_##a =                        \
      |         ^~
./include/trace/events/tlb.h:25:25: note: in expansion of macro
??TRACE_DEFINE_ENUM??
   25 | #define EMe(a,b)        TRACE_DEFINE_ENUM(a);
      |                         ^~~~~~~~~~~~~~~~~
./include/trace/events/tlb.h:16:9: note: in expansion of macro ??EMe??
   16 |         EMe( TLB_REMOTE_SEND_IPI,       "remote ipi send" )
      |         ^~~
./include/trace/events/tlb.h:27:1: note: in expansion of macro
??TLB_FLUSH_REASON??
   27 | TLB_FLUSH_REASON
      | ^~~~~~~~~~~~~~~~
arch/x86/mm/init.c:103:24: note: ??can_use_brk_pgt?? was declared here
  103 | static bool __initdata can_use_brk_pgt = true;

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/98146] [11 Regression] section type conflict when "used" attribute is applied to decl with specific section
  2020-12-04 14:47 [Bug target/98146] New: [11 Regression] section type conflict when "used" attribute is applied to decl with specific section jozefl at gcc dot gnu.org
  2020-12-07  7:49 ` [Bug target/98146] " rguenth at gcc dot gnu.org
  2020-12-07 21:11 ` hjl.tools at gmail dot com
@ 2020-12-11 15:41 ` hjl.tools at gmail dot com
  2020-12-11 15:46 ` hjl.tools at gmail dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2020-12-11 15:41 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mkuvyrkov at gcc dot gnu.org

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
*** Bug 98246 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/98146] [11 Regression] section type conflict when "used" attribute is applied to decl with specific section
  2020-12-04 14:47 [Bug target/98146] New: [11 Regression] section type conflict when "used" attribute is applied to decl with specific section jozefl at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-12-11 15:41 ` hjl.tools at gmail dot com
@ 2020-12-11 15:46 ` hjl.tools at gmail dot com
  2020-12-16 13:43 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2020-12-11 15:46 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-12-11
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2020-Decembe
                   |                            |r/561332.html
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |patch

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/98146] [11 Regression] section type conflict when "used" attribute is applied to decl with specific section
  2020-12-04 14:47 [Bug target/98146] New: [11 Regression] section type conflict when "used" attribute is applied to decl with specific section jozefl at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-12-11 15:46 ` hjl.tools at gmail dot com
@ 2020-12-16 13:43 ` cvs-commit at gcc dot gnu.org
  2020-12-16 13:43 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-16 13:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

https://gcc.gnu.org/g:6175383249143309fdc780a02bea484f4450def7

commit r11-6140-g6175383249143309fdc780a02bea484f4450def7
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Dec 3 11:01:06 2020 -0800

    Switch to a new section if the SECTION_RETAIN bit doesn't match

    When definitions marked with used attribute and unmarked definitions are
    placed in the section with the same name, switch to a new section if the
    SECTION_RETAIN bit doesn't match.

    gcc/

            PR target/98146
            * output.h (switch_to_section): Add a tree argument, default to
            nullptr.
            * varasm.c (get_section): If the SECTION_RETAIN bit doesn't match,
            return and switch to a new section later.
            (assemble_start_function): Pass decl to switch_to_section.
            (assemble_variable): Likewise.
            (switch_to_section): If the SECTION_RETAIN bit doesn't match,
            switch to a new section.

    gcc/testsuite/

            PR target/98146
            * c-c++-common/attr-used-5.c: New test.
            * c-c++-common/attr-used-6.c: Likewise.
            * c-c++-common/attr-used-7.c: Likewise.
            * c-c++-common/attr-used-8.c: Likewise.
            * c-c++-common/attr-used-9.c: Likewise.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/98146] [11 Regression] section type conflict when "used" attribute is applied to decl with specific section
  2020-12-04 14:47 [Bug target/98146] New: [11 Regression] section type conflict when "used" attribute is applied to decl with specific section jozefl at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2020-12-16 13:43 ` cvs-commit at gcc dot gnu.org
@ 2020-12-16 13:43 ` cvs-commit at gcc dot gnu.org
  2020-12-16 13:43 ` cvs-commit at gcc dot gnu.org
  2020-12-16 13:45 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-16 13:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

https://gcc.gnu.org/g:2a976020603589e897fcfa3276590ef50b489d34

commit r11-6141-g2a976020603589e897fcfa3276590ef50b489d34
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Dec 3 15:39:59 2020 -0800

    Warn used and not used symbols in section with the same name

    When SECTION_RETAIN is used, issue a warning when a symbol without used
    attribute and a symbol with used attribute are placed in the section with
    the same name, like

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

    since assembler will put them in different sections with the same section
    name.

    gcc/

            PR target/98146
            * varasm.c (switch_to_section): Warn when a symbol without used
            attribute and a symbol with used attribute are placed in the
            section with the same name.

    gcc/testsuite/

            PR target/98146
            * c-c++-common/attr-used-5.c: Updated.
            * c-c++-common/attr-used-6.c: Likewise.
            * c-c++-common/attr-used-7.c: Likewise.
            * c-c++-common/attr-used-8.c: Likewise.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/98146] [11 Regression] section type conflict when "used" attribute is applied to decl with specific section
  2020-12-04 14:47 [Bug target/98146] New: [11 Regression] section type conflict when "used" attribute is applied to decl with specific section jozefl at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2020-12-16 13:43 ` cvs-commit at gcc dot gnu.org
@ 2020-12-16 13:43 ` cvs-commit at gcc dot gnu.org
  2020-12-16 13:45 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-16 13:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

https://gcc.gnu.org/g:151d1347c99acfcf0f5bcd8caac36dcc7353816d

commit r11-6142-g151d1347c99acfcf0f5bcd8caac36dcc7353816d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Dec 14 20:10:13 2020 -0800

    Require .init_array/.fini_array support for SHF_GNU_RETAIN

    Since SHF_GNU_RETAIN support doesn't work for crtstuff.c which switches
    the output section directly with asm statement:

    ---
    static void __attribute__((used))
    __do_global_dtors_aux (void)
    {
      static _Bool completed;

      if (__builtin_expect (completed, 0))
        return;
      completed = 1;
    }

    static void __attribute__((__used__))
    call___do_global_dtors_aux (void)
    {
      asm ("\t.section\t.fini");
      __do_global_dtors_aux ();
      asm ("\t.section\t.text");
    }
    ---

    use SHF_GNU_RETAIN only if .init_array/.fini_array section is supported.

    gcc/

            PR target/98146
            * defaults.h (SUPPORTS_SHF_GNU_RETAIN): New.
            * varasm.c (get_section): Replace HAVE_GAS_SHF_GNU_RETAIN with
            SUPPORTS_SHF_GNU_RETAIN.
            (resolve_unique_section): Likewise.
            (get_variable_section): Likewise.
            (switch_to_section): Likewise.

    gcc/testsuite/

            PR target/98146
            * lib/target-supports.exp
            (check_effective_target_R_flag_in_section): Also check
            HAVE_INITFINI_ARRAY_SUPPORT != 0.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/98146] [11 Regression] section type conflict when "used" attribute is applied to decl with specific section
  2020-12-04 14:47 [Bug target/98146] New: [11 Regression] section type conflict when "used" attribute is applied to decl with specific section jozefl at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2020-12-16 13:43 ` cvs-commit at gcc dot gnu.org
@ 2020-12-16 13:45 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2020-12-16 13:45 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
Fixed for GCC 11.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-12-16 13:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04 14:47 [Bug target/98146] New: [11 Regression] section type conflict when "used" attribute is applied to decl with specific section jozefl at gcc dot gnu.org
2020-12-07  7:49 ` [Bug target/98146] " rguenth at gcc dot gnu.org
2020-12-07 21:11 ` hjl.tools at gmail dot com
2020-12-11 15:41 ` hjl.tools at gmail dot com
2020-12-11 15:46 ` hjl.tools at gmail dot com
2020-12-16 13:43 ` cvs-commit at gcc dot gnu.org
2020-12-16 13:43 ` cvs-commit at gcc dot gnu.org
2020-12-16 13:43 ` cvs-commit at gcc dot gnu.org
2020-12-16 13:45 ` hjl.tools at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).