xref: /btstack/port/renesas-tb-s1ja-cc256x/template/btstack_example/script/s1ja.ld (revision 3b5c872a8c45689e8cc17891f01530f5aa5e911c)
1/*
2                  Linker File for S1JA MCU
3*/
4
5/* Linker script to configure memory regions. */
6MEMORY
7{
8  FLASH (rx)         : ORIGIN = 0x00000000, LENGTH = 0x040000  /* 256K */
9
10
11
12  RAM (rwx)          : ORIGIN = 0x20000000, LENGTH = 0x008000  /* 32K  */
13  DATA_FLASH (rx)    : ORIGIN = 0x40100000, LENGTH = 0x0002000 /*  8K  */
14  ID_CODE_1 (rx)      : ORIGIN = 0x01010018, LENGTH = 0x04     /* 4 bytes */
15  ID_CODE_2 (rx)      : ORIGIN = 0x01010020, LENGTH = 0x04     /* 4 bytes */
16  ID_CODE_3 (rx)      : ORIGIN = 0x01010028, LENGTH = 0x04     /* 4 bytes */
17  ID_CODE_4 (rx)      : ORIGIN = 0x01010030, LENGTH = 0x04     /* 4 bytes */
18}
19
20/* Library configurations */
21GROUP(libgcc.a libc.a libm.a libnosys.a)
22
23/* Linker script to place sections and symbol values. Should be used together
24 * with other linker script that defines memory regions FLASH and RAM.
25 * It references following symbols, which must be defined in code:
26 *   Reset_Handler : Entry of reset handler
27 *
28 * It defines following symbols, which code can use without definition:
29 *   __exidx_start
30 *   __exidx_end
31 *   __copy_table_start__
32 *   __copy_table_end__
33 *   __zero_table_start__
34 *   __zero_table_end__
35 *   __etext
36 *   __data_start__
37 *   __preinit_array_start
38 *   __preinit_array_end
39 *   __init_array_start
40 *   __init_array_end
41 *   __fini_array_start
42 *   __fini_array_end
43 *   __data_end__
44 *   __bss_start__
45 *   __bss_end__
46 *   __end__
47 *   end
48 *   __HeapLimit
49 *   __StackLimit
50 *   __StackTop
51 *   __stack
52 *   __Vectors_End
53 *   __Vectors_Size
54 */
55ENTRY(Reset_Handler)
56
57SECTIONS
58{
59    .text :
60    {
61        __ROM_Start = .;
62
63        /* Even though the vector table is not 256 entries (1KB) long, we still allocate that much
64         * space because ROM registers are at address 0x400 and there is very little space
65         * in between. */
66        KEEP(*(.vectors))
67        KEEP(*(SORT_BY_NAME(.vector.*)))
68        __Vectors_End = .;
69        __end__ = .;
70
71        /* ROM Registers start at address 0x00000400 */
72        . = __ROM_Start + 0x400;
73        KEEP(*(.rom_registers*))
74
75        /* Reserving 0x100 bytes of space for ROM registers. */
76        . = __ROM_Start + 0x500;
77
78        /* Vector information array. */
79        __Vector_Info_Start = .;
80        KEEP(*(SORT_BY_NAME(.vector_info.*)))
81        __Vector_Info_End = .;
82
83        /* Hardware lock lookup array. */
84        __Lock_Lookup_Start = .;
85        KEEP(*(SORT_BY_NAME(.hw_lock_lookup.*)))
86        __Lock_Lookup_End = .;
87
88        *(.text*)
89
90        KEEP(*(.init))
91        KEEP(*(.fini))
92
93        /* .ctors */
94        *crtbegin.o(.ctors)
95        *crtbegin?.o(.ctors)
96        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
97        *(SORT(.ctors.*))
98        *(.ctors)
99
100        /* .dtors */
101        *crtbegin.o(.dtors)
102        *crtbegin?.o(.dtors)
103        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
104        *(SORT(.dtors.*))
105        *(.dtors)
106
107        *(.rodata*)
108        __usb_dev_descriptor_start_fs = .;
109        KEEP(*(.usb_device_desc_fs*))
110        __usb_cfg_descriptor_start_fs = .;
111        KEEP(*(.usb_config_desc_fs*))
112        __usb_interface_descriptor_start_fs = .;
113        KEEP(*(.usb_interface_desc_fs*))
114        __usb_descriptor_end_fs = .;
115
116        KEEP(*(.eh_frame*))
117
118        __ROM_End = .;
119    } > FLASH = 0xFF
120
121    __Vectors_Size = __Vectors_End - __Vectors;
122    __Vector_Info_Size = __Vector_Info_End - __Vector_Info_Start;
123    __Lock_Lookup_Size = __Lock_Lookup_End - __Lock_Lookup_Start;
124
125    .ARM.extab :
126    {
127        *(.ARM.extab* .gnu.linkonce.armextab.*)
128    } > FLASH
129
130    __exidx_start = .;
131    .ARM.exidx :
132    {
133        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
134    } > FLASH
135    __exidx_end = .;
136
137    /* To copy multiple ROM to RAM sections,
138     * uncomment .copy.table section and,
139     * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
140    /*
141    .copy.table :
142    {
143        . = ALIGN(4);
144        __copy_table_start__ = .;
145        LONG (__etext)
146        LONG (__data_start__)
147        LONG (__data_end__ - __data_start__)
148        LONG (__etext2)
149        LONG (__data2_start__)
150        LONG (__data2_end__ - __data2_start__)
151        __copy_table_end__ = .;
152    } > FLASH
153    */
154
155    /* To clear multiple BSS sections,
156     * uncomment .zero.table section and,
157     * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
158    /*
159    .zero.table :
160    {
161        . = ALIGN(4);
162        __zero_table_start__ = .;
163        LONG (__bss_start__)
164        LONG (__bss_end__ - __bss_start__)
165        LONG (__bss2_start__)
166        LONG (__bss2_end__ - __bss2_start__)
167        __zero_table_end__ = .;
168    } > FLASH
169    */
170
171    __etext = .;
172
173    /* If DTC is used, put the DTC vector table at the start of SRAM.
174       This avoids memory holes due to 1K alignment required by it. */
175    .ssp_dtc_vector_table (NOLOAD) :
176    {
177        . = ORIGIN(RAM);
178        *(.ssp_dtc_vector_table)
179    } > RAM
180
181    /* Initialized data section. */
182    .data :
183    {
184        __data_start__ = .;
185        *(vtable)
186        *(.data.*)
187
188        . = ALIGN(4);
189        /* preinit data */
190        PROVIDE_HIDDEN (__preinit_array_start = .);
191        KEEP(*(.preinit_array))
192        PROVIDE_HIDDEN (__preinit_array_end = .);
193
194        . = ALIGN(4);
195        /* init data */
196        PROVIDE_HIDDEN (__init_array_start = .);
197        KEEP(*(SORT(.init_array.*)))
198        KEEP(*(.init_array))
199        PROVIDE_HIDDEN (__init_array_end = .);
200
201
202        . = ALIGN(4);
203        /* finit data */
204        PROVIDE_HIDDEN (__fini_array_start = .);
205        KEEP(*(SORT(.fini_array.*)))
206        KEEP(*(.fini_array))
207        PROVIDE_HIDDEN (__fini_array_end = .);
208
209        KEEP(*(.jcr*))
210        . = ALIGN(4);
211
212        __Code_In_RAM_Start = .;
213
214        KEEP(*(.code_in_ram*))
215        __Code_In_RAM_End = .;
216
217        /* Hardware look array. */
218        __Lock_Start = .;
219        KEEP(*(SORT_BY_NAME(.hw_lock*)))
220        __Lock_End = .;
221
222        /* All data end */
223        __data_end__ = .;
224
225    } > RAM AT > FLASH
226
227    __Lock_Size = __Lock_End - __Lock_Start;
228
229    .noinit (NOLOAD):
230    {
231        . = ALIGN(4);
232        __noinit_start = .;
233        KEEP(*(.noinit*))
234        __noinit_end = .;
235    } > RAM
236
237    .bss :
238    {
239        . = ALIGN(4);
240        __bss_start__ = .;
241        *(.bss*)
242        *(COMMON)
243        . = ALIGN(4);
244        __bss_end__ = .;
245    } > RAM
246
247    .heap (NOLOAD):
248    {
249        . = ALIGN(8);
250        __HeapBase = .;
251        __end__ = .;
252        end = __end__;
253        KEEP(*(.heap*))
254        __HeapLimit = .;
255    } > RAM
256
257    /* Stacks are stored in this section. */
258    .stack_dummy (NOLOAD):
259    {
260        . = ALIGN(8);
261        __StackLimit = .;
262        /* Main stack */
263        KEEP(*(.stack))
264        __StackTop = .;
265        /* Thread stacks */
266        KEEP(*(.stack*))
267        __StackTopAll = .;
268    } > RAM
269
270    PROVIDE(__stack = __StackTopAll);
271
272    /* This symbol represents the end of user allocated RAM. The RAM after this symbol can be used
273       at run time for things such as ThreadX memory pool allocations. */
274    __RAM_segment_used_end__ = ALIGN(__StackTopAll , 4);
275
276    /* Data flash. */
277    .data_flash :
278    {
279        __Data_Flash_Start = .;
280        KEEP(*(.data_flash*))
281        __Data_Flash_End = .;
282    } > DATA_FLASH
283
284    .id_code_1 :
285    {
286        __ID_Code_1_Start = .;
287        KEEP(*(.id_code_1*))
288        __ID_Code_1_End = .;
289    } > ID_CODE_1
290
291    .id_code_2 :
292    {
293        __ID_Code_2_Start = .;
294        KEEP(*(.id_code_2*))
295        __ID_Code_2_End = .;
296    } > ID_CODE_2
297
298    .id_code_3 :
299    {
300        __ID_Code_3_Start = .;
301        KEEP(*(.id_code_3*))
302        __ID_Code_3_End = .;
303    } > ID_CODE_3
304
305    .id_code_4 :
306    {
307        __ID_Code_4_Start = .;
308        KEEP(*(.id_code_4*))
309        __ID_Code_4_End = .;
310    } > ID_CODE_4
311}
312