Merge pull request #2754 from ExpressLRS/merge-3.4.2-into-master
[ExpressLRS.git] / src / variants / ldscript_gen.ld
blob110d2768bb2ff739ea319b5d28c46b3cc841a563
2 /* Entry Point */
3 ENTRY(Reset_Handler)
5 /* Highest address of the user mode stack */
6 _estack = ORIGIN(RAM_DATA) + LENGTH(RAM_DATA) - 0x80;
7 /* Reserve some RAM to exchange data for bootloader */
8 _bootloader_data = ORIGIN(RAM_DATA) + LENGTH(RAM_DATA) - 0x7C;
9 /* Generate a link error if heap and stack don't fit into RAM */
10 _Min_Heap_Size = 0x200;   /* required amount of heap  */
11 _Min_Stack_Size = 0x1000; /* required amount of stack */
12 _Min_BL_Size = 0x80;      /* required amount of bootloader data */
14 /* Define output sections */
15 SECTIONS
17   /* Critical program code goes into RAM_CODE */
18   ram_code = LOADADDR(.ram_code);
19   .ram_code :
20   {
21     /* Vectors must be 512 bytes (128 words) aligned */
22     . = ALIGN(512);
23     ram_code_start = .;
24     /* NOTE: Keep vectors first! */
25     KEEP(*(.isr_vector))
26     *(.ram_code)
27     *(.ram_code*)
28     . = ALIGN(4);
29     ram_code_end = .;
30   } >RAM_CODE AT> FLASH
32   /* Link vector code here to avoid bootloader update with the
33    * latest (14.x or newer) platfroms */
34   .text_vectors :
35   {
36     . = ALIGN(4);
37     *(*Reset_Handler)
38     *(*NMI_Handler)
39     *(*HardFault_Handler)
40     *(*MemManage_Handler)
41     *(*Default_Handler)
42   } >FLASH
44   /* The program code and other data goes into FLASH */
45   .text :
46   {
47     . = ALIGN(4);
48     *(.text)           /* .text sections (code) */
49     *(.text*)          /* .text* sections (code) */
50     *(.glue_7)         /* glue arm to thumb code */
51     *(.glue_7t)        /* glue thumb to arm code */
52     *(.eh_frame)
54     KEEP (*(.init))
55     KEEP (*(.fini))
57     . = ALIGN(4);
58     _etext = .;        /* define a global symbols at end of code */
59   } >FLASH
61   /* Constant data goes into FLASH */
62   .rodata :
63   {
64     . = ALIGN(4);
65     *(.rodata)         /* .rodata sections (constants, strings, etc.) */
66     *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
67     . = ALIGN(4);
68   } >FLASH
70   .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
71   .ARM : {
72     __exidx_start = .;
73     *(.ARM.exidx*)
74     __exidx_end = .;
75   } >FLASH
77   .preinit_array     :
78   {
79     PROVIDE_HIDDEN (__preinit_array_start = .);
80     KEEP (*(.preinit_array*))
81     PROVIDE_HIDDEN (__preinit_array_end = .);
82   } >FLASH
83   .init_array :
84   {
85     PROVIDE_HIDDEN (__init_array_start = .);
86     KEEP (*(SORT(.init_array.*)))
87     KEEP (*(.init_array*))
88     PROVIDE_HIDDEN (__init_array_end = .);
89   } >FLASH
90   .fini_array :
91   {
92     PROVIDE_HIDDEN (__fini_array_start = .);
93     KEEP (*(SORT(.fini_array.*)))
94     KEEP (*(.fini_array*))
95     PROVIDE_HIDDEN (__fini_array_end = .);
96   } >FLASH
98   /* used by the startup to initialize data */
99   _sidata = LOADADDR(.data);
101   /* Initialized data sections goes into RAM, load LMA copy after code */
102   .data :
103   {
104     . = ALIGN(4);
105     _sdata = .;        /* create a global symbol at data start */
106     *(.data)           /* .data sections */
107     *(.data*)          /* .data* sections */
109     . = ALIGN(4);
110     _edata = .;        /* define a global symbol at data end */
111   } >RAM_DATA AT> FLASH
113   _siccmram = LOADADDR(.ccmram);
115   /* CCM-RAM section
116   *
117   * IMPORTANT NOTE!
118   * If initialized variables will be placed in this section,
119   * the startup code needs to be modified to copy the init-values.
120   */
121   .ccmram :
122   {
123     . = ALIGN(4);
124     _sccmram = .;       /* create a global symbol at ccmram start */
125     *(.ccmram)
126     *(.ccmram*)
128     . = ALIGN(4);
129     _eccmram = .;       /* create a global symbol at ccmram end */
130   } >CCMRAM AT> FLASH
132   /* Uninitialized data section */
133   . = ALIGN(4);
134   .bss (NOLOAD) :
135   {
136     /* This is used by the startup in order to initialize the .bss secion */
137     _sbss = .;         /* define a global symbol at bss start */
138     __bss_start__ = _sbss;
139     *(.bss)
140     *(.bss*)
141     *(COMMON)
143     . = ALIGN(4);
144     _ebss = .;         /* define a global symbol at bss end */
145     __bss_end__ = _ebss;
146   } >RAM_DATA
148   /* User_heap_stack section, used to check that there is enough RAM left */
149   ._user_heap_stack (NOLOAD) :
150   {
151     . = ALIGN(8);
152     PROVIDE ( end = . );
153     PROVIDE ( _end = . );
154     . = . + _Min_Heap_Size;
155     . = . + _Min_Stack_Size;
156     . = . + _Min_BL_Size;
157     . = ALIGN(8);
158   } >RAM_DATA
160   /* Remove information from the standard libraries */
161   /DISCARD/ :
162   {
163     libc.a ( * )
164     libm.a ( * )
165     libgcc.a ( * )
166   }
168   .ARM.attributes 0 : { *(.ARM.attributes) }