ARM GCC linker script

Ref: http://enginechang.logdown.com/posts/255812-introduction-to-stm32f429-linker-script 

進入點

/* Entry Point */
ENTRY(Reset_Handler)  

Memory 實體


/* Specify the memory areas */
MEMORY
{
  ROM(rx) : ORIGIN = 0x00000000, LENGTH = 1048396
  TCM_RAM(rwx) : ORIGIN = 0x1FFF0000, LENGTH = 65536
  BUS_RAM(rwx)  : ORIGIN = 0x10000000, LENGTH = 458752
}

Text 段

    *(.rotext*)
    *(.text.rom*)
    *(.text .text.* *.text .gnu.linkonce.t.*)

    . = ALIGN(4);
    /* glue_7: arm code calling thumb code */
    *(.glue_7)
    /* glue_7t: thumb code calling arm code */
    *(.glue_7t)

    *(.eh_frame*)

    KEEP(*(.init))
    KEEP(*(.fini))

    . = ALIGN(4);
    _etext = .;


        *(.ARM.extab* .gnu.linkonce.armextab.*)


---
exidx 和 extab 要放在不同 sections


   PROVIDE_HIDDEN (__exidx_start = .);
    .ARM.exidx :
    {
      *(.ARM.exidx* .gnu.linkonce.armexidx.*)
    } > BUS_RAM
    PROVIDE_HIDDEN (__exidx_end = .);


---
        . = ALIGN(4);
        /* preinit data */
        PROVIDE (__preinit_array_start = .);
        KEEP(*(.preinit_array))
        PROVIDE (__preinit_array_end = .);

         /* init data */
        . = ALIGN(4);
        KEEP(*(.init))

        /* init data */
        . = ALIGN(4);
        PROVIDE (__init_array_start = .);
        KEEP(*(SORT(.init_array.*)))
        KEEP(*(.init_array))
        PROVIDE (__init_array_end = .);

        /* .ctors */
        . = ALIGN(0x4);
        KEEP (*crtbegin.o(.ctors))
        KEEP(*crtbegin?.o(.ctors))
        KEEP(*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
        KEEP (*(SORT(.ctors.*)))
        KEEP (*crtend.o(.ctors))
        KEEP(*(.ctors))

         /* finit data */
        . = ALIGN(4);
        KEEP(*(.fini))


        . = ALIGN(4);
        PROVIDE (__fini_array_start = .);
        KEEP(*(SORT(.fini_array.*)))
        KEEP(*(.fini_array))
        PROVIDE (__fini_array_end = .);

        /* .dtors */
        . = ALIGN(4);
        KEEP (*crtbegin.o(.dtors))
        KEEP(*crtbegin?.o(.dtors))
        KEEP(*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
        KEEP(*(SORT(.dtors.*)))
        KEEP(*crtend.o(.dtors))
        KEEP(*(.dtors))

        KEEP(*(.eh_frame*))
       KEEP(*(.jcr*))

---

BSS

    .bss  (NOLOAD):
    {
        . = ALIGN(4);
        __bss_start__ = .;
        _sbss = . ;
        _szero = .;
        _start_bss = .;

    *(.bss .bss*)
    *(COMMON)

        . = ALIGN(4);
        _ebss = . ;
        _ezero = .;
        __bss_end__ = .;
        _end_bss = . ;
    }

--

    /DISCARD/ :
    {
       libc.a (*)
       libm.a (*)
       libgcc.a (*)
    }

    .ARM.attributes 0 : { *(.ARM.attributes) }

--


留言

熱門文章