Version 1.0 bump
[inav/snaewe.git] / src / main / target / stm32_flash.ld
blob40bc9965ba5c8a5b5ccdccb1ec0558dac28eecb6
1 /*
2 *****************************************************************************
3 **
4 **  File        : stm32_flash.ld
5 **
6 **  Abstract    : Common linker script for STM32 devices.
7 **
8 *****************************************************************************
9 */
11 /* Entry Point */
12 ENTRY(Reset_Handler)
14 /* Highest address of the user mode stack */
15 _estack = ORIGIN(RAM) + LENGTH(RAM);    /* end of RAM */
17 /* Generate a link error if heap and stack don't fit into RAM */
18 _Min_Heap_Size = 0;      /* required amount of heap  */
19 _Min_Stack_Size = 0x400; /* required amount of stack */
21 /* Define output sections */
22 SECTIONS
24   /* The startup code goes first into FLASH */
25   .isr_vector :
26   {
27     . = ALIGN(4);
28     PROVIDE (isr_vector_table_base = .);
29     KEEP(*(.isr_vector)) /* Startup code */
30     . = ALIGN(4);
31   } >FLASH
33   /* The program code and other data goes into FLASH */
34   .text :
35   {
36     . = ALIGN(4);
37     *(.text)           /* .text sections (code) */
38     *(.text*)          /* .text* sections (code) */
39     *(.rodata)         /* .rodata sections (constants, strings, etc.) */
40     *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
41     *(.glue_7)         /* glue arm to thumb code */
42     *(.glue_7t)        /* glue thumb to arm code */
43     *(.eh_frame)
45     KEEP (*(.init))
46     KEEP (*(.fini))
48     . = ALIGN(4);
49     _etext = .;        /* define a global symbols at end of code */
50   } >FLASH
53    .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
54     .ARM : {
55     __exidx_start = .;
56       *(.ARM.exidx*)
57       __exidx_end = .;
58     } >FLASH
60   .preinit_array     :
61   {
62     PROVIDE_HIDDEN (__preinit_array_start = .);
63     KEEP (*(.preinit_array*))
64     PROVIDE_HIDDEN (__preinit_array_end = .);
65   } >FLASH
66   .init_array :
67   {
68     PROVIDE_HIDDEN (__init_array_start = .);
69     KEEP (*(SORT(.init_array.*)))
70     KEEP (*(.init_array*))
71     PROVIDE_HIDDEN (__init_array_end = .);
72   } >FLASH
73   .fini_array :
74   {
75     PROVIDE_HIDDEN (__fini_array_start = .);
76     KEEP (*(.fini_array*))
77     KEEP (*(SORT(.fini_array.*)))
78     PROVIDE_HIDDEN (__fini_array_end = .);
79   } >FLASH
81   /* used by the startup to initialize data */
82   _sidata = .;
84   /* Initialized data sections goes into RAM, load LMA copy after code */
85   .data :
86   {
87     . = ALIGN(4);
88     _sdata = .;        /* create a global symbol at data start */
89     *(.data)           /* .data sections */
90     *(.data*)          /* .data* sections */
92     . = ALIGN(4);
93     _edata = .;        /* define a global symbol at data end */
94   } >RAM AT> FLASH
96   /* Uninitialized data section */
97   . = ALIGN(4);
98   .bss :
99   {
100     /* This is used by the startup in order to initialize the .bss secion */
101     _sbss = .;         /* define a global symbol at bss start */
102     __bss_start__ = _sbss;
103     *(.bss)
104     *(SORT_BY_ALIGNMENT(.bss*))
105     *(COMMON)
107     . = ALIGN(4);
108     _ebss = .;         /* define a global symbol at bss end */
109     __bss_end__ = _ebss;
110   } >RAM
112   /* User_heap_stack section, used to check that there is enough RAM left */
113   ._user_heap_stack :
114   {
115     . = ALIGN(4);
116     PROVIDE ( end = . );
117     PROVIDE ( _end = . );
118     . = . + _Min_Heap_Size;
119     . = . + _Min_Stack_Size;
120     . = ALIGN(4);
121   } >RAM
123   /* MEMORY_bank1 section, code must be located here explicitly            */
124   /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
125   .memory_b1_text :
126   {
127     *(.mb1text)        /* .mb1text sections (code) */
128     *(.mb1text*)       /* .mb1text* sections (code)  */
129     *(.mb1rodata)      /* read-only data (constants) */
130     *(.mb1rodata*)
131   } >MEMORY_B1
133   /* Remove information from the standard libraries */
134   /DISCARD/ :
135   {
136     libc.a ( * )
137     libm.a ( * )
138     libgcc.a ( * )
139   }
141   .ARM.attributes 0 : { *(.ARM.attributes) }