When using gcc to cross-compile for the MCU, you provide the linker script file to the linker so that it knows how to create the final object file.
I would like to know more about this type of file, but I cannot find a good tutorial on how these files work, what syntax they use, what are the best practices and what should be avoided.
Here is an example of a truncated link file that will be provided to the linker with the "-Tlinkfile.ld" parameter:
MEMORY
{
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20k
rom (rx) : ORIGIN = 0x00000000, LENGTH = 128K
}
SECTIONS
{
. = 0x0;
.text :
{
*(.nvic_vector)
*(.text.*)
*(.text)
*(.rodata)
} >rom
. = 0x20000000;
.data :
{
*(.data)
} >ram AT > rom
.bss :
{
*(.bss)
} >ram AT > rom
}
/Thank
Johan source
share