blob: 8f55ab1f6531c0e22be066390f8b2cb0c9d76005 [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*)
Damien George6d0629b2015-12-18 21:07:58 +000084 *lib/libm/*.o*(.literal*, .text*)
Damien Georgee6362792014-11-29 14:36:18 +000085 *pyexec.o(.literal*, .text*)
86 *readline.o(.literal*, .text*)
87 *pybstdio.o(.literal*, .text*)
Damien Georgee6362792014-11-29 14:36:18 +000088 *gccollect.o(.literal* .text*)
89 *gchelper.o(.literal* .text*)
Damien George304a96d2015-05-13 14:49:14 +010090 *modpyb.o(.literal*, .text*)
91 *modpybpin.o(.literal*, .text*)
92 *modpybrtc.o(.literal*, .text*)
Josef Gajdusekb4793192015-05-11 15:05:59 +020093 *modesp.o(.literal* .text*)
Damien Georgef09f8092015-10-20 22:59:31 +010094 *modnetwork.o(.literal* .text*)
95 *moduos.o(.literal* .text*)
Damien George304a96d2015-05-13 14:49:14 +010096 *modutime.o(.literal* .text*)
Damien Georgee6362792014-11-29 14:36:18 +000097
98 /* we put as much rodata as possible in this section */
99 /* note that only rodata accessed as a machine word is allowed here */
100 *py/qstr.o(.rodata.const_pool)
101 *py/*.o(.rodata.mp_type_*) /* catches type: mp_obj_type_t */
102 *py/*.o(.rodata.*_locals_dict*) /* catches types: mp_obj_dict_t, mp_map_elem_t */
103 *py/*.o(.rodata.mp_module_*) /* catches types: mp_obj_module_t, mp_obj_dict_t, mp_map_elem_t */
104
Damien Georgefbea8102014-11-28 14:58:25 +0000105 _irom0_text_end = ABSOLUTE(.);
106 } >irom0_0_seg :irom0_0_phdr
107
108 .text : ALIGN(4)
109 {
110 _stext = .;
111 _text_start = ABSOLUTE(.);
Josef Gajdusek7d8edef2015-05-26 18:54:55 +0200112 *(.UserEnter.text)
113 . = ALIGN(16);
114 *(.DebugExceptionVector.text)
115 . = ALIGN(16);
116 *(.NMIExceptionVector.text)
117 . = ALIGN(16);
118 *(.KernelExceptionVector.text)
119 LONG(0)
120 LONG(0)
121 LONG(0)
122 LONG(0)
123 . = ALIGN(16);
124 *(.UserExceptionVector.text)
125 LONG(0)
126 LONG(0)
127 LONG(0)
128 LONG(0)
129 . = ALIGN(16);
130 *(.DoubleExceptionVector.text)
131 LONG(0)
132 LONG(0)
133 LONG(0)
134 LONG(0)
135 . = ALIGN (16);
Damien Georgefbea8102014-11-28 14:58:25 +0000136 *(.entry.text)
137 *(.init.literal)
138 *(.init)
139 *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
140 *(.fini.literal)
141 *(.fini)
142 *(.gnu.version)
Damien Georgefbea8102014-11-28 14:58:25 +0000143 _text_end = ABSOLUTE(.);
144 _etext = .;
145 } >iram1_0_seg :iram1_0_phdr
146
147 .lit4 : ALIGN(4)
148 {
149 _lit4_start = ABSOLUTE(.);
150 *(*.lit4)
151 *(.lit4.*)
152 *(.gnu.linkonce.lit4.*)
153 _lit4_end = ABSOLUTE(.);
154 } >iram1_0_seg :iram1_0_phdr
155
Damien George075d5972014-11-27 20:30:33 +0000156 .data : ALIGN(4)
157 {
158 _data_start = ABSOLUTE(.);
159 *(.data)
160 *(.data.*)
161 *(.gnu.linkonce.d.*)
162 *(.data1)
163 *(.sdata)
164 *(.sdata.*)
165 *(.gnu.linkonce.s.*)
166 *(.sdata2)
167 *(.sdata2.*)
168 *(.gnu.linkonce.s2.*)
169 *(.jcr)
170 _data_end = ABSOLUTE(.);
171 } >dram0_0_seg :dram0_0_phdr
Damien Georgefbea8102014-11-28 14:58:25 +0000172
Damien George075d5972014-11-27 20:30:33 +0000173 .rodata : ALIGN(4)
174 {
175 _rodata_start = ABSOLUTE(.);
Paul Sokolovsky259f1342015-12-27 18:23:11 +0200176 *(.sdk.version)
Damien George075d5972014-11-27 20:30:33 +0000177 *(.rodata)
178 *(.rodata.*)
179 *(.gnu.linkonce.r.*)
180 *(.rodata1)
181 __XT_EXCEPTION_TABLE__ = ABSOLUTE(.);
182 *(.xt_except_table)
183 *(.gcc_except_table)
184 *(.gnu.linkonce.e.*)
185 *(.gnu.version_r)
186 *(.eh_frame)
187 /* C++ constructor and destructor tables, properly ordered: */
188 KEEP (*crtbegin.o(.ctors))
189 KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
190 KEEP (*(SORT(.ctors.*)))
191 KEEP (*(.ctors))
192 KEEP (*crtbegin.o(.dtors))
193 KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
194 KEEP (*(SORT(.dtors.*)))
195 KEEP (*(.dtors))
196 /* C++ exception handlers table: */
197 __XT_EXCEPTION_DESCS__ = ABSOLUTE(.);
198 *(.xt_except_desc)
199 *(.gnu.linkonce.h.*)
200 __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
201 *(.xt_except_desc_end)
202 *(.dynamic)
203 *(.gnu.version_d)
204 . = ALIGN(4); /* this table MUST be 4-byte aligned */
205 _bss_table_start = ABSOLUTE(.);
206 LONG(_bss_start)
207 LONG(_bss_end)
208 _bss_table_end = ABSOLUTE(.);
209 _rodata_end = ABSOLUTE(.);
210 } >dram0_0_seg :dram0_0_phdr
Damien Georgefbea8102014-11-28 14:58:25 +0000211
Damien George075d5972014-11-27 20:30:33 +0000212 .bss ALIGN(8) (NOLOAD) : ALIGN(4)
213 {
214 . = ALIGN (8);
215 _bss_start = ABSOLUTE(.);
216 *(.dynsbss)
217 *(.sbss)
218 *(.sbss.*)
219 *(.gnu.linkonce.sb.*)
220 *(.scommon)
221 *(.sbss2)
222 *(.sbss2.*)
223 *(.gnu.linkonce.sb2.*)
224 *(.dynbss)
225 *(.bss)
226 *(.bss.*)
227 *(.gnu.linkonce.b.*)
228 *(COMMON)
229 . = ALIGN (8);
230 _bss_end = ABSOLUTE(.);
231 _heap_start = ABSOLUTE(.);
232 } >dram0_0_seg :dram0_0_bss_phdr
Damien George075d5972014-11-27 20:30:33 +0000233}
234
235/* get ROM code address */
236INCLUDE "eagle.rom.addr.v6.ld"