1/* 2 * Copyright (c) 2021 NXP 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7OUTPUT_ARCH(xtensa) 8 9#include <soc/memory.h> 10#include <xtensa/config/core-isa.h> 11 12#include <zephyr/linker/linker-defs.h> 13#include <zephyr/linker/linker-tool.h> 14#include <zephyr/linker/sections.h> 15 16#define RAMABLE_REGION sdram0 :sdram0_phdr 17#define ROMABLE_REGION sdram0 :sdram0_phdr 18 19MEMORY 20{ 21 vector_reset_text : 22 org = XCHAL_RESET_VECTOR0_PADDR_IRAM, 23 len = MEM_RESET_TEXT_SIZE 24 vector_reset_lit : 25 org = XCHAL_RESET_VECTOR0_PADDR_IRAM + MEM_RESET_TEXT_SIZE, 26 len = MEM_RESET_LIT_SIZE 27 vector_base_text : 28 org = XCHAL_VECBASE_RESET_PADDR_IRAM, 29 len = MEM_VECBASE_LIT_SIZE 30 vector_int2_lit : 31 org = XCHAL_INTLEVEL2_VECTOR_PADDR_IRAM - MEM_VECT_LIT_SIZE, 32 len = MEM_VECT_LIT_SIZE 33 vector_int2_text : 34 org = XCHAL_INTLEVEL2_VECTOR_PADDR_IRAM, 35 len = MEM_VECT_TEXT_SIZE 36 vector_int3_lit : 37 org = XCHAL_INTLEVEL3_VECTOR_PADDR_IRAM - MEM_VECT_LIT_SIZE, 38 len = MEM_VECT_LIT_SIZE 39 vector_int3_text : 40 org = XCHAL_INTLEVEL3_VECTOR_PADDR_IRAM, 41 len = MEM_VECT_TEXT_SIZE 42 vector_int4_lit : 43 org = XCHAL_INTLEVEL4_VECTOR_PADDR_IRAM - MEM_VECT_LIT_SIZE, 44 len = MEM_VECT_LIT_SIZE 45 vector_int4_text : 46 org = XCHAL_INTLEVEL4_VECTOR_PADDR_IRAM, 47 len = MEM_VECT_TEXT_SIZE 48 vector_int5_lit : 49 org = XCHAL_INTLEVEL5_VECTOR_PADDR_IRAM - MEM_VECT_LIT_SIZE, 50 len = MEM_VECT_LIT_SIZE 51 vector_int5_text : 52 org = XCHAL_INTLEVEL5_VECTOR_PADDR_IRAM, 53 len = MEM_VECT_TEXT_SIZE 54 vector_kernel_lit : 55 org = XCHAL_KERNEL_VECTOR_PADDR_IRAM - MEM_VECT_LIT_SIZE, 56 len = MEM_VECT_LIT_SIZE 57 vector_kernel_text : 58 org = XCHAL_KERNEL_VECTOR_PADDR_IRAM, 59 len = MEM_VECT_TEXT_SIZE 60 vector_user_lit : 61 org = XCHAL_USER_VECTOR_PADDR_IRAM - MEM_VECT_LIT_SIZE, 62 len = MEM_VECT_LIT_SIZE 63 vector_user_text : 64 org = XCHAL_USER_VECTOR_PADDR_IRAM, 65 len = MEM_VECT_TEXT_SIZE 66 vector_double_lit : 67 org = XCHAL_DOUBLEEXC_VECTOR_PADDR_IRAM - MEM_VECT_LIT_SIZE, 68 len = MEM_VECT_LIT_SIZE 69 vector_double_text : 70 org = XCHAL_DOUBLEEXC_VECTOR_PADDR_IRAM, 71 len = MEM_VECT_TEXT_SIZE 72 iram_text_start : 73 org = XCHAL_DOUBLEEXC_VECTOR_PADDR_IRAM + MEM_VECT_TEXT_SIZE, 74 len = (IRAM_BASE + IRAM_SIZE) - (XCHAL_DOUBLEEXC_VECTOR_PADDR + MEM_VECT_TEXT_SIZE) 75 sdram0 : 76 org = SDRAM0_BASE, 77 len = SDRAM0_SIZE 78#ifdef CONFIG_GEN_ISR_TABLES 79 IDT_LIST : 80 org = IDT_BASE, 81 len = IDT_SIZE 82#endif 83} 84 85PHDRS 86{ 87 vector_reset_text_phdr PT_LOAD; 88 vector_reset_lit_phdr PT_LOAD; 89 vector_base_text_phdr PT_LOAD; 90 vector_base_lit_phdr PT_LOAD; 91 vector_int2_text_phdr PT_LOAD; 92 vector_int2_lit_phdr PT_LOAD; 93 vector_int3_text_phdr PT_LOAD; 94 vector_int3_lit_phdr PT_LOAD; 95 vector_int4_text_phdr PT_LOAD; 96 vector_int4_lit_phdr PT_LOAD; 97 vector_int5_text_phdr PT_LOAD; 98 vector_int5_lit_phdr PT_LOAD; 99 vector_kernel_text_phdr PT_LOAD; 100 vector_kernel_lit_phdr PT_LOAD; 101 vector_user_text_phdr PT_LOAD; 102 vector_user_lit_phdr PT_LOAD; 103 vector_double_text_phdr PT_LOAD; 104 vector_double_lit_phdr PT_LOAD; 105 iram_text_start_phdr PT_LOAD; 106 sdram0_phdr PT_LOAD; 107} 108 109PROVIDE(_memmap_reset_vector = XCHAL_RESET_VECTOR0_PADDR_IRAM); 110PROVIDE(_memmap_vecbase_reset = XCHAL_VECBASE_RESET_PADDR_IRAM); 111 112ENTRY(CONFIG_KERNEL_ENTRY) 113 114/* Various memory-map dependent cache attribute settings: */ 115_memmap_cacheattr_wb_base = 0x00000012; 116_memmap_cacheattr_wt_base = 0x00000012; 117_memmap_cacheattr_bp_base = 0x00000022; 118_memmap_cacheattr_unused_mask = 0xFFFFFF00; 119_memmap_cacheattr_wb_trapnull = 0x22222212; 120_memmap_cacheattr_wba_trapnull = 0x22222212; 121_memmap_cacheattr_wbna_trapnull = 0x22222212; 122_memmap_cacheattr_wt_trapnull = 0x22222212; 123_memmap_cacheattr_bp_trapnull = 0x22222222; 124_memmap_cacheattr_wb_strict = 0xFFFFFF12; 125_memmap_cacheattr_wt_strict = 0xFFFFFF12; 126_memmap_cacheattr_bp_strict = 0xFFFFFF22; 127_memmap_cacheattr_wb_allvalid = 0x22222212; 128_memmap_cacheattr_wt_allvalid = 0x22222212; 129_memmap_cacheattr_bp_allvalid = 0x22222222; 130_memmap_region_map = 0x00000003; 131PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull); 132 133SECTIONS 134{ 135 136#include <zephyr/linker/rel-sections.ld> 137 138#ifdef CONFIG_LLEXT 139#include <zephyr/linker/llext-sections.ld> 140#endif 141 .ResetVector.text : ALIGN(4) 142 { 143 _ResetVector_text_start = ABSOLUTE(.); 144 KEEP (*(.ResetVector.text)) 145 _ResetVector_text_end = ABSOLUTE(.); 146 } >vector_reset_text :vector_reset_text_phdr 147 148 .ResetVector.literal : ALIGN(4) 149 { 150 _ResetVector_literal_start = ABSOLUTE(.); 151 *(.ResetVector.literal) 152 _ResetVector_literal_end = ABSOLUTE(.); 153 } >vector_reset_lit :vector_reset_lit_phdr 154 155 .WindowVectors.text : ALIGN(4) 156 { 157 _WindowVectors_text_start = ABSOLUTE(.); 158 KEEP (*(.WindowVectors.text)) 159 _WindowVectors_text_end = ABSOLUTE(.); 160 } >vector_base_text :vector_base_text_phdr 161 162 .Level2InterruptVector.literal : ALIGN(4) 163 { 164 _Level2InterruptVector_literal_start = ABSOLUTE(.); 165 *(.Level2InterruptVector.literal) 166 _Level2InterruptVector_literal_end = ABSOLUTE(.); 167 } >vector_int2_lit :vector_int2_lit_phdr 168 169 .Level2InterruptVector.text : ALIGN(4) 170 { 171 _Level2InterruptVector_text_start = ABSOLUTE(.); 172 KEEP (*(.Level2InterruptVector.text)) 173 _Level2InterruptVector_text_end = ABSOLUTE(.); 174 } >vector_int2_text :vector_int2_text_phdr 175 176 .Level3InterruptVector.literal : ALIGN(4) 177 { 178 _Level3InterruptVector_literal_start = ABSOLUTE(.); 179 *(.Level3InterruptVector.literal) 180 _Level3InterruptVector_literal_end = ABSOLUTE(.); 181 } >vector_int3_lit :vector_int3_lit_phdr 182 183 .Level3InterruptVector.text : ALIGN(4) 184 { 185 _Level3InterruptVector_text_start = ABSOLUTE(.); 186 KEEP (*(.Level3InterruptVector.text)) 187 _Level3InterruptVector_text_end = ABSOLUTE(.); 188 } >vector_int3_text :vector_int3_text_phdr 189 190 .DebugExceptionVector.literal : ALIGN(4) 191 { 192 _DebugExceptionVector_literal_start = ABSOLUTE(.); 193 *(.DebugExceptionVector.literal) 194 _DebugExceptionVector_literal_end = ABSOLUTE(.); 195 } >vector_int4_lit :vector_int4_lit_phdr 196 197 .DebugExceptionVector.text : ALIGN(4) 198 { 199 _DebugExceptionVector_text_start = ABSOLUTE(.); 200 KEEP (*(.DebugExceptionVector.text)) 201 _DebugExceptionVector_text_end = ABSOLUTE(.); 202 } >vector_int4_text :vector_int4_text_phdr 203 204 .NMIExceptionVector.literal : ALIGN(4) 205 { 206 _NMIExceptionVector_literal_start = ABSOLUTE(.); 207 *(.NMIExceptionVector.literal) 208 _NMIExceptionVector_literal_end = ABSOLUTE(.); 209 } >vector_int5_lit :vector_int5_lit_phdr 210 211 .NMIExceptionVector.text : ALIGN(4) 212 { 213 _NMIExceptionVector_text_start = ABSOLUTE(.); 214 KEEP (*(.NMIExceptionVector.text)) 215 _NMIExceptionVector_text_end = ABSOLUTE(.); 216 } >vector_int5_text :vector_int5_text_phdr 217 218 .KernelExceptionVector.literal : ALIGN(4) 219 { 220 _KernelExceptionVector_literal_start = ABSOLUTE(.); 221 *(.KernelExceptionVector.literal) 222 _KernelExceptionVector_literal_end = ABSOLUTE(.); 223 } >vector_kernel_lit :vector_kernel_lit_phdr 224 225 .KernelExceptionVector.text : ALIGN(4) 226 { 227 _KernelExceptionVector_text_start = ABSOLUTE(.); 228 KEEP (*(.KernelExceptionVector.text)) 229 _KernelExceptionVector_text_end = ABSOLUTE(.); 230 } >vector_kernel_text :vector_kernel_text_phdr 231 232 .UserExceptionVector.literal : ALIGN(4) 233 { 234 _UserExceptionVector_literal_start = ABSOLUTE(.); 235 *(.UserExceptionVector.literal) 236 _UserExceptionVector_literal_end = ABSOLUTE(.); 237 } >vector_user_lit :vector_user_lit_phdr 238 239 .UserExceptionVector.text : ALIGN(4) 240 { 241 _UserExceptionVector_text_start = ABSOLUTE(.); 242 KEEP (*(.UserExceptionVector.text)) 243 _UserExceptionVector_text_end = ABSOLUTE(.); 244 } >vector_user_text :vector_user_text_phdr 245 246 .DoubleExceptionVector.literal : ALIGN(4) 247 { 248 _DoubleExceptionVector_literal_start = ABSOLUTE(.); 249 *(.DoubleExceptionVector.literal) 250 _DoubleExceptionVector_literal_end = ABSOLUTE(.); 251 } >vector_double_lit :vector_double_lit_phdr 252 253 .DoubleExceptionVector.text : ALIGN(4) 254 { 255 _DoubleExceptionVector_text_start = ABSOLUTE(.); 256 KEEP (*(.DoubleExceptionVector.text)) 257 _DoubleExceptionVector_text_end = ABSOLUTE(.); 258 } >vector_double_text :vector_double_text_phdr 259 260 .iram.text : ALIGN(4) 261 { 262 _stext = .; 263 _iram_text_start = ABSOLUTE(.); 264 *(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text) 265 _iram_text_end = ABSOLUTE(.); 266 } >iram_text_start :iram_text_start_phdr 267 268 .rodata : ALIGN(4) 269 { 270 __rodata_region_start = ABSOLUTE(.); 271 *(.rodata) 272 *(.rodata.*) 273 *(.gnu.linkonce.r.*) 274 *(.rodata1) 275 __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); 276 KEEP (*(.xt_except_table)) 277 KEEP (*(.gcc_except_table .gcc_except_table.*)) 278 *(.gnu.linkonce.e.*) 279 *(.gnu.version_r) 280 KEEP (*(.eh_frame)) 281 KEEP (*crtbegin.o(.ctors)) 282 KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) 283 KEEP (*(SORT(.ctors.*))) 284 KEEP (*(.ctors)) 285 KEEP (*crtbegin.o(.dtors)) 286 KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) 287 KEEP (*(SORT(.dtors.*))) 288 KEEP (*(.dtors)) 289 __XT_EXCEPTION_DESCS__ = ABSOLUTE(.); 290 *(.xt_except_desc) 291 *(.gnu.linkonce.h.*) 292 __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.); 293 *(.xt_except_desc_end) 294 *(.dynamic) 295 *(.gnu.version_d) 296 . = ALIGN(4); 297 _bss_table_start = ABSOLUTE(.); 298 LONG(_bss_start) 299 LONG(_bss_end) 300 _bss_table_end = ABSOLUTE(.); 301 __rodata_region_end = ABSOLUTE(.); 302 } >sdram0 :sdram0_phdr 303 304 .module_init : ALIGN(4) 305 { 306 _module_init_start = ABSOLUTE(.); 307 *(*.initcall) 308 _module_init_end = ABSOLUTE(.); 309 } >sdram0 :sdram0_phdr 310 311 .text : ALIGN(4) 312 { 313 _stext = .; 314 __text_region_start = ABSOLUTE(.); 315 KEEP (*(.ResetVector.text)) 316 *(.ResetVector.literal) 317 *(.entry.text) 318 *(.init.literal) 319 KEEP(*(.init)) 320 *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) 321 *(.fini.literal) 322 KEEP(*(.fini)) 323 *(.gnu.version) 324 __text_region_end = ABSOLUTE(.); 325 _etext = .; 326 } >iram_text_start :iram_text_start_phdr 327 328#include <zephyr/linker/common-rom.ld> 329/* Located in generated directory. This file is populated by calling 330 * zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs. 331 */ 332#include <snippets-rom-sections.ld> 333 334 .fw_ready : ALIGN(4) 335 { 336 KEEP(*(".fw_ready")); 337 KEEP (*(.fw_ready_metadata)) 338 } >sdram0 :sdram0_phdr 339 340 .data : ALIGN(4) 341 { 342 __data_start = ABSOLUTE(.); 343 *(.data) 344 *(.data.*) 345 *(.gnu.linkonce.d.*) 346 KEEP(*(.gnu.linkonce.d.*personality*)) 347 *(.data1) 348 *(.sdata) 349 *(.sdata.*) 350 *(.gnu.linkonce.s.*) 351 *(.sdata2) 352 *(.sdata2.*) 353 *(.gnu.linkonce.s2.*) 354 KEEP(*(.jcr)) 355 _trace_ctx_start = ABSOLUTE(.); 356 *(.trace_ctx) 357 _trace_ctx_end = ABSOLUTE(.); 358 . = ALIGN(4); 359 *(.gna_model) 360 __data_end = ABSOLUTE(.); 361 . = ALIGN(4096); 362 } >sdram0 :sdram0_phdr 363 364 .lit4 : ALIGN(4) 365 { 366 _lit4_start = ABSOLUTE(.); 367 *(*.lit4) 368 *(.lit4.*) 369 *(.gnu.linkonce.lit4.*) 370 _lit4_end = ABSOLUTE(.); 371 } >sdram0 :sdram0_phdr 372 373#include <zephyr/linker/common-ram.ld> 374 375 .bss (NOLOAD) : ALIGN(8) 376 { 377 . = ALIGN (8); 378 _bss_start = ABSOLUTE(.); 379 *(.dynsbss) 380 *(.sbss) 381 *(.sbss.*) 382 *(.gnu.linkonce.sb.*) 383 *(.scommon) 384 *(.sbss2) 385 *(.sbss2.*) 386 *(.gnu.linkonce.sb2.*) 387 *(.dynbss) 388 *(.bss) 389 *(.bss.*) 390 *(.gnu.linkonce.b.*) 391 *(COMMON) 392 . = ALIGN (8); 393 _bss_end = ABSOLUTE(.); 394 } >sdram0 :sdram0_phdr 395 396 .noinit (NOLOAD) : ALIGN(4) 397 { 398 *(.noinit) 399 *(.noinit.*) 400 } >sdram0 :sdram0_phdr 401 402 .heap_mem (NOLOAD) : ALIGN(8) 403 { 404 . = ALIGN (8); 405 _heap_mem_start = ABSOLUTE(.); 406 *(*.heap_mem) 407 _heap_mem_end = ABSOLUTE(.); 408 409 } >sdram0 :sdram0_phdr 410 411 /* stack */ 412 _end = ALIGN (8); 413 414 /DISCARD/ : { *(.note.GNU-stack) } 415 _heap_sentry = SDRAM0_BASE + SDRAM0_SIZE; 416 __stack = SDRAM0_BASE + SDRAM0_SIZE + CONFIG_RT595_ADSP_STACK_SIZE; 417 .comment 0 : { *(.comment) } 418 .debug 0 : { *(.debug) } 419 .line 0 : { *(.line) } 420 .debug_srcinfo 0 : { *(.debug_srcinfo) } 421 .debug_sfnames 0 : { *(.debug_sfnames) } 422 .debug_aranges 0 : { *(.debug_aranges) } 423 .debug_pubnames 0 : { *(.debug_pubnames) } 424 .debug_info 0 : { *(.debug_info) } 425 .debug_abbrev 0 : { *(.debug_abbrev) } 426 .debug_line 0 : { *(.debug_line) } 427 .debug_frame 0 : { *(.debug_frame) } 428 .debug_str 0 : { *(.debug_str) } 429 .debug_loc 0 : { *(.debug_loc) } 430 .debug_macinfo 0 : { *(.debug_macinfo) } 431 .debug_weaknames 0 : { *(.debug_weaknames) } 432 .debug_funcnames 0 : { *(.debug_funcnames) } 433 .debug_typenames 0 : { *(.debug_typenames) } 434 .debug_varnames 0 : { *(.debug_varnames) } 435 .debug_ranges 0 : { *(.debug_ranges) } 436 .debug_addr 0 : { *(.debug_addr) } 437 .debug_line_str 0 : { *(.debug_line_str) } 438 .debug_loclists 0 : { *(.debug_loclists) } 439 .debug_macro 0 : { *(.debug_macro) } 440 .debug_names 0 : { *(.debug_names) } 441 .debug_rnglists 0 : { *(.debug_rnglists) } 442 .debug_str_offsets 0 : { *(.debug_str_offsets) } 443 .debug_sup 0 : { *(.debug_sup) } 444 .xtensa.info 0 : { *(.xtensa.info) } 445 .xt.insn 0 : 446 { 447 KEEP (*(.xt.insn)) 448 KEEP (*(.gnu.linkonce.x.*)) 449 } 450 .xt.prop 0 : 451 { 452 KEEP (*(.xt.prop)) 453 KEEP (*(.xt.prop.*)) 454 KEEP (*(.gnu.linkonce.prop.*)) 455 } 456 .xt.lit 0 : 457 { 458 KEEP (*(.xt.lit)) 459 KEEP (*(.xt.lit.*)) 460 KEEP (*(.gnu.linkonce.p.*)) 461 } 462 .xt.profile_range 0 : 463 { 464 KEEP (*(.xt.profile_range)) 465 KEEP (*(.gnu.linkonce.profile_range.*)) 466 } 467 .xt.profile_ranges 0 : 468 { 469 KEEP (*(.xt.profile_ranges)) 470 KEEP (*(.gnu.linkonce.xt.profile_ranges.*)) 471 } 472 .xt.profile_files 0 : 473 { 474 KEEP (*(.xt.profile_files)) 475 KEEP (*(.gnu.linkonce.xt.profile_files.*)) 476 } 477#ifdef CONFIG_GEN_ISR_TABLES 478#include <zephyr/linker/intlist.ld> 479#endif 480} 481