public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/100357] New: attribute noinit with -fdata-sections unexpected behaviour
@ 2021-04-30 13:16 sebastian.huber@embedded-brains.de
  2021-04-30 13:20 ` [Bug c/100357] unexpected behaviour of attribute noinit sebastian.huber@embedded-brains.de
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: sebastian.huber@embedded-brains.de @ 2021-04-30 13:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100357
           Summary: attribute noinit with -fdata-sections unexpected
                    behaviour
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sebastian.huber@embedded-brains.de
  Target Milestone: ---

Consider the following test code:

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

* [Bug c/100357] unexpected behaviour of attribute noinit
  2021-04-30 13:16 [Bug c/100357] New: attribute noinit with -fdata-sections unexpected behaviour sebastian.huber@embedded-brains.de
@ 2021-04-30 13:20 ` sebastian.huber@embedded-brains.de
  2021-09-22  7:20 ` [Bug middle-end/100357] noinit attribute does not work sometimes (small data or with -fdata-sections) pinskia at gcc dot gnu.org
  2021-09-22  7:22 ` [Bug middle-end/100357] noinit attribute does not work sometimes (small data) pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: sebastian.huber@embedded-brains.de @ 2021-04-30 13:20 UTC (permalink / raw)
  To: gcc-bugs

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

Sebastian Huber <sebastian.huber@embedded-brains.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|attribute noinit with       |unexpected behaviour of
                   |-fdata-sections unexpected  |attribute noinit
                   |behaviour                   |

--- Comment #1 from Sebastian Huber <sebastian.huber@embedded-brains.de> ---
Consider the following test code:

__attribute__(( __noinit__ )) int a;

__attribute__(( __noinit__ )) int b;

On a target with a small data area (e.g. powerpc) this yields:

 powerpc-rtems6-gcc -O2 -S -o - test.c
        .file   "test.c"
        .machine ppc
        .section        ".text"
        .globl B
        .globl a
        .section        .sbss,"aw",@nobits
        .align 2
        .type   B, @object
        .size   B, 4
B:
        .zero   4
        .type   a, @object
        .size   a, 4
a:
        .zero   4
        .ident  "GCC: (GNU) 10.2.1 20210113 (RTEMS 6, RSB
3d30ecae960152dd5a0e1be55de97dd46486ac53, Newlib 415fdd4)"
        .section        .note.GNU-stack,"",@progbits

On arm you get the expected result:
arm-rtems6-gcc -O2 -S -o - test.c
        .cpu arm7tdmi
        .eabi_attribute 20, 1
        .eabi_attribute 21, 1
        .eabi_attribute 23, 3
        .eabi_attribute 24, 1
        .eabi_attribute 25, 1
        .eabi_attribute 26, 2
        .eabi_attribute 30, 2
        .eabi_attribute 34, 0
        .eabi_attribute 18, 4
        .file   "test.c"
        .text
        .global B
        .global a
        .section        .noinit,"aw"
        .align  2
        .type   B, %object
        .size   B, 4
B:
        .space  4
        .type   a, %object
        .size   a, 4
a:
        .space  4
        .ident  "GCC: (GNU) 10.2.1 20210113 (RTEMS 6, RSB
3d30ecae960152dd5a0e1be55de97dd46486ac53, Newlib 415fdd4)"

However, with -fdata-sections you get:

arm-rtems6-gcc -O2 -S -o - test.c -fdata-sections
        .cpu arm7tdmi
        .eabi_attribute 20, 1
        .eabi_attribute 21, 1
        .eabi_attribute 23, 3
        .eabi_attribute 24, 1
        .eabi_attribute 25, 1
        .eabi_attribute 26, 2
        .eabi_attribute 30, 2
        .eabi_attribute 34, 0
        .eabi_attribute 18, 4
        .file   "test.c"
        .text
        .global B
        .global a
        .section        .bss.B,"aw",%nobits
        .align  2
        .type   B, %object
        .size   B, 4
B:
        .space  4
        .section        .bss.a,"aw",%nobits
        .align  2
        .type   a, %object
        .size   a, 4
a:
        .space  4
        .ident  "GCC: (GNU) 10.2.1 20210113 (RTEMS 6, RSB
3d30ecae960152dd5a0e1be55de97dd46486ac53, Newlib 415fdd4)"

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

* [Bug middle-end/100357] noinit attribute does not work sometimes (small data or with -fdata-sections)
  2021-04-30 13:16 [Bug c/100357] New: attribute noinit with -fdata-sections unexpected behaviour sebastian.huber@embedded-brains.de
  2021-04-30 13:20 ` [Bug c/100357] unexpected behaviour of attribute noinit sebastian.huber@embedded-brains.de
@ 2021-09-22  7:20 ` pinskia at gcc dot gnu.org
  2021-09-22  7:22 ` [Bug middle-end/100357] noinit attribute does not work sometimes (small data) pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-22  7:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
-fdata-sections problem was fixed with r11-5246-gb510765dedfec5.

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

* [Bug middle-end/100357] noinit attribute does not work sometimes (small data)
  2021-04-30 13:16 [Bug c/100357] New: attribute noinit with -fdata-sections unexpected behaviour sebastian.huber@embedded-brains.de
  2021-04-30 13:20 ` [Bug c/100357] unexpected behaviour of attribute noinit sebastian.huber@embedded-brains.de
  2021-09-22  7:20 ` [Bug middle-end/100357] noinit attribute does not work sometimes (small data or with -fdata-sections) pinskia at gcc dot gnu.org
@ 2021-09-22  7:22 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-22  7:22 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|noinit attribute does not   |noinit attribute does not
                   |work sometimes (small data  |work sometimes (small data)
                   |or with -fdata-sections)    |
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-09-22

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The sbss issue can most likely be fixed by:
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 2d261b353bf..1216e76be53 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -7063,7 +7063,7 @@ categorize_decl_for_section (const_tree decl, int reloc)
     }

   /* If the target uses small data sections, select it.  */
-  else if (targetm.in_small_data_p (decl))
+  else if (!DECL_NOINIT_P (decl) && targetm.in_small_data_p (decl))
     {
       if (ret == SECCAT_BSS)
        ret = SECCAT_SBSS;

But I have no way to test this patch.

Anyways confirmed for small data.

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

end of thread, other threads:[~2021-09-22  7:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-30 13:16 [Bug c/100357] New: attribute noinit with -fdata-sections unexpected behaviour sebastian.huber@embedded-brains.de
2021-04-30 13:20 ` [Bug c/100357] unexpected behaviour of attribute noinit sebastian.huber@embedded-brains.de
2021-09-22  7:20 ` [Bug middle-end/100357] noinit attribute does not work sometimes (small data or with -fdata-sections) pinskia at gcc dot gnu.org
2021-09-22  7:22 ` [Bug middle-end/100357] noinit attribute does not work sometimes (small data) pinskia at gcc dot gnu.org

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).