Gcc: Memory region for anonymous string
I used GCC and need to define big array of text, like
const char* myArray[1000] = {"red", "blue", "green", "yellow", ...};
I have a array of pointers and big heap of text like "red\0blue\0green\0..."
somewere in memory. I want to change memory region for that text. I used __attribute__((section(...)))
GCC directive, but they change only allocat开发者_如何学Pythonion of pointers. How can i change allocation of big text chunk? Thanks for answers.
P.S. Sorry for bad English.
You can use -fdata-sections with gcc. That will create a unique section for each global variable in the object-file.
Then you can create a LdScript-file which will tell the linker (ld) to put the sections into the desired memory region.
Anonymous strings are in the .rodata-section of the object-file. An LdScript-example snippet:
.memregion1.rodata :
{
Startup.c.obj(.rodata.str1.8)
}
will put the str1.8 from Startup.c into the memregion1.
精彩评论