blob: e2f1b807e2b5bd2b2d0e85d4ca24e55217215ab0 [file] [log] [blame]
Damien George075d5972014-11-27 20:30:33 +00001/* GNU linker script for ESP8266 */
2
3MEMORY
4{
5 dport0_0_seg : org = 0x3ff00000, len = 0x10
6 dram0_0_seg : org = 0x3ffe8000, len = 0x14000
7 iram1_0_seg : org = 0x40100000, len = 0x8000
Josef Gajdusekb4793192015-05-11 15:05:59 +02008 irom0_0_seg : org = 0x40210000, len = 0x5A000
Damien George075d5972014-11-27 20:30:33 +00009}
10
11/* define the top of RAM */
12_heap_end = ORIGIN(dram0_0_seg) + LENGTH(dram0_0_seg);
13
14PHDRS
15{
16 dport0_0_phdr PT_LOAD;
17 dram0_0_phdr PT_LOAD;
18 dram0_0_bss_phdr PT_LOAD;
19 iram1_0_phdr PT_LOAD;
20 irom0_0_phdr PT_LOAD;
21}
22
23ENTRY(call_user_start)
Josef Gajdusek7d8edef2015-05-26 18:54:55 +020024EXTERN(_DebugExceptionVector)
25EXTERN(_DoubleExceptionVector)
26EXTERN(_KernelExceptionVector)
27EXTERN(_NMIExceptionVector)
28EXTERN(_UserExceptionVector)
Damien George075d5972014-11-27 20:30:33 +000029
30PROVIDE(_memmap_vecbase_reset = 0x40000000);
31
32/* Various memory-map dependent cache attribute settings: */
33_memmap_cacheattr_wb_base = 0x00000110;
34_memmap_cacheattr_wt_base = 0x00000110;
35_memmap_cacheattr_bp_base = 0x00000220;
36_memmap_cacheattr_unused_mask = 0xFFFFF00F;
37_memmap_cacheattr_wb_trapnull = 0x2222211F;
38_memmap_cacheattr_wba_trapnull = 0x2222211F;
39_memmap_cacheattr_wbna_trapnull = 0x2222211F;
40_memmap_cacheattr_wt_trapnull = 0x2222211F;
41_memmap_cacheattr_bp_trapnull = 0x2222222F;
42_memmap_cacheattr_wb_strict = 0xFFFFF11F;
43_memmap_cacheattr_wt_strict = 0xFFFFF11F;
44_memmap_cacheattr_bp_strict = 0xFFFFF22F;
45_memmap_cacheattr_wb_allvalid = 0x22222112;
46_memmap_cacheattr_wt_allvalid = 0x22222112;
47_memmap_cacheattr_bp_allvalid = 0x22222222;
48PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull);
49
50SECTIONS
51{
52
53 .dport0.rodata : ALIGN(4)
54 {
55 _dport0_rodata_start = ABSOLUTE(.);
56 *(.dport0.rodata)
57 *(.dport.rodata)
58 _dport0_rodata_end = ABSOLUTE(.);
59 } >dport0_0_seg :dport0_0_phdr
Damien Georgefbea8102014-11-28 14:58:25 +000060
Damien George075d5972014-11-27 20:30:33 +000061 .dport0.literal : ALIGN(4)
62 {
63 _dport0_literal_start = ABSOLUTE(.);
64 *(.dport0.literal)
65 *(.dport.literal)
66 _dport0_literal_end = ABSOLUTE(.);
67 } >dport0_0_seg :dport0_0_phdr
Damien Georgefbea8102014-11-28 14:58:25 +000068
Damien George075d5972014-11-27 20:30:33 +000069 .dport0.data : ALIGN(4)
70 {
71 _dport0_data_start = ABSOLUTE(.);
72 *(.dport0.data)
73 *(.dport.data)
74 _dport0_data_end = ABSOLUTE(.);
75 } >dport0_0_seg :dport0_0_phdr
Damien Georgefbea8102014-11-28 14:58:25 +000076
77 .irom0.text : ALIGN(4)
78 {
79 _irom0_text_start = ABSOLUTE(.);
80 *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
Damien Georgee6362792014-11-29 14:36:18 +000081
82 /* we put some specific text in this section */
83 *py/*.o*(.literal* .text*)
84 *pyexec.o(.literal*, .text*)
85 *readline.o(.literal*, .text*)
86 *pybstdio.o(.literal*, .text*)
Damien Georgee6362792014-11-29 14:36:18 +000087 *gccollect.o(.literal* .text*)
88 *gchelper.o(.literal* .text*)
Damien George304a96d2015-05-13 14:49:14 +010089 *modpyb.o(.literal*, .text*)
90 *modpybpin.o(.literal*, .text*)
91 *modpybrtc.o(.literal*, .text*)
Josef Gajdusekb4793192015-05-11 15:05:59 +020092 *modesp.o(.literal* .text*)
Damien Georgef09f8092015-10-20 22:59:31 +010093 *modnetwork.o(.literal* .text*)
94 *moduos.o(.literal* .text*)
Damien George304a96d2015-05-13 14:49:14 +010095 *modutime.o(.literal* .text*)
Damien Georgee6362792014-11-29 14:36:18 +000096
97 /* we put as much rodata as possible in this section */
98 /* note that only rodata accessed as a machine word is allowed here */
99 *py/qstr.o(.rodata.const_pool)
100 *py/*.o(.rodata.mp_type_*) /* catches type: mp_obj_type_t */
101 *py/*.o(.rodata.*_locals_dict*) /* catches types: mp_obj_dict_t, mp_map_elem_t */
102 *py/*.o(.rodata.mp_module_*) /* catches types: mp_obj_module_t, mp_obj_dict_t, mp_map_elem_t */
103
Damien Georgefbea8102014-11-28 14:58:25 +0000104 _irom0_text_end = ABSOLUTE(.);
105 } >irom0_0_seg :irom0_0_phdr
106
107 .text : ALIGN(4)
108 {
109 _stext = .;
110 _text_start = ABSOLUTE(.);
Josef Gajdusek7d8edef2015-05-26 18:54:55 +0200111 *(.UserEnter.text)
112 . = ALIGN(16);
113 *(.DebugExceptionVector.text)
114 . = ALIGN(16);
115 *(.NMIExceptionVector.text)
116 . = ALIGN(16);
117 *(.KernelExceptionVector.text)
118 LONG(0)
119 LONG(0)
120 LONG(0)
121 LONG(0)
122 . = ALIGN(16);
123 *(.UserExceptionVector.text)
124 LONG(0)
125 LONG(0)
126 LONG(0)
127 LONG(0)
128 . = ALIGN(16);
129 *(.DoubleExceptionVector.text)
130 LONG(0)
131 LONG(0)
132 LONG(0)
133 LONG(0)
134 . = ALIGN (16);
Damien Georgefbea8102014-11-28 14:58:25 +0000135 *(.entry.text)
136 *(.init.literal)
137 *(.init)
138 *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
139 *(.fini.literal)
140 *(.fini)
141 *(.gnu.version)
Damien Georgefbea8102014-11-28 14:58:25 +0000142 _text_end = ABSOLUTE(.);
143 _etext = .;
144 } >iram1_0_seg :iram1_0_phdr
145
146 .lit4 : ALIGN(4)
147 {
148 _lit4_start = ABSOLUTE(.);
149 *(*.lit4)
150 *(.lit4.*)
151 *(.gnu.linkonce.lit4.*)
152 _lit4_end = ABSOLUTE(.);
153 } >iram1_0_seg :iram1_0_phdr
154
Damien George075d5972014-11-27 20:30:33 +0000155 .data : ALIGN(4)
156 {
157 _data_start = ABSOLUTE(.);
158 *(.data)
159 *(.data.*)
160 *(.gnu.linkonce.d.*)
161 *(.data1)
162 *(.sdata)
163 *(.sdata.*)
164 *(.gnu.linkonce.s.*)
165 *(.sdata2)
166 *(.sdata2.*)
167 *(.gnu.linkonce.s2.*)
168 *(.jcr)
169 _data_end = ABSOLUTE(.);
170 } >dram0_0_seg :dram0_0_phdr
Damien Georgefbea8102014-11-28 14:58:25 +0000171
Damien George075d5972014-11-27 20:30:33 +0000172 .rodata : ALIGN(4)
173 {
174 _rodata_start = ABSOLUTE(.);
175 *(.rodata)
176 *(.rodata.*)
177 *(.gnu.linkonce.r.*)
178 *(.rodata1)
179 __XT_EXCEPTION_TABLE__ = ABSOLUTE(.);
180 *(.xt_except_table)
181 *(.gcc_except_table)
182 *(.gnu.linkonce.e.*)
183 *(.gnu.version_r)
184 *(.eh_frame)
185 /* C++ constructor and destructor tables, properly ordered: */
186 KEEP (*crtbegin.o(.ctors))
187 KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
188 KEEP (*(SORT(.ctors.*)))
189 KEEP (*(.ctors))
190 KEEP (*crtbegin.o(.dtors))
191 KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
192 KEEP (*(SORT(.dtors.*)))
193 KEEP (*(.dtors))
194 /* C++ exception handlers table: */
195 __XT_EXCEPTION_DESCS__ = ABSOLUTE(.);
196 *(.xt_except_desc)
197 *(.gnu.linkonce.h.*)
198 __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
199 *(.xt_except_desc_end)
200 *(.dynamic)
201 *(.gnu.version_d)
202 . = ALIGN(4); /* this table MUST be 4-byte aligned */
203 _bss_table_start = ABSOLUTE(.);
204 LONG(_bss_start)
205 LONG(_bss_end)
206 _bss_table_end = ABSOLUTE(.);
207 _rodata_end = ABSOLUTE(.);
208 } >dram0_0_seg :dram0_0_phdr
Damien Georgefbea8102014-11-28 14:58:25 +0000209
Damien George075d5972014-11-27 20:30:33 +0000210 .bss ALIGN(8) (NOLOAD) : ALIGN(4)
211 {
212 . = ALIGN (8);
213 _bss_start = ABSOLUTE(.);
214 *(.dynsbss)
215 *(.sbss)
216 *(.sbss.*)
217 *(.gnu.linkonce.sb.*)
218 *(.scommon)
219 *(.sbss2)
220 *(.sbss2.*)
221 *(.gnu.linkonce.sb2.*)
222 *(.dynbss)
223 *(.bss)
224 *(.bss.*)
225 *(.gnu.linkonce.b.*)
226 *(COMMON)
227 . = ALIGN (8);
228 _bss_end = ABSOLUTE(.);
229 _heap_start = ABSOLUTE(.);
230 } >dram0_0_seg :dram0_0_bss_phdr
Damien George075d5972014-11-27 20:30:33 +0000231}
232
233/* get ROM code address */
234INCLUDE "eagle.rom.addr.v6.ld"