Gcc memory card link file, what syntax is it?

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;           /* From 0x00000000 */
    .text : 
    {
        *(.nvic_vector)  /* Vector table */
        *(.text.*)      /* Program code */
        *(.text)        /* Program code */
        *(.rodata)      /* Read only data */
    } >rom

    .  = 0x20000000;    /* From 0x20000000 */      
    .data : 
    {
        *(.data)        /* Data memory */
    } >ram AT > rom

    .bss : 
    {
        *(.bss)         /* Zero-filled run time allocate data memory */
    } >ram AT > rom
}  

/Thank

+3
source share
1 answer

GNU binutils ld - , , , .

+3

All Articles