/* 0xFFFFFFFF * 256*/
#define test_256X0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, ... 0xFFFFFFFF
After compiling, the const array is placed in ".rwdata" section rather than ".rodata" section, and I don't know why.
After google and searching the stackoverflow site, there is no specified answer. Does any one know why or how to ask compiler(or linker) to output warning message when "placing constant data into non-read-only section"? thanks.
PS. I resolve my problem by add attribure((section(".rodata")))
__attribure__((section(".rodata"))) volatile const int TEST_ro[512] = {test_256X, test_256X};
PS. I use linaor-gcc compiler for arm core
volatile const int. Why would aconstneed to bevolatile? - T.J. Crowdervolatileis for. It indicates to the compiler that the memory may be changed asynchronously so it doesn't used cached results. It's inconsistent withconst. Trystaticwhich tells the compiler that other modules cannot access it. - luser droogconstis not necessarily inconsistent withvolatile.constdoesn't mean variable cannot change, it means it cannot be changed. - user694733.rodatasection? - Nikolai