1/* 2 * Linker Script for i.MX8M 3 * 4 * This script is run through the GNU C preprocessor to align the memory 5 * offsets with headers. 6 * 7 * Use spaces for formatting as cpp ignore tab sizes. 8 */ 9 10 11#include <sof/lib/memory.h> 12#include <xtensa/config/core-isa.h> 13 14OUTPUT_ARCH(xtensa) 15 16MEMORY 17{ 18 vector_reset_text : 19 org = XCHAL_RESET_VECTOR0_PADDR, 20 len = SOF_MEM_RESET_TEXT_SIZE 21 vector_reset_lit : 22 org = XCHAL_RESET_VECTOR0_PADDR + SOF_MEM_RESET_TEXT_SIZE, 23 len = SOF_MEM_RESET_LIT_SIZE 24 vector_base_text : 25 org = XCHAL_VECBASE_RESET_PADDR, 26 len = SOF_MEM_VECBASE_LIT_SIZE 27 vector_int2_lit : 28 org = XCHAL_INTLEVEL2_VECTOR_PADDR - SOF_MEM_VECT_LIT_SIZE, 29 len = SOF_MEM_VECT_LIT_SIZE 30 vector_int2_text : 31 org = XCHAL_INTLEVEL2_VECTOR_PADDR, 32 len = SOF_MEM_VECT_TEXT_SIZE 33 vector_int3_lit : 34 org = XCHAL_INTLEVEL3_VECTOR_PADDR - SOF_MEM_VECT_LIT_SIZE, 35 len = SOF_MEM_VECT_LIT_SIZE 36 vector_int3_text : 37 org = XCHAL_INTLEVEL3_VECTOR_PADDR, 38 len = SOF_MEM_VECT_TEXT_SIZE 39 vector_int4_lit : 40 org = XCHAL_INTLEVEL4_VECTOR_PADDR - SOF_MEM_VECT_LIT_SIZE, 41 len = SOF_MEM_VECT_LIT_SIZE 42 vector_int4_text : 43 org = XCHAL_INTLEVEL4_VECTOR_PADDR, 44 len = SOF_MEM_VECT_TEXT_SIZE 45 vector_int5_lit : 46 org = XCHAL_INTLEVEL5_VECTOR_PADDR - SOF_MEM_VECT_LIT_SIZE, 47 len = SOF_MEM_VECT_LIT_SIZE 48 vector_int5_text : 49 org = XCHAL_INTLEVEL5_VECTOR_PADDR, 50 len = SOF_MEM_VECT_TEXT_SIZE 51 vector_kernel_lit : 52 org = XCHAL_KERNEL_VECTOR_PADDR - SOF_MEM_VECT_LIT_SIZE, 53 len = SOF_MEM_VECT_LIT_SIZE 54 vector_kernel_text : 55 org = XCHAL_KERNEL_VECTOR_PADDR, 56 len = SOF_MEM_VECT_TEXT_SIZE 57 vector_user_lit : 58 org = XCHAL_USER_VECTOR_PADDR - SOF_MEM_VECT_LIT_SIZE, 59 len = SOF_MEM_VECT_LIT_SIZE 60 vector_user_text : 61 org = XCHAL_USER_VECTOR_PADDR, 62 len = SOF_MEM_VECT_TEXT_SIZE 63 vector_double_lit : 64 org = XCHAL_DOUBLEEXC_VECTOR_PADDR - SOF_MEM_VECT_LIT_SIZE, 65 len = SOF_MEM_VECT_LIT_SIZE 66 vector_double_text : 67 org = XCHAL_DOUBLEEXC_VECTOR_PADDR, 68 len = SOF_MEM_VECT_TEXT_SIZE 69 sof_iram_text_start : 70 org = XCHAL_DOUBLEEXC_VECTOR_PADDR + SOF_MEM_VECT_TEXT_SIZE, 71 len = (IRAM_BASE + IRAM_SIZE) - (XCHAL_DOUBLEEXC_VECTOR_PADDR + SOF_MEM_VECT_TEXT_SIZE) 72 sof_sdram0 : 73 org = SDRAM0_BASE, 74 len = SDRAM0_SIZE 75 system_heap : 76 org = HEAP_SYSTEM_BASE, 77 len = HEAP_SYSTEM_SIZE 78 system_runtime_heap : 79 org = HEAP_SYS_RUNTIME_BASE, 80 len = HEAP_SYS_RUNTIME_SIZE 81 runtime_heap : 82 org = HEAP_RUNTIME_BASE, 83 len = HEAP_RUNTIME_SIZE 84 buffer_heap : 85 org = HEAP_BUFFER_BASE, 86 len = HEAP_BUFFER_SIZE 87 sof_stack : 88 org = SOF_STACK_END, 89 len = SOF_STACK_BASE - SOF_STACK_END 90 sof_sdram1 : 91 org = SDRAM1_BASE, 92 len = SDRAM1_SIZE 93 static_uuid_entries_seg (!ari) : 94 org = UUID_ENTRY_ELF_BASE, 95 len = UUID_ENTRY_ELF_SIZE 96 static_log_entries_seg (!ari) : 97 org = LOG_ENTRY_ELF_BASE, 98 len = LOG_ENTRY_ELF_SIZE 99 fw_metadata_seg (!ari) : 100 org = EXT_MANIFEST_ELF_BASE, 101 len = EXT_MANIFEST_ELF_SIZE 102} 103 104PHDRS 105{ 106 vector_reset_text_phdr PT_LOAD; 107 vector_reset_lit_phdr PT_LOAD; 108 vector_base_text_phdr PT_LOAD; 109 vector_base_lit_phdr PT_LOAD; 110 vector_int2_text_phdr PT_LOAD; 111 vector_int2_lit_phdr PT_LOAD; 112 vector_int3_text_phdr PT_LOAD; 113 vector_int3_lit_phdr PT_LOAD; 114 vector_int4_text_phdr PT_LOAD; 115 vector_int4_lit_phdr PT_LOAD; 116 vector_int5_text_phdr PT_LOAD; 117 vector_int5_lit_phdr PT_LOAD; 118 vector_kernel_text_phdr PT_LOAD; 119 vector_kernel_lit_phdr PT_LOAD; 120 vector_user_text_phdr PT_LOAD; 121 vector_user_lit_phdr PT_LOAD; 122 vector_double_text_phdr PT_LOAD; 123 vector_double_lit_phdr PT_LOAD; 124 sof_iram_text_start_phdr PT_LOAD; 125 sof_sdram0_phdr PT_LOAD; 126 system_heap_phdr PT_LOAD; 127 system_runtime_heap_phdr PT_LOAD; 128 runtime_heap_phdr PT_LOAD; 129 buffer_heap_phdr PT_LOAD; 130 sof_stack_phdr PT_LOAD; 131 static_uuid_entries_phdr PT_NOTE; 132 static_log_entries_phdr PT_NOTE; 133 metadata_entries_phdr PT_NOTE; 134} 135 136/* Default entry point: */ 137ENTRY(_ResetVector) 138_rom_store_table = 0; 139 140/* ABI0 does not use Window base */ 141PROVIDE(_memmap_vecbase_reset = XCHAL_VECBASE_RESET_PADDR); 142 143/* Various memory-map dependent cache attribute settings: */ 144_memmap_cacheattr_wb_base = 0x44024000; 145_memmap_cacheattr_wt_base = 0x11021000; 146_memmap_cacheattr_bp_base = 0x22022000; 147_memmap_cacheattr_unused_mask = 0x00F00FFF; 148_memmap_cacheattr_wb_trapnull = 0x4422422F; 149_memmap_cacheattr_wba_trapnull = 0x4422422F; 150_memmap_cacheattr_wbna_trapnull = 0x25222222; 151_memmap_cacheattr_wt_trapnull = 0x1122122F; 152_memmap_cacheattr_bp_trapnull = 0x2222222F; 153_memmap_cacheattr_wb_strict = 0x44F24FFF; 154_memmap_cacheattr_wt_strict = 0x11F21FFF; 155_memmap_cacheattr_bp_strict = 0x22F22FFF; 156_memmap_cacheattr_wb_allvalid = 0x44224222; 157_memmap_cacheattr_wt_allvalid = 0x11221222; 158_memmap_cacheattr_bp_allvalid = 0x22222222; 159/* 160 * Every 512M in 4GB space has dedicate cache attribute. 161 * 1: write through 162 * 2: cache bypass 163 * 4: write back 164 * F: invalid access 165 */ 166_memmap_cacheattr_imx8_wt_allvalid = 0x22212222; 167PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_imx8_wt_allvalid); 168 169_EXT_MAN_ALIGN_ = 16; 170EXTERN(ext_man_fw_ver) 171 172SECTIONS 173{ 174 .ResetVector.text : ALIGN(4) 175 { 176 _ResetVector_text_start = ABSOLUTE(.); 177 KEEP (*(.ResetVector.text)) 178 _ResetVector_text_end = ABSOLUTE(.); 179 } >vector_reset_text :vector_reset_text_phdr 180 181 .ResetVector.literal : ALIGN(4) 182 { 183 _ResetVector_literal_start = ABSOLUTE(.); 184 *(.ResetVector.literal) 185 _ResetVector_literal_end = ABSOLUTE(.); 186 } >vector_reset_lit :vector_reset_lit_phdr 187 188 .WindowVectors.text : ALIGN(4) 189 { 190 _WindowVectors_text_start = ABSOLUTE(.); 191 KEEP (*(.WindowVectors.text)) 192 _WindowVectors_text_end = ABSOLUTE(.); 193 } >vector_base_text :vector_base_text_phdr 194 195 .Level2InterruptVector.literal : ALIGN(4) 196 { 197 _Level2InterruptVector_literal_start = ABSOLUTE(.); 198 *(.Level2InterruptVector.literal) 199 _Level2InterruptVector_literal_end = ABSOLUTE(.); 200 } >vector_int2_lit :vector_int2_lit_phdr 201 202 .Level2InterruptVector.text : ALIGN(4) 203 { 204 _Level2InterruptVector_text_start = ABSOLUTE(.); 205 KEEP (*(.Level2InterruptVector.text)) 206 _Level2InterruptVector_text_end = ABSOLUTE(.); 207 } >vector_int2_text :vector_int2_text_phdr 208 209 .Level3InterruptVector.literal : ALIGN(4) 210 { 211 _Level3InterruptVector_literal_start = ABSOLUTE(.); 212 *(.Level3InterruptVector.literal) 213 _Level3InterruptVector_literal_end = ABSOLUTE(.); 214 } >vector_int3_lit :vector_int3_lit_phdr 215 216 .Level3InterruptVector.text : ALIGN(4) 217 { 218 _Level3InterruptVector_text_start = ABSOLUTE(.); 219 KEEP (*(.Level3InterruptVector.text)) 220 _Level3InterruptVector_text_end = ABSOLUTE(.); 221 } >vector_int3_text :vector_int3_text_phdr 222 223 .DebugExceptionVector.literal : ALIGN(4) 224 { 225 _DebugExceptionVector_literal_start = ABSOLUTE(.); 226 *(.DebugExceptionVector.literal) 227 _DebugExceptionVector_literal_end = ABSOLUTE(.); 228 } >vector_int4_lit :vector_int4_lit_phdr 229 230 .DebugExceptionVector.text : ALIGN(4) 231 { 232 _DebugExceptionVector_text_start = ABSOLUTE(.); 233 KEEP (*(.DebugExceptionVector.text)) 234 _DebugExceptionVector_text_end = ABSOLUTE(.); 235 } >vector_int4_text :vector_int4_text_phdr 236 237 .NMIExceptionVector.literal : ALIGN(4) 238 { 239 _NMIExceptionVector_literal_start = ABSOLUTE(.); 240 *(.NMIExceptionVector.literal) 241 _NMIExceptionVector_literal_end = ABSOLUTE(.); 242 } >vector_int5_lit :vector_int5_lit_phdr 243 244 .NMIExceptionVector.text : ALIGN(4) 245 { 246 _NMIExceptionVector_text_start = ABSOLUTE(.); 247 KEEP (*(.NMIExceptionVector.text)) 248 _NMIExceptionVector_text_end = ABSOLUTE(.); 249 } >vector_int5_text :vector_int5_text_phdr 250 251 .KernelExceptionVector.literal : ALIGN(4) 252 { 253 _KernelExceptionVector_literal_start = ABSOLUTE(.); 254 *(.KernelExceptionVector.literal) 255 _KernelExceptionVector_literal_end = ABSOLUTE(.); 256 } >vector_kernel_lit :vector_kernel_lit_phdr 257 258 .KernelExceptionVector.text : ALIGN(4) 259 { 260 _KernelExceptionVector_text_start = ABSOLUTE(.); 261 KEEP (*(.KernelExceptionVector.text)) 262 _KernelExceptionVector_text_end = ABSOLUTE(.); 263 } >vector_kernel_text :vector_kernel_text_phdr 264 265 .UserExceptionVector.literal : ALIGN(4) 266 { 267 _UserExceptionVector_literal_start = ABSOLUTE(.); 268 *(.UserExceptionVector.literal) 269 _UserExceptionVector_literal_end = ABSOLUTE(.); 270 } >vector_user_lit :vector_user_lit_phdr 271 272 .UserExceptionVector.text : ALIGN(4) 273 { 274 _UserExceptionVector_text_start = ABSOLUTE(.); 275 KEEP (*(.UserExceptionVector.text)) 276 _UserExceptionVector_text_end = ABSOLUTE(.); 277 } >vector_user_text :vector_user_text_phdr 278 279 .DoubleExceptionVector.literal : ALIGN(4) 280 { 281 _DoubleExceptionVector_literal_start = ABSOLUTE(.); 282 *(.DoubleExceptionVector.literal) 283 _DoubleExceptionVector_literal_end = ABSOLUTE(.); 284 } >vector_double_lit :vector_double_lit_phdr 285 286 .DoubleExceptionVector.text : ALIGN(4) 287 { 288 _DoubleExceptionVector_text_start = ABSOLUTE(.); 289 KEEP (*(.DoubleExceptionVector.text)) 290 _DoubleExceptionVector_text_end = ABSOLUTE(.); 291 } >vector_double_text :vector_double_text_phdr 292 293 .iram.text : ALIGN(4) 294 { 295 _stext = .; 296 _iram_text_start = ABSOLUTE(.); 297 *(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text) 298 _iram_text_end = ABSOLUTE(.); 299 } >sof_iram_text_start :sof_iram_text_start_phdr 300 301 .rodata : ALIGN(4) 302 { 303 _rodata_start = ABSOLUTE(.); 304 *(.rodata) 305 *(.rodata.*) 306 *(.gnu.linkonce.r.*) 307 *(.rodata1) 308 __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); 309 KEEP (*(.xt_except_table)) 310 KEEP (*(.gcc_except_table)) 311 *(.gnu.linkonce.e.*) 312 *(.gnu.version_r) 313 KEEP (*(.eh_frame)) 314 /* C++ constructor and destructor tables, properly ordered: */ 315 KEEP (*crtbegin.o(.ctors)) 316 KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) 317 KEEP (*(SORT(.ctors.*))) 318 KEEP (*(.ctors)) 319 KEEP (*crtbegin.o(.dtors)) 320 KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) 321 KEEP (*(SORT(.dtors.*))) 322 KEEP (*(.dtors)) 323 /* C++ exception handlers table: */ 324 __XT_EXCEPTION_DESCS__ = ABSOLUTE(.); 325 *(.xt_except_desc) 326 *(.gnu.linkonce.h.*) 327 __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.); 328 *(.xt_except_desc_end) 329 *(.dynamic) 330 *(.gnu.version_d) 331 . = ALIGN(4); /* this table MUST be 4-byte aligned */ 332 _bss_table_start = ABSOLUTE(.); 333 LONG(_bss_start) 334 LONG(_bss_end) 335 _bss_table_end = ABSOLUTE(.); 336 _rodata_end = ABSOLUTE(.); 337 } >sof_sdram0 :sof_sdram0_phdr 338 339 .module_init : ALIGN(4) 340 { 341 _module_init_start = ABSOLUTE(.); 342 *(*.initcall) 343 _module_init_end = ABSOLUTE(.); 344 } >sof_sdram0 :sof_sdram0_phdr 345 346 .text : ALIGN(4) 347 { 348 _stext = .; 349 _text_start = ABSOLUTE(.); 350 *(.entry.text) 351 *(.init.literal) 352 KEEP(*(.init)) 353 *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) 354 *(.fini.literal) 355 KEEP(*(.fini)) 356 *(.gnu.version) 357 _text_end = ABSOLUTE(.); 358 _etext = .; 359 } >sof_sdram0 :sof_sdram0_phdr 360 361 .reset.rodata : ALIGN(4) 362 { 363 _reset_rodata_start = ABSOLUTE(.); 364 *(.reset.rodata) 365 _reset_rodata_end = ABSOLUTE(.); 366 } >sof_sdram0 :sof_sdram0_phdr 367 368 369 .data : ALIGN(4) 370 { 371 _data_start = ABSOLUTE(.); 372 *(.data) 373 *(.data.*) 374 *(.gnu.linkonce.d.*) 375 KEEP(*(.gnu.linkonce.d.*personality*)) 376 *(.data1) 377 *(.sdata) 378 *(.sdata.*) 379 *(.gnu.linkonce.s.*) 380 *(.sdata2) 381 *(.sdata2.*) 382 *(.gnu.linkonce.s2.*) 383 KEEP(*(.jcr)) 384 _trace_ctx_start = ABSOLUTE(.); 385 *(.trace_ctx) 386 _trace_ctx_end = ABSOLUTE(.); 387 _data_end = ABSOLUTE(.); 388 } >sof_sdram0 :sof_sdram0_phdr 389 390 .lit4 : ALIGN(4) 391 { 392 _lit4_start = ABSOLUTE(.); 393 *(*.lit4) 394 *(.lit4.*) 395 *(.gnu.linkonce.lit4.*) 396 _lit4_end = ABSOLUTE(.); 397 } >sof_sdram0 :sof_sdram0_phdr 398 399 .bss (NOLOAD) : ALIGN(8) 400 { 401 . = ALIGN (8); 402 _bss_start = ABSOLUTE(.); 403 *(.dynsbss) 404 *(.sbss) 405 *(.sbss.*) 406 *(.gnu.linkonce.sb.*) 407 *(.scommon) 408 *(.sbss2) 409 *(.sbss2.*) 410 *(.gnu.linkonce.sb2.*) 411 *(.dynbss) 412 *(.bss) 413 *(.bss.*) 414 *(.gnu.linkonce.b.*) 415 *(COMMON) 416 . = ALIGN (8); 417 _bss_end = ABSOLUTE(.); 418 } >sof_sdram0 :sof_sdram0_phdr 419 420 /* stack */ 421 _end = SOF_STACK_END; 422 PROVIDE(end = SOF_STACK_END); 423 _stack_sentry = SOF_STACK_END; 424 __stack = SOF_STACK_BASE; 425 426 .debug 0 : { *(.debug) } 427 .line 0 : { *(.line) } 428 .debug_srcinfo 0 : { *(.debug_srcinfo) } 429 .debug_sfnames 0 : { *(.debug_sfnames) } 430 .debug_aranges 0 : { *(.debug_aranges) } 431 .debug_pubnames 0 : { *(.debug_pubnames) } 432 .debug_info 0 : { *(.debug_info) } 433 .debug_abbrev 0 : { *(.debug_abbrev) } 434 .debug_line 0 : { *(.debug_line) } 435 .debug_frame 0 : { *(.debug_frame) } 436 .debug_str 0 : { *(.debug_str) } 437 .debug_loc 0 : { *(.debug_loc) } 438 .debug_macinfo 0 : { *(.debug_macinfo) } 439 .debug_weaknames 0 : { *(.debug_weaknames) } 440 .debug_funcnames 0 : { *(.debug_funcnames) } 441 .debug_typenames 0 : { *(.debug_typenames) } 442 .debug_varnames 0 : { *(.debug_varnames) } 443 444 .xt.insn 0 : 445 { 446 KEEP (*(.xt.insn)) 447 KEEP (*(.gnu.linkonce.x.*)) 448 } 449 .xt.prop 0 : 450 { 451 KEEP (*(.xt.prop)) 452 KEEP (*(.xt.prop.*)) 453 KEEP (*(.gnu.linkonce.prop.*)) 454 } 455 .xt.lit 0 : 456 { 457 KEEP (*(.xt.lit)) 458 KEEP (*(.xt.lit.*)) 459 KEEP (*(.gnu.linkonce.p.*)) 460 } 461 .xt.profile_range 0 : 462 { 463 KEEP (*(.xt.profile_range)) 464 KEEP (*(.gnu.linkonce.profile_range.*)) 465 } 466 .xt.profile_ranges 0 : 467 { 468 KEEP (*(.xt.profile_ranges)) 469 KEEP (*(.gnu.linkonce.xt.profile_ranges.*)) 470 } 471 .xt.profile_files 0 : 472 { 473 KEEP (*(.xt.profile_files)) 474 KEEP (*(.gnu.linkonce.xt.profile_files.*)) 475 } 476 477 .system_heap (NOLOAD) : ALIGN(8) 478 { 479 . = ALIGN (32); 480 _system_heap_start = ABSOLUTE(.); 481 . = . + HEAP_SYSTEM_SIZE; 482 _system_heap_end = ABSOLUTE(.); 483 } >system_heap :system_heap_phdr 484 485 .system_runtime_heap (NOLOAD) : ALIGN(8) 486 { 487 . = ALIGN (HEAP_BUF_ALIGNMENT); 488 _system_runtime_heap_start = ABSOLUTE(.); 489 . = . + HEAP_SYS_RUNTIME_SIZE; 490 _system_runtime_heap_end = ABSOLUTE(.); 491 } >system_runtime_heap :system_runtime_heap_phdr 492 493 .runtime_heap (NOLOAD) : ALIGN(8) 494 { 495 . = ALIGN (32); 496 _runtime_heap_start = ABSOLUTE(.); 497 . = . + HEAP_RUNTIME_SIZE; 498 _runtime_heap_end = ABSOLUTE(.); 499 } >runtime_heap :runtime_heap_phdr 500 501 .buffer_heap (NOLOAD) : ALIGN(8) 502 { 503 . = ALIGN (HEAP_BUF_ALIGNMENT); 504 _buffer_heap_start = ABSOLUTE(.); 505 . = . + HEAP_BUFFER_SIZE; 506 _buffer_heap_end = ABSOLUTE(.); 507 } >buffer_heap :buffer_heap_phdr 508 509 .sof_stack (NOLOAD) : ALIGN(8) 510 { 511 . = ALIGN (4096); 512 _sof_stack_start = ABSOLUTE(.); 513 . = . + SOF_STACK_TOTAL_SIZE; 514 _sof_stack_end = ABSOLUTE(.); 515 } >sof_stack :sof_stack_phdr 516 517 .static_uuid_entries (COPY) : ALIGN(1024) 518 { 519 *(*.static_uuids) 520 } > static_uuid_entries_seg :static_uuid_entries_phdr 521 522 .static_log_entries (COPY) : ALIGN(1024) 523 { 524 *(*.static_log*) 525 } > static_log_entries_seg :static_log_entries_phdr 526 527 .fw_ready : ALIGN(4) 528 { 529 KEEP (*(.fw_ready)) 530 KEEP (*(.fw_ready_metadata)) 531 } >sof_sdram0 :sof_sdram0_phdr 532 533 .fw_metadata (COPY) : ALIGN(1024) 534 { 535 KEEP (*(.fw_metadata)) 536 . = ALIGN(_EXT_MAN_ALIGN_); 537 } >fw_metadata_seg :metadata_entries_phdr 538} 539