The MSP430 target supports an attribute "persistent" that can be set
on variables to indicate that they should be placed in a special
section ".persistent", which will not be re-initialized on reset.

As reported in PR78818
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78818), GCC does not
place variables with the persistent attribute in the .persistent
section if:
1) If -fdata-sections is used.
2) If -mdata-region={lower,upper,either} is used.
3) They are static and initialized to 0 (or uninitialized).

The first of the two following patch fixes these issues by always
setting the section of a variable with the .persistent attribute to
.persistent.

The second patch adds a warning if the persistent attribute is used on
an automatic variable, to warn that this will have no effect.

The patches passed regression testing with "-mcpu=msp430x/-mlarge" for
msp430-elf on the gcc-6-branch (r247086). Trunk doesn't build with C++
support for msp430-elf which is why gcc-6-branch was used.

Reply via email to