Implement the "persistent" attribute
authorJozef Lawrynowicz <jozef.l@mittosystems.com>
Mon, 23 Nov 2020 12:06:39 +0000 (12:06 +0000)
committerJozef Lawrynowicz <jozef.l@mittosystems.com>
Mon, 23 Nov 2020 12:15:51 +0000 (12:15 +0000)
commit762ca20364a590be2cb9c79c0101ccbff74b5de1
treeb865ba9ae2ac517d369987c8329cd9623cb31478
parentfb8309d4abdcd4c8de07bd4c42e22d1e80471765
Implement the "persistent" attribute

The "persistent" attribute is used for variables that are initialized
by the program loader, but are not initialized by the runtime startup
code. "persistent" variables are placed in a non-volatile area of
memory, which allows their value to "persist" between processor resets.

gcc/c-family/ChangeLog:

* c-attribs.c (handle_special_var_sec_attribute): New.
(handle_noinit_attribute): Remove.
(attr_noinit_exclusions): Rename to...
(attr_section_exclusions): ...this, and add "persistent" attribute
exclusion.
(c_common_attribute_table): Add "persistent" attribute.

gcc/ChangeLog:

* doc/extend.texi (Common Variable Attributes): Document the
"persistent" variable attribute.
* doc/sourcebuild.texi (Effective-Target Keywords): Document
the "persistent" effective target keyword.
* tree.h (DECL_PERSISTENT_P): Define.
* varasm.c (bss_initializer_p): Return false for a
DECL_PERSISTENT_P decl initialized to zero.
(default_section_type_flags): Handle the ".persistent" section.
(default_elf_select_section): Likewise.
(default_unique_section): Likewise.

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/noinit-attribute.c: Moved to...
* c-c++-common/torture/attr-noinit-main.inc: ...here.
* lib/target-supports.exp (check_effective_target_persistent): New.
* c-c++-common/torture/attr-noinit-1.c: New test.
* c-c++-common/torture/attr-noinit-2.c: New test.
* c-c++-common/torture/attr-noinit-3.c: New test.
* c-c++-common/torture/attr-noinit-invalid.c: New test.
* c-c++-common/torture/attr-persistent-1.c: New test.
* c-c++-common/torture/attr-persistent-2.c: New test.
* c-c++-common/torture/attr-persistent-3.c: New test.
* c-c++-common/torture/attr-persistent-invalid.c: New test.
* c-c++-common/torture/attr-persistent-main.inc: New test.
17 files changed:
gcc/c-family/c-attribs.c
gcc/doc/extend.texi
gcc/doc/sourcebuild.texi
gcc/testsuite/c-c++-common/torture/attr-noinit-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/torture/attr-noinit-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/torture/attr-noinit-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/torture/attr-noinit-invalid.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/torture/attr-noinit-main.inc [new file with mode: 0644]
gcc/testsuite/c-c++-common/torture/attr-persistent-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/torture/attr-persistent-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/torture/attr-persistent-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/torture/attr-persistent-invalid.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/torture/attr-persistent-main.inc [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/noinit-attribute.c [deleted file]
gcc/testsuite/lib/target-supports.exp
gcc/tree.h
gcc/varasm.c