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 allocation 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With