aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@linaro.org>2019-08-14 13:14:59 +0000
committerChristophe Lyon <clyon@gcc.gnu.org>2019-08-14 15:14:59 +0200
commitf0033821c1c9ba386a1983499a666d5759cdd943 (patch)
treefb03464b4e6202043a7a8c16d3c468949bca950b /gcc/doc
parent93cf5515729f526761489ec3892c6f0ea0d7105b (diff)
downloadgcc-f0033821c1c9ba386a1983499a666d5759cdd943.zip
gcc-f0033821c1c9ba386a1983499a666d5759cdd943.tar.gz
gcc-f0033821c1c9ba386a1983499a666d5759cdd943.tar.bz2
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. From-SVN: r274482
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/extend.texi8
-rw-r--r--gcc/doc/sourcebuild.texi3
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 1666972..2ba9b74 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -7156,6 +7156,14 @@ The @code{visibility} attribute is described in
The @code{weak} attribute is described in
@ref{Common Function Attributes}.
+@item noinit
+@cindex @code{noinit} variable attribute
+Any data with the @code{noinit} attribute will not be initialized by
+the C runtime startup code, or the program loader. Not initializing
+data in this way can reduce program startup times. This attribute is
+specific to ELF targets and relies on the linker to place such data in
+the right location
+
@end table
@node ARC Variable Attributes
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 73186c5..f9fcd09 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2302,6 +2302,9 @@ Target uses natural alignment (aligned to type size) for types of
Target uses natural alignment (aligned to type size) for types of
64 bits or less.
+@item noinit
+Target supports the @code{noinit} variable attribute.
+
@item nonpic
Target does not generate PIC by default.