1/*
2 * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/* Simplified memory map for the bootloader.
8 *
9 * The main purpose is to make sure the bootloader can load into main memory
10 * without overwriting itself.
11 */
12
13MEMORY
14{
15  iram_seg (RWX) :                  org = 0x403C7000, len = 0x9000
16  iram_loader_seg (RWX) :           org = 0x403D0000, len = 0x5400
17  dram_seg (RW) :                   org = 0x3FCD5400, len = 0xA000
18}
19
20/*  Default entry point:  */
21ENTRY(main);
22
23SECTIONS
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    *libhal.a:*.*(.literal .text .literal.* .text.*)
32    *esp_mcuboot.*(.literal .text .literal.* .text.*)
33    *esp_loader.*(.literal .text .literal.* .text.*)
34    *main.*(.literal .text .literal.* .text.*)
35    *(.fini.literal)
36    *(.fini)
37    *(.gnu.version)
38    _loader_text_end = ABSOLUTE(.);
39  } > iram_loader_seg
40
41  .iram.text :
42  {
43    . = ALIGN (16);
44    *(.entry.text)
45    *(.init.literal)
46    *(.init)
47  } > iram_seg
48
49
50  /* Shared RAM */
51  .dram0.bss (NOLOAD) :
52  {
53    . = ALIGN (8);
54    _dram_start = ABSOLUTE(.);
55    _bss_start = ABSOLUTE(.);
56    *(.dynsbss)
57    *(.sbss)
58    *(.sbss.*)
59    *(.gnu.linkonce.sb.*)
60    *(.scommon)
61    *(.sbss2)
62    *(.sbss2.*)
63    *(.gnu.linkonce.sb2.*)
64    *(.dynbss)
65    *(.bss)
66    *(.bss.*)
67    *(.gnu.linkonce.b.*)
68    *(COMMON)
69    . = ALIGN (8);
70    _bss_end = ABSOLUTE(.);
71  } >dram_seg
72
73  .dram0.data :
74  {
75    _data_start = ABSOLUTE(.);
76    *(.data)
77    *(.data.*)
78    *(.gnu.linkonce.d.*)
79    *(.data1)
80    *(.sdata)
81    *(.sdata.*)
82    *(.gnu.linkonce.s.*)
83    *(.sdata2)
84    *(.sdata2.*)
85    *(.gnu.linkonce.s2.*)
86    *(.jcr)
87    _data_end = ABSOLUTE(.);
88  } >dram_seg
89
90  .dram0.rodata :
91  {
92    _rodata_start = ABSOLUTE(.);
93    *(.rodata)
94    *(.rodata.*)
95    *(.gnu.linkonce.r.*)
96    *(.rodata1)
97    __XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
98    *(.xt_except_table)
99    *(.gcc_except_table)
100    *(.gnu.linkonce.e.*)
101    *(.gnu.version_r)
102    *(.eh_frame)
103    . = (. + 3) & ~ 3;
104    /*  C++ constructor and destructor tables, properly ordered:  */
105    __init_array_start = ABSOLUTE(.);
106    KEEP (*crtbegin.*(.ctors))
107    KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors))
108    KEEP (*(SORT(.ctors.*)))
109    KEEP (*(.ctors))
110    __init_array_end = ABSOLUTE(.);
111    KEEP (*crtbegin.*(.dtors))
112    KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
113    KEEP (*(SORT(.dtors.*)))
114    KEEP (*(.dtors))
115    /*  C++ exception handlers table:  */
116    __XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
117    *(.xt_except_desc)
118    *(.gnu.linkonce.h.*)
119    __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
120    *(.xt_except_desc_end)
121    *(.dynamic)
122    *(.gnu.version_d)
123    _rodata_end = ABSOLUTE(.);
124    /* Literals are also RO data. */
125    _lit4_start = ABSOLUTE(.);
126    *(*.lit4)
127    *(.lit4.*)
128    *(.gnu.linkonce.lit4.*)
129    _lit4_end = ABSOLUTE(.);
130    . = ALIGN(4);
131    _dram_end = ABSOLUTE(.);
132  } >dram_seg
133
134  .iram.text :
135  {
136    _stext = .;
137    _text_start = ABSOLUTE(.);
138    *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
139    *(.iram .iram.*) /* catch stray IRAM_ATTR */
140    *(.fini.literal)
141    *(.fini)
142    *(.gnu.version)
143    _text_end = ABSOLUTE(.);
144    _etext = .;
145  } > iram_seg
146
147}
148