.text variable and optimization issue

Ángel González keisial@gmail.com
Wed Jul 4 21:24:00 GMT 2012


On 04/07/12 22:30, Marcin S wrote:
> 2012/7/4 Václav Zeman:
>> The compiler probably sees through your games. The language defines that
>> constants are really, constant, AFAIK. Try changing the 'const uint16_t
>> CFlashSignature::SIGNATURE' to 'const volatile uint16_t
>> CFlashSignature::SIGNATURE' or just drop the const entirely (and add
>> volatile).
> Hi,
> Yes, i did tried this before, unfortunately with this modifier
> (volatile or omitting const at all) makes variable not to land in
> .text (flash) but in RAM, so, this won't do me any good if flag will
> reset after power down - i need it to be persistent, thats the whole
> point.
Have you tried adding an explicit section attribute?

__attribute__ ((section (".text")));

http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#index-g_t_0040code_007bsection_007d-function-attribute-2598




More information about the Gcc-help mailing list