1/***************************************************************************//** 2* \file cyb06xx5_cm4.ld 3* \version 2.95.1 4* 5* Linker file for the GNU C compiler. 6* 7* The main purpose of the linker script is to describe how the sections in the 8* input files should be mapped into the output file, and to control the memory 9* layout of the output file. 10* 11* \note The entry point location is fixed and starts at 0x10020000. The valid 12* application image should be placed there. 13* 14* \note The linker files included with the PDL template projects must be generic 15* and handle all common use cases. Your project may not use every section 16* defined in the linker files. In that case you may see warnings during the 17* build process. In your project, you can simply comment out or remove the 18* relevant code in the linker file. 19* 20******************************************************************************** 21* \copyright 22* Copyright 2016-2021 Cypress Semiconductor Corporation 23* SPDX-License-Identifier: Apache-2.0 24* 25* Licensed under the Apache License, Version 2.0 (the "License"); 26* you may not use this file except in compliance with the License. 27* You may obtain a copy of the License at 28* 29* http://www.apache.org/licenses/LICENSE-2.0 30* 31* Unless required by applicable law or agreed to in writing, software 32* distributed under the License is distributed on an "AS IS" BASIS, 33* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 34* See the License for the specific language governing permissions and 35* limitations under the License. 36*******************************************************************************/ 37 38OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") 39SEARCH_DIR(.) 40GROUP(-lgcc -lc -lnosys) 41ENTRY(Reset_Handler) 42 43/* The size of the stack section at the end of CM4 SRAM */ 44STACK_SIZE = 0x1000; 45 46/* The size of the MCU boot header area at the start of FLASH */ 47BOOT_HEADER_SIZE = 0x400; 48 49/* Force symbol to be entered in the output file as an undefined symbol. Doing 50* this may, for example, trigger linking of additional modules from standard 51* libraries. You may list several symbols for each EXTERN, and you may use 52* EXTERN multiple times. This command has the same effect as the -u command-line 53* option. 54*/ 55EXTERN(Reset_Handler) 56 57/* The MEMORY section below describes the location and size of blocks of memory in the target. 58* Use this section to specify the memory regions available for allocation. 59*/ 60MEMORY 61{ 62 /* The ram and flash regions control RAM and flash memory allocation for the CM4 core. 63 */ 64 ram (rwx) : ORIGIN = 0x08001800, LENGTH = 0x1E800 65 flash (rx) : ORIGIN = 0x10020000, LENGTH = 0x20000 66 67 68 /* The following regions define device specific memory regions and must not be changed. */ 69 xip (rx) : ORIGIN = 0x18000000, LENGTH = 0x8000000 /* 128 MB */ 70} 71 72/* Library configurations */ 73GROUP(libgcc.a libc.a libm.a libnosys.a) 74 75/* Linker script to place sections and symbol values. Should be used together 76 * with other linker script that defines memory regions FLASH and RAM. 77 * It references following symbols, which must be defined in code: 78 * Reset_Handler : Entry of reset handler 79 * 80 * It defines following symbols, which code can use without definition: 81 * __exidx_start 82 * __exidx_end 83 * __copy_table_start__ 84 * __copy_table_end__ 85 * __zero_table_start__ 86 * __zero_table_end__ 87 * __etext 88 * __data_start__ 89 * __preinit_array_start 90 * __preinit_array_end 91 * __init_array_start 92 * __init_array_end 93 * __fini_array_start 94 * __fini_array_end 95 * __data_end__ 96 * __bss_start__ 97 * __bss_end__ 98 * __end__ 99 * end 100 * __HeapLimit 101 * __StackLimit 102 * __StackTop 103 * __stack 104 * __Vectors_End 105 * __Vectors_Size 106 */ 107 108 109SECTIONS 110{ 111 /* Cortex-M4 application flash area */ 112 .text ORIGIN(flash) + BOOT_HEADER_SIZE : 113 { 114 /* Cortex-M4 flash vector table */ 115 . = ALIGN(4); 116 __Vectors = . ; 117 KEEP(*(.vectors)) 118 . = ALIGN(4); 119 __Vectors_End = .; 120 __Vectors_Size = __Vectors_End - __Vectors; 121 __end__ = .; 122 123 . = ALIGN(4); 124 *(.text*) 125 126 KEEP(*(.init)) 127 KEEP(*(.fini)) 128 129 /* .ctors */ 130 *crtbegin.o(.ctors) 131 *crtbegin?.o(.ctors) 132 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) 133 *(SORT(.ctors.*)) 134 *(.ctors) 135 136 /* .dtors */ 137 *crtbegin.o(.dtors) 138 *crtbegin?.o(.dtors) 139 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) 140 *(SORT(.dtors.*)) 141 *(.dtors) 142 143 /* Read-only code (constants). */ 144 *(.rodata .rodata.* .constdata .constdata.* .conststring .conststring.*) 145 146 KEEP(*(.eh_frame*)) 147 } > flash 148 149 150 .ARM.extab : 151 { 152 *(.ARM.extab* .gnu.linkonce.armextab.*) 153 } > flash 154 155 __exidx_start = .; 156 157 .ARM.exidx : 158 { 159 *(.ARM.exidx* .gnu.linkonce.armexidx.*) 160 } > flash 161 __exidx_end = .; 162 163 164 /* To copy multiple ROM to RAM sections, 165 * uncomment .copy.table section and, 166 * define __STARTUP_COPY_MULTIPLE in startup_psoc6_03_cm4.S */ 167 .copy.table : 168 { 169 . = ALIGN(4); 170 __copy_table_start__ = .; 171 172 /* Copy interrupt vectors from flash to RAM */ 173 LONG (__Vectors) /* From */ 174 LONG (__ram_vectors_start__) /* To */ 175 LONG (__Vectors_End - __Vectors) /* Size */ 176 177 /* Copy data section to RAM */ 178 LONG (__etext) /* From */ 179 LONG (__data_start__) /* To */ 180 LONG (__data_end__ - __data_start__) /* Size */ 181 182 __copy_table_end__ = .; 183 } > flash 184 185 186 /* To clear multiple BSS sections, 187 * uncomment .zero.table section and, 188 * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_psoc6_03_cm4.S */ 189 .zero.table : 190 { 191 . = ALIGN(4); 192 __zero_table_start__ = .; 193 LONG (__bss_start__) 194 LONG (__bss_end__ - __bss_start__) 195 __zero_table_end__ = .; 196 } > flash 197 198 __etext = . ; 199 200 201 .ramVectors (NOLOAD) : ALIGN(8) 202 { 203 __ram_vectors_start__ = .; 204 KEEP(*(.ram_vectors)) 205 __ram_vectors_end__ = .; 206 } > ram 207 208 209 .data __ram_vectors_end__ : 210 { 211 . = ALIGN(4); 212 __data_start__ = .; 213 214 *(vtable) 215 *(.data*) 216 217 . = ALIGN(4); 218 /* preinit data */ 219 PROVIDE_HIDDEN (__preinit_array_start = .); 220 KEEP(*(.preinit_array)) 221 PROVIDE_HIDDEN (__preinit_array_end = .); 222 223 . = ALIGN(4); 224 /* init data */ 225 PROVIDE_HIDDEN (__init_array_start = .); 226 KEEP(*(SORT(.init_array.*))) 227 KEEP(*(.init_array)) 228 PROVIDE_HIDDEN (__init_array_end = .); 229 230 . = ALIGN(4); 231 /* finit data */ 232 PROVIDE_HIDDEN (__fini_array_start = .); 233 KEEP(*(SORT(.fini_array.*))) 234 KEEP(*(.fini_array)) 235 PROVIDE_HIDDEN (__fini_array_end = .); 236 237 KEEP(*(.jcr*)) 238 . = ALIGN(4); 239 240 KEEP(*(.cy_ramfunc*)) 241 . = ALIGN(4); 242 243 __data_end__ = .; 244 245 } > ram AT>flash 246 247 248 /* Place variables in the section that should not be initialized during the 249 * device startup. 250 */ 251 .noinit (NOLOAD) : ALIGN(8) 252 { 253 KEEP(*(.noinit)) 254 } > ram 255 256 257 /* The uninitialized global or static variables are placed in this section. 258 * 259 * The NOLOAD attribute tells linker that .bss section does not consume 260 * any space in the image. The NOLOAD attribute changes the .bss type to 261 * NOBITS, and that makes linker to A) not allocate section in memory, and 262 * A) put information to clear the section with all zeros during application 263 * loading. 264 * 265 * Without the NOLOAD attribute, the .bss section might get PROGBITS type. 266 * This makes linker to A) allocate zeroed section in memory, and B) copy 267 * this section to RAM during application loading. 268 */ 269 .bss (NOLOAD): 270 { 271 . = ALIGN(4); 272 __bss_start__ = .; 273 *(.bss*) 274 *(COMMON) 275 . = ALIGN(4); 276 __bss_end__ = .; 277 } > ram 278 279 280 .heap (NOLOAD): 281 { 282 __HeapBase = .; 283 __end__ = .; 284 end = __end__; 285 KEEP(*(.heap*)) 286 . = ORIGIN(ram) + LENGTH(ram) - STACK_SIZE; 287 __HeapLimit = .; 288 } > ram 289 290 291 /* .stack_dummy section doesn't contains any symbols. It is only 292 * used for linker to calculate size of stack sections, and assign 293 * values to stack symbols later */ 294 .stack_dummy (NOLOAD): 295 { 296 KEEP(*(.stack*)) 297 } > ram 298 299 300 /* Set stack top to end of RAM, and stack limit move down by 301 * size of stack_dummy section */ 302 __StackTop = ORIGIN(ram) + LENGTH(ram); 303 __StackLimit = __StackTop - SIZEOF(.stack_dummy); 304 PROVIDE(__stack = __StackTop); 305 306 /* Check if data + heap + stack exceeds RAM limit */ 307 ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") 308 309 310 /* Used for the digital signature of the secure application and the Bootloader SDK application. 311 * The size of the section depends on the required data size. */ 312 .cy_app_signature ORIGIN(flash) + LENGTH(flash) - 256 : 313 { 314 KEEP(*(.cy_app_signature)) 315 } > flash 316 317 318 319 320 /* Places the code in the Execute in Place (XIP) section. See the smif driver 321 * documentation for details. 322 */ 323 cy_xip : 324 { 325 __cy_xip_start = .; 326 KEEP(*(.cy_xip)) 327 __cy_xip_end = .; 328 } > xip 329 330 331} 332 333 334/* EOF */ 335