]> git.ipfire.org Git - thirdparty/gcc.git/commit
Add generic support for noinit attribute.
authorclyon <clyon@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Aug 2019 13:14:59 +0000 (13:14 +0000)
committerclyon <clyon@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Aug 2019 13:14:59 +0000 (13:14 +0000)
commitd6491b527c7722d0f7b1711f1b7329675cdfaa90
treefb03464b4e6202043a7a8c16d3c468949bca950b
parent2e3534be44d4f3bf4c3743e3a77810cfeb0e07c3
Add generic support for noinit attribute.

    Similar to what already exists for TI msp430 or in TI compilers for
    arm, this patch adds support for the "noinit" attribute.

    It is convenient for embedded targets where the user wants to keep the
    value of some data when the program is restarted: such variables are
    not zero-initialized. It is mostly a helper/shortcut to placing
    variables in a dedicated section.

    It's probably desirable to add the following chunk to the GNU linker:
    diff --git a/ld/emulparams/armelf.sh b/ld/emulparams/armelf.sh
    index 272a8bc..9555cec 100644
    --- a/ld/emulparams/armelf.sh
    +++ b/ld/emulparams/armelf.sh
    @@ -10,7 +10,19 @@ OTHER_TEXT_SECTIONS='*(.glue_7t) *(.glue_7)
    *(.vfp11_veneer) *(.v4_bx)'
     OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ =
    .${CREATE_SHLIB+)};"
     OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ =
    .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__bss_end__ =
    .${CREATE_SHLIB+)};"
     OTHER_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__end__ = .${CREATE_SHLIB+)};"
     -OTHER_SECTIONS='.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }'
     +OTHER_SECTIONS='
     +.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
     +  /* This section contains data that is not initialised during load
     +     *or* application reset.  */
     +   .noinit (NOLOAD) :
     +   {
     +     . = ALIGN(2);
     +     PROVIDE (__noinit_start = .);
     +     *(.noinit)
     +     . = ALIGN(2);
     +     PROVIDE (__noinit_end = .);
     +   }
     +'

    so that the noinit section has the "NOLOAD" flag.

    I added a testcase if gcc.c-torture/execute, gated by the new noinit
    effective-target.

    Finally, I tested on arm-eabi, but not on msp430 for which I do not
    have the environment.

gcc/ChangeLog:

2019-08-14  Christophe Lyon  <christophe.lyon@linaro.org>

* doc/extend.texi: Add "noinit" attribute documentation.
* doc/sourcebuild.texi: Add noinit effective target documentation.
* varasm.c (default_section_type_flags): Add support for "noinit" section.
(default_elf_select_section): Add support for "noinit" attribute.
* config/msp430/msp430.c (msp430_attribute_table): Remove "noinit" entry.

gcc/c-family/ChangeLog:

2019-08-14  Christophe Lyon  <christophe.lyon@linaro.org>

* c-attribs.c (c_common_attribute_table): Add "noinit" entry. Add
exclusion with "section" attribute.
(attr_noinit_exclusions): New table.
(handle_noinit_attribute): New function.

gcc/testsuite/ChangeLog:

2019-08-14  Christophe Lyon  <christophe.lyon@linaro.org>

* lib/target-supports.exp (check_effective_target_noinit): New
proc.
* gcc.c-torture/execute/noinit-attribute.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274482 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-attribs.c
gcc/config/msp430/msp430.c
gcc/doc/extend.texi
gcc/doc/sourcebuild.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/noinit-attribute.c [new file with mode: 0644]
gcc/testsuite/lib/target-supports.exp
gcc/varasm.c