| /* |
| * Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd. |
| * SPDX-License-Identifier: Apache-2.0 |
| */ |
| |
| /** |
| * @file |
| * @brief Linker command/script file |
| * |
| * Linker script for the Xtensa platform. |
| */ |
| |
| #include <zephyr/devicetree.h> |
| #include <zephyr/linker/sections.h> |
| #include <zephyr/linker/linker-defs.h> |
| #include <zephyr/linker/linker-tool.h> |
| |
| #ifdef CONFIG_XIP |
| #error "Xtensa bootloader cannot use XIP" |
| #endif /* CONFIG_XIP */ |
| |
| /* Disable all romable LMA */ |
| #undef GROUP_DATA_LINK_IN |
| #define GROUP_DATA_LINK_IN(vregion, lregion) > vregion |
| |
| #define RAMABLE_REGION dram_seg |
| #define RAMABLE_REGION_1 dram_seg |
| |
| #define RODATA_REGION dram_seg |
| #define ROMABLE_REGION dram_seg |
| |
| #define IRAM_REGION iram_seg |
| #define FLASH_CODE_REGION iram_seg |
| |
| #define IROM_SEG_ALIGN 16 |
| |
| MEMORY |
| { |
| iram_seg(RWX) : org = 0x403B6000, len = 0x8000 |
| iram_loader_seg(RWX) : org = 0x403BE000, len = 0x2000 |
| dram_seg(RW) : org = 0x3FCD0000, len = 0x6000 |
| |
| #ifdef CONFIG_GEN_ISR_TABLES |
| IDT_LIST(RW): org = 0x3ebfe010, len = 0x2000 |
| #endif |
| } |
| |
| /* Default entry point: */ |
| ENTRY(CONFIG_KERNEL_ENTRY) |
| |
| SECTIONS |
| { |
| |
| SECTION_PROLOGUE(_RODATA_SECTION_NAME,,ALIGN(0x10)) |
| { |
| __rodata_region_start = ABSOLUTE(.); |
| |
| . = ALIGN(4); |
| #include <snippets-rodata.ld> |
| |
| . = ALIGN(4); |
| *(.rodata) |
| *(.rodata.*) |
| |
| *(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */ |
| *(.gnu.linkonce.r.*) |
| *(.rodata1) |
| __XT_EXCEPTION_TABLE_ = ABSOLUTE(.); |
| *(.xt_except_table) |
| *(.gcc_except_table .gcc_except_table.*) |
| *(.gnu.linkonce.e.*) |
| *(.gnu.version_r) |
| . = (. + 3) & ~ 3; |
| __eh_frame = ABSOLUTE(.); |
| KEEP(*(.eh_frame)) |
| . = (. + 7) & ~ 3; |
| |
| /* C++ exception handlers table: */ |
| __XT_EXCEPTION_DESCS_ = ABSOLUTE(.); |
| *(.xt_except_desc) |
| *(.gnu.linkonce.h.*) |
| __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.); |
| *(.xt_except_desc_end) |
| *(.dynamic) |
| *(.gnu.version_d) |
| . = ALIGN(4); |
| __rodata_region_end = ABSOLUTE(.); |
| /* Literals are also RO data. */ |
| _lit4_start = ABSOLUTE(.); |
| *(*.lit4) |
| *(.lit4.*) |
| *(.gnu.linkonce.lit4.*) |
| _lit4_end = ABSOLUTE(.); |
| . = ALIGN(4); |
| _thread_local_start = ABSOLUTE(.); |
| *(.tdata) |
| *(.tdata.*) |
| *(.tbss) |
| *(.tbss.*) |
| *(.rodata_wlog) |
| *(.rodata_wlog*) |
| _thread_local_end = ABSOLUTE(.); |
| /* _rodata_reserved_end = ABSOLUTE(.); */ |
| . = ALIGN(4); |
| } GROUP_DATA_LINK_IN(RODATA_REGION, ROMABLE_REGION) |
| |
| #include <zephyr/linker/common-rom/common-rom-cpp.ld> |
| #include <zephyr/linker/common-rom/common-rom-kernel-devices.ld> |
| #include <zephyr/linker/common-rom/common-rom-debug.ld> |
| #include <zephyr/linker/common-rom/common-rom-misc.ld> |
| #include <snippets-sections.ld> |
| |
| .dram0.data : |
| { |
| __data_start = ABSOLUTE(.); |
| |
| _btdm_data_start = ABSOLUTE(.); |
| *libbtdm_app.a:(.data .data.*) |
| . = ALIGN (4); |
| _btdm_data_end = ABSOLUTE(.); |
| |
| *(.data) |
| *(.data.*) |
| *(.gnu.linkonce.d.*) |
| *(.data1) |
| *(.sdata) |
| *(.sdata.*) |
| *(.gnu.linkonce.s.*) |
| *(.sdata2) |
| *(.sdata2.*) |
| *(.gnu.linkonce.s2.*) |
| KEEP(*(.jcr)) |
| *(.dram1 .dram1.*) |
| . = ALIGN(4); |
| } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) |
| |
| #include <zephyr/linker/cplusplus-rom.ld> |
| #include <snippets-data-sections.ld> |
| #include <zephyr/linker/common-ram.ld> |
| #include <snippets-ram-sections.ld> |
| #include <zephyr/linker/cplusplus-ram.ld> |
| #include <zephyr/linker/common-rom/common-rom-logging.ld> |
| |
| .dram0.end : |
| { |
| . = ALIGN(4); |
| #include <snippets-rwdata.ld> |
| . = ALIGN(4); |
| _end = ABSOLUTE(.); |
| _heap_sentry = .; |
| __data_end = ABSOLUTE(.); |
| } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) |
| |
| /* Send .iram0 code to iram */ |
| .iram0.vectors : ALIGN(4) |
| { |
| /* Vectors go to IRAM */ |
| _init_start = ABSOLUTE(.); |
| /* Vectors according to builds/RF-2015.2-win32/esp108_v1_2_s5_512int_2/config.html */ |
| . = 0x0; |
| KEEP(*(.WindowVectors.text)); |
| . = 0x180; |
| KEEP(*(.Level2InterruptVector.text)); |
| . = 0x1c0; |
| KEEP(*(.Level3InterruptVector.text)); |
| . = 0x200; |
| KEEP(*(.Level4InterruptVector.text)); |
| . = 0x240; |
| KEEP(*(.Level5InterruptVector.text)); |
| . = 0x280; |
| KEEP(*(.DebugExceptionVector.text)); |
| . = 0x2c0; |
| KEEP(*(.NMIExceptionVector.text)); |
| . = 0x300; |
| KEEP(*(.KernelExceptionVector.text)); |
| . = 0x340; |
| KEEP(*(.UserExceptionVector.text)); |
| . = 0x3C0; |
| KEEP(*(.DoubleExceptionVector.text)); |
| . = 0x400; |
| _invalid_pc_placeholder = ABSOLUTE(.); |
| *(.*Vector.literal) |
| |
| *(.UserEnter.literal); |
| *(.UserEnter.text); |
| . = ALIGN (16); |
| *(.entry.text) |
| *(.init.literal) |
| *(.init) |
| _init_end = ABSOLUTE(.); |
| |
| /* This goes here, not at top of linker script, so addr2line finds it last, |
| * and uses it in preference to the first symbol in IRAM |
| */ |
| _iram_start = ABSOLUTE(0); |
| } GROUP_DATA_LINK_IN(IRAM_REGION, ROMABLE_REGION) |
| |
| .iram_loader.text : |
| { |
| . = ALIGN (16); |
| _loader_text_start = ABSOLUTE(.); |
| *(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) |
| *(.iram1 .iram1.*) /* catch stray IRAM_ATTR */ |
| *libzephyr.a:bootloader_flash.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:bootloader_flash_config_esp32s3.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:bootloader_common_loader.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:bootloader_init_common.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:bootloader_flash.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:bootloader_random.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:bootloader_random*.*(.literal.bootloader_random_disable .text.bootloader_random_disable) |
| *libzephyr.a:bootloader_random*.*(.literal.bootloader_random_enable .text.bootloader_random_enable) |
| *libzephyr.a:bootloader_efuse_esp32s3.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:bootloader_utility.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:bootloader_sha.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:bootloader_console.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:bootloader_console_loader.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:bootloader_panic.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:bootloader_soc.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:esp_image_format.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:flash_encrypt.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:flash_encryption_secure_features.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:flash_partitions.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:secure_boot.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:secure_boot_secure_features.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:secure_boot_signatures_bootloader.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:wdt_hal_iram.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:esp_efuse_table.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:esp_efuse_fields.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:esp_efuse_api.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:esp_efuse_utility.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:esp_efuse_api_key_esp32xx.*(.literal .text .literal.* .text.*) |
| *libzephyr.a:app_cpu_start.*(.literal .text .literal.* .text.*) |
| *esp_mcuboot.*(.literal .text .literal.* .text.*) |
| *esp_loader.*(.literal .text .literal.* .text.*) |
| *(.fini.literal) |
| *(.fini) |
| *(.gnu.version) |
| _loader_text_end = ABSOLUTE(.); |
| } > iram_loader_seg |
| |
| SECTION_PROLOGUE(_TEXT_SECTION_NAME, , ALIGN(4)) |
| { |
| /* Code marked as running out of IRAM */ |
| _iram_text_start = ABSOLUTE(.); |
| |
| *(.iram1 .iram1.*) |
| *(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text) |
| |
| . = ALIGN(16); |
| _iram_text_end = ABSOLUTE(.); */ |
| _iram_end = ABSOLUTE(.); |
| } GROUP_DATA_LINK_IN(IRAM_REGION, ROMABLE_REGION) |
| |
| /* Shared RAM */ |
| SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),) |
| { |
| . = ALIGN (8); |
| _bss_start = ABSOLUTE(.); /* required by bluetooth library */ |
| __bss_start = ABSOLUTE(.); |
| |
| _btdm_bss_start = ABSOLUTE(.); |
| *libbtdm_app.a:(.bss .bss.* COMMON) |
| . = ALIGN (4); |
| _btdm_bss_end = ABSOLUTE(.); |
| |
| /* Buffer for system heap should be placed in dram_seg */ |
| *libkernel.a:mempool.*(.noinit.kheap_buf__system_heap .noinit.*.kheap_buf__system_heap) |
| |
| *(.dynsbss) |
| *(.sbss) |
| *(.sbss.*) |
| *(.gnu.linkonce.sb.*) |
| *(.scommon) |
| *(.sbss2) |
| *(.sbss2.*) |
| *(.gnu.linkonce.sb2.*) |
| *(.dynbss) |
| *(.bss) |
| *(.bss.*) |
| *(.share.mem) |
| *(.gnu.linkonce.b.*) |
| *(COMMON) |
| . = ALIGN (8); |
| __bss_end = ABSOLUTE(.); |
| _bss_end = ABSOLUTE(.); |
| _end = ABSOLUTE(.); |
| } GROUP_LINK_IN(RAMABLE_REGION) |
| |
| ASSERT(((__bss_end - ORIGIN(dram_seg)) <= LENGTH(dram_seg)), "DRAM segment data does not fit.") |
| |
| SECTION_DATA_PROLOGUE(_NOINIT_SECTION_NAME, (NOLOAD),) |
| { |
| . = ALIGN(8); |
| *(.noinit) |
| *(.noinit.*) |
| . = ALIGN(8) ; |
| } GROUP_LINK_IN(RAMABLE_REGION) |
| |
| .flash.text : |
| { |
| _stext = .; |
| _text_start = ABSOLUTE(.); |
| |
| *(.literal .text .literal.* .text.*) |
| . = ALIGN(4); |
| |
| *(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) |
| *(.irom0.text) /* catch stray ICACHE_RODATA_ATTR */ |
| *(.fini.literal) |
| *(.fini) |
| *(.gnu.version) |
| |
| /* CPU will try to prefetch up to 16 bytes of |
| * of instructions. This means that any configuration (e.g. MMU, PMS) must allow |
| * safe access to up to 16 bytes after the last real instruction, add |
| * dummy bytes to ensure this |
| */ |
| . += 16; |
| |
| _text_end = ABSOLUTE(.); |
| _etext = .; |
| |
| /* Similar to _iram_start, this symbol goes here so it is |
| * resolved by addr2line in preference to the first symbol in |
| * the flash.text segment. |
| */ |
| _flash_cache_start = ABSOLUTE(0); |
| } GROUP_DATA_LINK_IN(FLASH_CODE_REGION, ROMABLE_REGION) |
| |
| #include <zephyr/linker/debug-sections.ld> |
| |
| .xtensa.info 0 : { *(.xtensa.info) } |
| .xt.insn 0 : |
| { |
| KEEP (*(.xt.insn)) |
| KEEP (*(.gnu.linkonce.x.*)) |
| } |
| .xt.prop 0 : |
| { |
| KEEP (*(.xt.prop)) |
| KEEP (*(.xt.prop.*)) |
| KEEP (*(.gnu.linkonce.prop.*)) |
| } |
| .xt.lit 0 : |
| { |
| KEEP (*(.xt.lit)) |
| KEEP (*(.xt.lit.*)) |
| KEEP (*(.gnu.linkonce.p.*)) |
| } |
| .xt.profile_range 0 : |
| { |
| KEEP (*(.xt.profile_range)) |
| KEEP (*(.gnu.linkonce.profile_range.*)) |
| } |
| .xt.profile_ranges 0 : |
| { |
| KEEP (*(.xt.profile_ranges)) |
| KEEP (*(.gnu.linkonce.xt.profile_ranges.*)) |
| } |
| .xt.profile_files 0 : |
| { |
| KEEP (*(.xt.profile_files)) |
| KEEP (*(.gnu.linkonce.xt.profile_files.*)) |
| } |
| |
| #ifdef CONFIG_GEN_ISR_TABLES |
| #include <zephyr/linker/intlist.ld> |
| #endif |
| |
| } |
| |
| ASSERT(((_iram_end - ORIGIN(IRAM_REGION)) <= LENGTH(IRAM_REGION)), |
| "IRAM0 segment data does not fit.") |