1 | /********************************************************************* |
---|
2 | * SEGGER Microcontroller GmbH * |
---|
3 | * The Embedded Experts * |
---|
4 | ********************************************************************** |
---|
5 | * * |
---|
6 | * (c) 2014 - 2024 SEGGER Microcontroller GmbH * |
---|
7 | * * |
---|
8 | * www.segger.com Support: support@segger.com * |
---|
9 | * * |
---|
10 | ********************************************************************** |
---|
11 | * * |
---|
12 | * All rights reserved. * |
---|
13 | * * |
---|
14 | * Redistribution and use in source and binary forms, with or * |
---|
15 | * without modification, are permitted provided that the following * |
---|
16 | * condition is met: * |
---|
17 | * * |
---|
18 | * - Redistributions of source code must retain the above copyright * |
---|
19 | * notice, this condition and the following disclaimer. * |
---|
20 | * * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * |
---|
22 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * |
---|
23 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * |
---|
24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * |
---|
25 | * DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * |
---|
26 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * |
---|
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * |
---|
28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * |
---|
29 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * |
---|
30 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * |
---|
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * |
---|
32 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * |
---|
33 | * DAMAGE. * |
---|
34 | * * |
---|
35 | ********************************************************************** |
---|
36 | -------------------------- END-OF-HEADER ----------------------------- |
---|
37 | |
---|
38 | File : SEGGER_Flash.icf |
---|
39 | Purpose : Generic linker script for application placement in Flash, |
---|
40 | for use with the SEGGER Linker. |
---|
41 | Literature: |
---|
42 | [1] SEGGER Linker User Guide (https://www.segger.com/doc/UM20005_Linker.html) |
---|
43 | [2] SEGGER Linker Section Placement (https://wiki.segger.com/SEGGER_Linker_Script_Files) |
---|
44 | */ |
---|
45 | |
---|
46 | define memory with size = 4G; |
---|
47 | |
---|
48 | // |
---|
49 | // Combined regions per memory type |
---|
50 | // |
---|
51 | define region FLASH = FLASH1; |
---|
52 | define region RAM = AXI_RAM; |
---|
53 | |
---|
54 | // |
---|
55 | // Block definitions |
---|
56 | // |
---|
57 | define block vectors { section .vectors }; // Vector table section |
---|
58 | define block vectors_ram { section .vectors_ram }; // Vector table section |
---|
59 | define block ctors { section .ctors, section .ctors.*, block with alphabetical order { init_array } }; |
---|
60 | define block dtors { section .dtors, section .dtors.*, block with reverse alphabetical order { fini_array } }; |
---|
61 | define block exidx { section .ARM.exidx, section .ARM.exidx.* }; |
---|
62 | define block tbss { section .tbss, section .tbss.* }; |
---|
63 | define block tdata { section .tdata, section .tdata.* }; |
---|
64 | define block tls with fixed order { block tbss, block tdata }; |
---|
65 | define block tdata_load { copy of block tdata }; |
---|
66 | define block heap with auto size = __HEAPSIZE__, alignment = 8, /* fill =0x00, */ readwrite access { }; |
---|
67 | define block stack with size = __STACKSIZE__, alignment = 8, /* fill =0xCD, */ readwrite access { }; |
---|
68 | define block stack_process with size = __STACKSIZE_PROCESS__, alignment = 8, /* fill =0xCD, */ readwrite access { }; |
---|
69 | // |
---|
70 | // Explicit initialization settings for sections |
---|
71 | // Packing options for initialize by copy: packing=auto/lzss/zpak/packbits |
---|
72 | // |
---|
73 | do not initialize { section .non_init, section .non_init.*, section .*.non_init, section .*.non_init.* }; |
---|
74 | do not initialize { section .no_init, section .no_init.*, section .*.no_init, section .*.no_init.* }; // Legacy sections, kept for backwards compatibility |
---|
75 | do not initialize { section .noinit, section .noinit.*, section .*.noinit, section .*.noinit.* }; // Legacy sections, used by some SDKs/HALs |
---|
76 | do not initialize { block vectors_ram }; |
---|
77 | initialize by copy with packing=auto { section .data, section .data.*, section .*.data, section .*.data.* }; // Static data sections |
---|
78 | initialize by copy with packing=auto { section .fast, section .fast.*, section .*.fast, section .*.fast.* }; // "RAM Code" sections |
---|
79 | |
---|
80 | initialize by calling __SEGGER_STOP_X_InitLimits { section .data.stop.* }; |
---|
81 | |
---|
82 | #define USES_ALLOC_FUNC \ |
---|
83 | linked symbol malloc || linked symbol aligned_alloc || \ |
---|
84 | linked symbol calloc || linked symbol realloc |
---|
85 | |
---|
86 | initialize by calling __SEGGER_init_heap if USES_ALLOC_FUNC { block heap }; // Init the heap if one is required |
---|
87 | initialize by calling __SEGGER_init_ctors { block ctors }; // Call constructors for global objects which need to be constructed before reaching main (if any). Make sure this is done after setting up heap. |
---|
88 | |
---|
89 | //assert with warning "free() linked into application but there are no calls to an allocation function!" { |
---|
90 | // linked symbol free => USES_ALLOC_FUNC |
---|
91 | //}; |
---|
92 | |
---|
93 | assert with error "heap is too small!" { USES_ALLOC_FUNC => size of block heap >= 48 }; |
---|
94 | assert with error "heap size not a multiple of 8!" { USES_ALLOC_FUNC => size of block heap % 8 == 0 }; |
---|
95 | assert with error "heap not correctly aligned!" { USES_ALLOC_FUNC => start of block heap % 8 == 0 }; |
---|
96 | |
---|
97 | |
---|
98 | // |
---|
99 | // Explicit placement in FLASHn |
---|
100 | // |
---|
101 | place in FLASH1 { section .FLASH1, section .FLASH1.* }; |
---|
102 | // |
---|
103 | // FLASH Placement |
---|
104 | // |
---|
105 | place at start of FLASH { block vectors }; // Vector table section |
---|
106 | place in FLASH with minimum size order { block tdata_load, // Thread-local-storage load image |
---|
107 | block exidx, // ARM exception unwinding block |
---|
108 | block ctors, // Constructors block |
---|
109 | block dtors, // Destructors block |
---|
110 | readonly, // Catch-all for readonly data (e.g. .rodata, .srodata) |
---|
111 | readexec // Catch-all for (readonly) executable code (e.g. .text) |
---|
112 | }; |
---|
113 | |
---|
114 | // |
---|
115 | // Explicit placement in RAMn |
---|
116 | // |
---|
117 | place in RAM1 { section .RAM1, section .RAM1.* }; |
---|
118 | // |
---|
119 | // RAM Placement |
---|
120 | // |
---|
121 | place at start of RAM { block vectors_ram }; |
---|
122 | place in RAM with auto order { section .fast, section .fast.*, // "ramfunc" section |
---|
123 | block tls, // Thread-local-storage block |
---|
124 | readwrite, // Catch-all for initialized/uninitialized data sections (e.g. .data, .noinit) |
---|
125 | zeroinit // Catch-all for zero-initialized data sections (e.g. .bss) |
---|
126 | }; |
---|
127 | place in DTCM_RAM { block heap }; // Heap reserved block |
---|
128 | place at end of DTCM_RAM with fixed order { block stack_process, |
---|
129 | block stack }; // Stack reserved block at the end |
---|