1/***************************************************************************//** 2* \file cy8c6xx7_cm0plus.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 0x10000000. 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 CM0+ SRAM */ 44STACK_SIZE = 0x1000; 45 46/* Force symbol to be entered in the output file as an undefined symbol. Doing 47* this may, for example, trigger linking of additional modules from standard 48* libraries. You may list several symbols for each EXTERN, and you may use 49* EXTERN multiple times. This command has the same effect as the -u command-line 50* option. 51*/ 52EXTERN(Reset_Handler) 53 54/* The MEMORY section below describes the location and size of blocks of memory in the target. 55* Use this section to specify the memory regions available for allocation. 56*/ 57MEMORY 58{ 59 /* The ram and flash regions control RAM and flash memory allocation for the CM0+ core. 60 * You can change the memory allocation by editing the 'ram' and 'flash' regions. 61 * Note that 2 KB of RAM (at the end of the SRAM) are reserved for system use. 62 * Using this memory region for other purposes will lead to unexpected behavior. 63 * Your changes must be aligned with the corresponding memory regions for the CM4 core in 'xx_cm4_dual.ld', 64 * where 'xx' is the device group; for example, 'cy8c6xx7_cm4_dual.ld'. 65 */ 66 ram (rwx) : ORIGIN = 0x08000000, LENGTH = 0x2000 67 flash (rx) : ORIGIN = 0x10000000, LENGTH = 0x2000 68 69 70 /* This is an unprotected public RAM region, with the placed .cy_sharedmem. 71 * This region is used to place objects that require full access from both cores. 72 * Uncomment the following line, define the region origin and length, and uncomment the placement of 73 * the .cy_sharedmem section below. 74 */ 75 /* public_ram (rw) : ORIGIN = %REGION_START_ADDRESS%, LENGTH = %REGION_SIZE% */ 76 77 /* This is a 32K flash region used for EEPROM emulation. This region can also be used as the general purpose flash. 78 * You can assign sections to this memory region for only one of the cores. 79 * Note some middleware (e.g. BLE, Emulated EEPROM) can place their data into this memory region. 80 * Therefore, repurposing this memory region will prevent such middleware from operation. 81 */ 82 em_eeprom (rx) : ORIGIN = 0x14000000, LENGTH = 0x8000 /* 32 KB */ 83 84 /* The following regions define device specific memory regions and must not be changed. */ 85 sflash_user_data (rx) : ORIGIN = 0x16000800, LENGTH = 0x800 /* Supervisory flash: User data */ 86 sflash_nar (rx) : ORIGIN = 0x16001A00, LENGTH = 0x200 /* Supervisory flash: Normal Access Restrictions (NAR) */ 87 sflash_public_key (rx) : ORIGIN = 0x16005A00, LENGTH = 0xC00 /* Supervisory flash: Public Key */ 88 sflash_toc_2 (rx) : ORIGIN = 0x16007C00, LENGTH = 0x200 /* Supervisory flash: Table of Content # 2 */ 89 sflash_rtoc_2 (rx) : ORIGIN = 0x16007E00, LENGTH = 0x200 /* Supervisory flash: Table of Content # 2 Copy */ 90 xip (rx) : ORIGIN = 0x18000000, LENGTH = 0x8000000 /* 128 MB */ 91 efuse (r) : ORIGIN = 0x90700000, LENGTH = 0x100000 /* 1 MB */ 92} 93 94/* Library configurations */ 95GROUP(libgcc.a libc.a libm.a libnosys.a) 96 97/* Linker script to place sections and symbol values. Should be used together 98 * with other linker script that defines memory regions FLASH and RAM. 99 * It references following symbols, which must be defined in code: 100 * Reset_Handler : Entry of reset handler 101 * 102 * It defines following symbols, which code can use without definition: 103 * __exidx_start 104 * __exidx_end 105 * __copy_table_start__ 106 * __copy_table_end__ 107 * __zero_table_start__ 108 * __zero_table_end__ 109 * __etext 110 * __data_start__ 111 * __preinit_array_start 112 * __preinit_array_end 113 * __init_array_start 114 * __init_array_end 115 * __fini_array_start 116 * __fini_array_end 117 * __data_end__ 118 * __bss_start__ 119 * __bss_end__ 120 * __end__ 121 * end 122 * __HeapLimit 123 * __StackLimit 124 * __StackTop 125 * __stack 126 * __Vectors_End 127 * __Vectors_Size 128 */ 129 130 131SECTIONS 132{ 133 .cy_app_header : 134 { 135 KEEP(*(.cy_app_header)) 136 } > flash 137 138 /* Cortex-M0+ application flash area */ 139 .text : 140 { 141 . = ALIGN(4); 142 __Vectors = . ; 143 KEEP(*(.vectors)) 144 . = ALIGN(4); 145 __Vectors_End = .; 146 __Vectors_Size = __Vectors_End - __Vectors; 147 __end__ = .; 148 149 . = ALIGN(4); 150 *(.text*) 151 152 KEEP(*(.init)) 153 KEEP(*(.fini)) 154 155 /* .ctors */ 156 *crtbegin.o(.ctors) 157 *crtbegin?.o(.ctors) 158 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) 159 *(SORT(.ctors.*)) 160 *(.ctors) 161 162 /* .dtors */ 163 *crtbegin.o(.dtors) 164 *crtbegin?.o(.dtors) 165 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) 166 *(SORT(.dtors.*)) 167 *(.dtors) 168 169 /* Read-only code (constants). */ 170 *(.rodata .rodata.* .constdata .constdata.* .conststring .conststring.*) 171 172 KEEP(*(.eh_frame*)) 173 } > flash 174 175 176 .ARM.extab : 177 { 178 *(.ARM.extab* .gnu.linkonce.armextab.*) 179 } > flash 180 181 __exidx_start = .; 182 183 .ARM.exidx : 184 { 185 *(.ARM.exidx* .gnu.linkonce.armexidx.*) 186 } > flash 187 __exidx_end = .; 188 189 190 /* To copy multiple ROM to RAM sections, 191 * uncomment .copy.table section and, 192 * define __STARTUP_COPY_MULTIPLE in startup_psoc6_01_cm0plus.S */ 193 .copy.table : 194 { 195 . = ALIGN(4); 196 __copy_table_start__ = .; 197 198 /* Copy interrupt vectors from flash to RAM */ 199 LONG (__Vectors) /* From */ 200 LONG (__ram_vectors_start__) /* To */ 201 LONG (__Vectors_End - __Vectors) /* Size */ 202 203 /* Copy data section to RAM */ 204 LONG (__etext) /* From */ 205 LONG (__data_start__) /* To */ 206 LONG (__data_end__ - __data_start__) /* Size */ 207 208 __copy_table_end__ = .; 209 } > flash 210 211 212 /* To clear multiple BSS sections, 213 * uncomment .zero.table section and, 214 * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_psoc6_01_cm0plus.S */ 215 .zero.table : 216 { 217 . = ALIGN(4); 218 __zero_table_start__ = .; 219 LONG (__bss_start__) 220 LONG (__bss_end__ - __bss_start__) 221 __zero_table_end__ = .; 222 } > flash 223 224 __etext = . ; 225 226 227 .ramVectors (NOLOAD) : ALIGN(8) 228 { 229 __ram_vectors_start__ = .; 230 KEEP(*(.ram_vectors)) 231 __ram_vectors_end__ = .; 232 } > ram 233 234 235 .data __ram_vectors_end__ : 236 { 237 . = ALIGN(4); 238 __data_start__ = .; 239 240 *(vtable) 241 *(.data*) 242 243 . = ALIGN(4); 244 /* preinit data */ 245 PROVIDE_HIDDEN (__preinit_array_start = .); 246 KEEP(*(.preinit_array)) 247 PROVIDE_HIDDEN (__preinit_array_end = .); 248 249 . = ALIGN(4); 250 /* init data */ 251 PROVIDE_HIDDEN (__init_array_start = .); 252 KEEP(*(SORT(.init_array.*))) 253 KEEP(*(.init_array)) 254 PROVIDE_HIDDEN (__init_array_end = .); 255 256 . = ALIGN(4); 257 /* finit data */ 258 PROVIDE_HIDDEN (__fini_array_start = .); 259 KEEP(*(SORT(.fini_array.*))) 260 KEEP(*(.fini_array)) 261 PROVIDE_HIDDEN (__fini_array_end = .); 262 263 KEEP(*(.jcr*)) 264 . = ALIGN(4); 265 266 KEEP(*(.cy_ramfunc*)) 267 . = ALIGN(4); 268 269 __data_end__ = .; 270 271 } > ram AT>flash 272 273 274 /* Place variables in the section that should not be initialized during the 275 * device startup. 276 */ 277 .noinit (NOLOAD) : ALIGN(8) 278 { 279 KEEP(*(.noinit)) 280 } > ram 281 282 283 /* The uninitialized global or static variables are placed in this section. 284 * 285 * The NOLOAD attribute tells linker that .bss section does not consume 286 * any space in the image. The NOLOAD attribute changes the .bss type to 287 * NOBITS, and that makes linker to A) not allocate section in memory, and 288 * A) put information to clear the section with all zeros during application 289 * loading. 290 * 291 * Without the NOLOAD attribute, the .bss section might get PROGBITS type. 292 * This makes linker to A) allocate zeroed section in memory, and B) copy 293 * this section to RAM during application loading. 294 */ 295 .bss (NOLOAD): 296 { 297 . = ALIGN(4); 298 __bss_start__ = .; 299 *(.bss*) 300 *(COMMON) 301 . = ALIGN(4); 302 __bss_end__ = .; 303 } > ram 304 305 306 .heap (NOLOAD): 307 { 308 __HeapBase = .; 309 __end__ = .; 310 end = __end__; 311 KEEP(*(.heap*)) 312 . = ORIGIN(ram) + LENGTH(ram) - STACK_SIZE; 313 __HeapLimit = .; 314 } > ram 315 316 317 /* To use unprotected public RAM, uncomment the following .cy_sharedmem section placement.*/ 318 /* 319 .cy_sharedmem (NOLOAD): 320 { 321 . = ALIGN(4); 322 __public_ram_start__ = .; 323 KEEP(*(.cy_sharedmem)) 324 . = ALIGN(4); 325 __public_ram_end__ = .; 326 } > public_ram 327 */ 328 329 /* .stack_dummy section doesn't contains any symbols. It is only 330 * used for linker to calculate size of stack sections, and assign 331 * values to stack symbols later */ 332 .stack_dummy (NOLOAD): 333 { 334 KEEP(*(.stack*)) 335 } > ram 336 337 338 /* Set stack top to end of RAM, and stack limit move down by 339 * size of stack_dummy section */ 340 __StackTop = ORIGIN(ram) + LENGTH(ram); 341 __StackLimit = __StackTop - SIZEOF(.stack_dummy); 342 PROVIDE(__stack = __StackTop); 343 344 /* Check if data + heap + stack exceeds RAM limit */ 345 ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") 346 347 348 /* Emulated EEPROM Flash area */ 349 .cy_em_eeprom : 350 { 351 KEEP(*(.cy_em_eeprom)) 352 } > em_eeprom 353 354 355 /* Supervisory Flash: User data */ 356 .cy_sflash_user_data : 357 { 358 KEEP(*(.cy_sflash_user_data)) 359 } > sflash_user_data 360 361 362 /* Supervisory Flash: Normal Access Restrictions (NAR) */ 363 .cy_sflash_nar : 364 { 365 KEEP(*(.cy_sflash_nar)) 366 } > sflash_nar 367 368 369 /* Supervisory Flash: Public Key */ 370 .cy_sflash_public_key : 371 { 372 KEEP(*(.cy_sflash_public_key)) 373 } > sflash_public_key 374 375 376 /* Supervisory Flash: Table of Content # 2 */ 377 .cy_toc_part2 : 378 { 379 KEEP(*(.cy_toc_part2)) 380 } > sflash_toc_2 381 382 383 /* Supervisory Flash: Table of Content # 2 Copy */ 384 .cy_rtoc_part2 : 385 { 386 KEEP(*(.cy_rtoc_part2)) 387 } > sflash_rtoc_2 388 389 390 /* Places the code in the Execute in Place (XIP) section. See the smif driver 391 * documentation for details. 392 */ 393 cy_xip : 394 { 395 __cy_xip_start = .; 396 KEEP(*(.cy_xip)) 397 __cy_xip_end = .; 398 } > xip 399 400 401 /* eFuse */ 402 .cy_efuse : 403 { 404 KEEP(*(.cy_efuse)) 405 } > efuse 406 407 408 /* These sections are used for additional metadata (silicon revision, 409 * Silicon/JTAG ID, etc.) storage. 410 */ 411 .cymeta 0x90500000 : { KEEP(*(.cymeta)) } :NONE 412} 413 414 415/* The following symbols used by the cymcuelftool. */ 416/* Flash */ 417__cy_memory_0_start = 0x10000000; 418__cy_memory_0_length = 0x00100000; 419__cy_memory_0_row_size = 0x200; 420 421/* Emulated EEPROM Flash area */ 422__cy_memory_1_start = 0x14000000; 423__cy_memory_1_length = 0x8000; 424__cy_memory_1_row_size = 0x200; 425 426/* Supervisory Flash */ 427__cy_memory_2_start = 0x16000000; 428__cy_memory_2_length = 0x8000; 429__cy_memory_2_row_size = 0x200; 430 431/* XIP */ 432__cy_memory_3_start = 0x18000000; 433__cy_memory_3_length = 0x08000000; 434__cy_memory_3_row_size = 0x200; 435 436/* eFuse */ 437__cy_memory_4_start = 0x90700000; 438__cy_memory_4_length = 0x100000; 439__cy_memory_4_row_size = 1; 440 441/* EOF */ 442