Hi Claudio
I have just done something like this.
First, I suggest you read through this article: Putting Code of Files into Special Section with the GNU Linker | MCU on Eclipse
In the linker file, you can specify that you want the output from a specified source file put in a specific memory location as follows:
This example is to store a constant array in a particular location (it's 1K in size). The array was defined on its own in a file called "boot_crc32.c"
1. In the linker file, MEMORY section, add a new line for the data:
MEMORY {
m_interrupts (RX) : ORIGIN = 0x00001000, LENGTH = 0x000000C0
m_boot_crc32 (R) : ORIGIN = 0x00000C00, LENGTH = 0x00000400
etc.
}
2. In the SECTIONS part of the linker file, add the following. Put it somewhere near the start before the .text section which holds the program code and data.
/* New section for the CRC32 lookup table */
.boot_crc32_seg :
{
. = ALIGN(4);
*boot_crc32.o (.rodata .rodata*)
. = ALIGN(4);
} > m_boot_crc32
3. This tells the linker to take the compiled output from any file matching the pattern *boot_crc32.o and place any read only data in memory block m_boot_crc32
If you were placing code in this segment, change .rodata to .text.
4. The actual definition for this data reads
const uint32 TableCRC32[] = { 0x00000000, 0x04c11db7, etc.
Note that I did not have to put any __attribute__ ((section (".boot_crc32_seg "))) statement at the front of the declaration.
It's all done in the linker file (Usually called "ProcessorExpert.ld" or similar)
5. Finally, check placement in the map file
Hope this helps. I spent half a day working this out and testing it.
Good luck
Steve