1/*
2 * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6/* Simplified memory map for the bootloader.
7 * Make sure the bootloader can load into main memory without overwriting itself.
8 */
9
10
11MEMORY
12{
13  iram_seg (RWX) :                  org = 0x4004B000, len = 0x4000  /* SRAM part of block 12 and 13 */
14  iram_loader_seg (RWX) :           org = 0x4004F000, len = 0x7000  /* SRAM part of block 13, Block 14 & part of 15 */
15  dram_seg (RW) :                   org = 0x3FFE6000, len = 0x4B00  /* Part SRAM Blocks 15 & 16, ROM static buffer starts at end of this region (reclaimed after app runs) */
16}
17
18/*  Default entry point:  */
19ENTRY(call_start_cpu0);
20
21
22SECTIONS
23{
24
25  .iram_loader.text :
26  {
27    . = ALIGN (16);
28    _loader_text_start = ABSOLUTE(.);
29    *(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
30     *(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
31    *liblog.a:(.literal .text .literal.* .text.*)
32    *libgcc.a:(.literal .text .literal.* .text.*)
33    *libbootloader_support.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*)
34    *libbootloader_support.a:bootloader_common_loader.*(.literal .text .literal.* .text.*)
35    *libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
36    *libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
37    *libbootloader_support.a:bootloader_random*.*(.literal.bootloader_random_disable .text.bootloader_random_disable)
38    *libesp_common.a:fpga_overrides.*(.literal.bootloader_fill_random .text.bootloader_fill_random)
39    *libbootloader_support.a:bootloader_efuse.*(.literal .text .literal.* .text.*)
40    *libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
41    *libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
42    *libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
43    *libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
44    *libbootloader_support.a:bootloader_soc.*(.literal .text .literal.* .text.*)
45    *libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
46    *libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
47    *libbootloader_support.a:flash_encryption_secure_features.*(.literal .text .literal.* .text.*)
48    *libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
49    *libbootloader_support.a:secure_boot.*(.literal .text .literal.* .text.*)
50    *libbootloader_support.a:secure_boot_secure_features.*(.literal .text .literal.* .text.*)
51    *libbootloader_support.a:secure_boot_signatures_bootloader.*(.literal .text .literal.* .text.*)
52    *libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
53    *libspi_flash.a:*.*(.literal .text .literal.* .text.*)
54    *libhal.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
55    *libhal.a:mmu_hal.*(.literal .text .literal.* .text.*)
56    *libhal.a:cache_hal.*(.literal .text .literal.* .text.*)
57    *libhal.a:efuse_hal.*(.literal .text .literal.* .text.*)
58    *libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
59    *libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
60    *libesp_hw_support.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)
61    *libefuse.a:*.*(.literal .text .literal.* .text.*)
62    *libesp_rom.a:esp_rom_regi2c.*(.literal .text .literal.* .text.*)
63    *(.fini.literal)
64    *(.fini)
65    *(.gnu.version)
66    _loader_text_end = ABSOLUTE(.);
67  } > iram_loader_seg
68
69  .iram.text :
70  {
71    . = ALIGN (16);
72    *(.entry.text)
73    *(.init.literal)
74    *(.init)
75  } > iram_seg
76
77
78  /* Shared RAM */
79  .dram0.bss (NOLOAD) :
80  {
81    . = ALIGN (8);
82    _dram_start = ABSOLUTE(.);
83    _bss_start = ABSOLUTE(.);
84    *(.dynsbss)
85    *(.sbss)
86    *(.sbss.*)
87    *(.gnu.linkonce.sb.*)
88    *(.scommon)
89    *(.sbss2)
90    *(.sbss2.*)
91    *(.gnu.linkonce.sb2.*)
92    *(.dynbss)
93    *(.bss)
94    *(.bss.*)
95    *(.gnu.linkonce.b.*)
96    *(COMMON)
97    . = ALIGN (8);
98    _bss_end = ABSOLUTE(.);
99  } >dram_seg
100
101  .dram0.data :
102  {
103    _data_start = ABSOLUTE(.);
104    *(.data)
105    *(.data.*)
106    *(.gnu.linkonce.d.*)
107    *(.data1)
108    *(.sdata)
109    *(.sdata.*)
110    *(.gnu.linkonce.s.*)
111    *(.gnu.linkonce.s2.*)
112    *(.jcr)
113    _data_end = ABSOLUTE(.);
114  } >dram_seg
115
116  .dram0.rodata :
117  {
118    _rodata_start = ABSOLUTE(.);
119    *(.rodata)
120    *(.rodata.*)
121    *(.gnu.linkonce.r.*)
122    *(.rodata1)
123    *(.sdata2 .sdata2.*)
124    __XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
125    *(.xt_except_table)
126    *(.gcc_except_table)
127    *(.gnu.linkonce.e.*)
128    *(.gnu.version_r)
129    *(.eh_frame)
130    . = (. + 3) & ~ 3;
131    /*  C++ constructor and destructor tables, properly ordered:  */
132    __init_array_start = ABSOLUTE(.);
133    KEEP (*crtbegin.*(.ctors))
134    KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors))
135    KEEP (*(SORT(.ctors.*)))
136    KEEP (*(.ctors))
137    __init_array_end = ABSOLUTE(.);
138    KEEP (*crtbegin.*(.dtors))
139    KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
140    KEEP (*(SORT(.dtors.*)))
141    KEEP (*(.dtors))
142    /*  C++ exception handlers table:  */
143    __XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
144    *(.xt_except_desc)
145    *(.gnu.linkonce.h.*)
146    __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
147    *(.xt_except_desc_end)
148    *(.dynamic)
149    *(.gnu.version_d)
150    _rodata_end = ABSOLUTE(.);
151	/* Literals are also RO data. */
152    _lit4_start = ABSOLUTE(.);
153    *(*.lit4)
154    *(.lit4.*)
155    *(.gnu.linkonce.lit4.*)
156    _lit4_end = ABSOLUTE(.);
157    . = ALIGN(4);
158    _dram_end = ABSOLUTE(.);
159  } >dram_seg
160
161  .iram.text :
162  {
163    _stext = .;
164    _text_start = ABSOLUTE(.);
165    *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
166    *(.iram .iram.*) /* catch stray IRAM_ATTR */
167    *(.fini.literal)
168    *(.fini)
169    *(.gnu.version)
170
171    /** CPU will try to prefetch up to 16 bytes of
172      * of instructions. This means that any configuration (e.g. MMU, PMS) must allow
173      * safe access to up to 16 bytes after the last real instruction, add
174      * dummy bytes to ensure this
175      */
176    . += 16;
177
178    _text_end = ABSOLUTE(.);
179    _etext = .;
180  } > iram_seg
181
182  /** This section will be used by the debugger and disassembler to get more information
183   * about raw data present in the code.
184   * Indeed, it may be required to add some padding at some points in the code
185   * in order to align a branch/jump destination on a particular bound.
186   * Padding these instructions will generate null bytes that shall be
187   * interpreted as data, and not code by the debugger or disassembler.
188   * This section will only be present in the ELF file, not in the final binary
189   * For more details, check GCC-212
190   */
191  .xt.prop 0 :
192  {
193    KEEP (*(.xt.prop .gnu.linkonce.prop.*))
194  }
195
196  .xt.lit 0 :
197  {
198    KEEP (*(.xt.lit .gnu.linkonce.p.*))
199  }
200
201}
202