varasm.c
235 KB
-
Add generic support for noinit attribute. · f0033821
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. From-SVN: r274482
Christophe Lyon committed