forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/arch/xtensa/kernel/vmlinux.lds.S
....@@ -14,12 +14,14 @@
1414 * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
1515 */
1616
17
+#define RO_EXCEPTION_TABLE_ALIGN 16
18
+
1719 #include <asm-generic/vmlinux.lds.h>
1820 #include <asm/page.h>
1921 #include <asm/thread_info.h>
2022
23
+#include <asm/core.h>
2124 #include <asm/vectors.h>
22
-#include <variant/core.h>
2325
2426 OUTPUT_ARCH(xtensa)
2527 ENTRY(_start)
....@@ -45,15 +47,20 @@
4547 LONG(sym ## _end); \
4648 LONG(LOADADDR(section))
4749
50
+#if !defined(CONFIG_VECTORS_ADDR) && XCHAL_HAVE_VECBASE
51
+#define MERGED_VECTORS 1
52
+#else
53
+#define MERGED_VECTORS 0
54
+#endif
55
+
4856 /*
49
- * Macro to define a section for a vector. When CONFIG_VECTORS_OFFSET is
50
- * defined code for every vector is located with other init data. At startup
57
+ * Macro to define a section for a vector. When MERGED_VECTORS is 0
58
+ * code for every vector is located with other init data. At startup
5159 * time head.S copies code for every vector to its final position according
5260 * to description recorded in the corresponding RELOCATE_ENTRY.
5361 */
5462
55
-#ifdef CONFIG_VECTORS_OFFSET
56
-#define SECTION_VECTOR(sym, section, addr, prevsec) \
63
+#define SECTION_VECTOR4(sym, section, addr, prevsec) \
5764 section addr : AT(((LOADADDR(prevsec) + SIZEOF(prevsec)) + 3) & ~ 3) \
5865 { \
5966 . = ALIGN(4); \
....@@ -61,11 +68,10 @@
6168 *(section) \
6269 sym ## _end = ABSOLUTE(.); \
6370 }
64
-#else
65
-#define SECTION_VECTOR(section, addr) \
71
+
72
+#define SECTION_VECTOR2(section, addr) \
6673 . = addr; \
6774 *(section)
68
-#endif
6975
7076 /*
7177 * Mapping of input sections to output sections when linking.
....@@ -84,30 +90,32 @@
8490 /* The HEAD_TEXT section must be the first section! */
8591 HEAD_TEXT
8692
87
-#ifndef CONFIG_VECTORS_OFFSET
88
- . = ALIGN(PAGE_SIZE);
89
- _vecbase = .;
93
+#if MERGED_VECTORS
94
+ . = ALIGN(PAGE_SIZE);
95
+ _vecbase = .;
9096
91
- SECTION_VECTOR (.WindowVectors.text, WINDOW_VECTORS_VADDR)
97
+ SECTION_VECTOR2 (.WindowVectors.text, WINDOW_VECTORS_VADDR)
9298 #if XCHAL_EXCM_LEVEL >= 2
93
- SECTION_VECTOR (.Level2InterruptVector.text, INTLEVEL2_VECTOR_VADDR)
99
+ SECTION_VECTOR2 (.Level2InterruptVector.text, INTLEVEL2_VECTOR_VADDR)
94100 #endif
95101 #if XCHAL_EXCM_LEVEL >= 3
96
- SECTION_VECTOR (.Level3InterruptVector.text, INTLEVEL3_VECTOR_VADDR)
102
+ SECTION_VECTOR2 (.Level3InterruptVector.text, INTLEVEL3_VECTOR_VADDR)
97103 #endif
98104 #if XCHAL_EXCM_LEVEL >= 4
99
- SECTION_VECTOR (.Level4InterruptVector.text, INTLEVEL4_VECTOR_VADDR)
105
+ SECTION_VECTOR2 (.Level4InterruptVector.text, INTLEVEL4_VECTOR_VADDR)
100106 #endif
101107 #if XCHAL_EXCM_LEVEL >= 5
102
- SECTION_VECTOR (.Level5InterruptVector.text, INTLEVEL5_VECTOR_VADDR)
108
+ SECTION_VECTOR2 (.Level5InterruptVector.text, INTLEVEL5_VECTOR_VADDR)
103109 #endif
104110 #if XCHAL_EXCM_LEVEL >= 6
105
- SECTION_VECTOR (.Level6InterruptVector.text, INTLEVEL6_VECTOR_VADDR)
111
+ SECTION_VECTOR2 (.Level6InterruptVector.text, INTLEVEL6_VECTOR_VADDR)
106112 #endif
107
- SECTION_VECTOR (.DebugInterruptVector.text, DEBUG_VECTOR_VADDR)
108
- SECTION_VECTOR (.KernelExceptionVector.text, KERNEL_VECTOR_VADDR)
109
- SECTION_VECTOR (.UserExceptionVector.text, USER_VECTOR_VADDR)
110
- SECTION_VECTOR (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR)
113
+ SECTION_VECTOR2 (.DebugInterruptVector.text, DEBUG_VECTOR_VADDR)
114
+ SECTION_VECTOR2 (.KernelExceptionVector.text, KERNEL_VECTOR_VADDR)
115
+ SECTION_VECTOR2 (.UserExceptionVector.text, USER_VECTOR_VADDR)
116
+ SECTION_VECTOR2 (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR)
117
+
118
+ *(.exception.text)
111119 #endif
112120
113121 IRQENTRY_TEXT
....@@ -117,25 +125,22 @@
117125 SCHED_TEXT
118126 CPUIDLE_TEXT
119127 LOCK_TEXT
120
-
128
+ *(.fixup)
121129 }
122130 _etext = .;
123131 PROVIDE (etext = .);
124132
125133 . = ALIGN(16);
126134
127
- RODATA
135
+ RO_DATA(4096)
128136
129
- /* Relocation table */
130
-
131
- .fixup : { *(.fixup) }
132
-
133
- EXCEPTION_TABLE(16)
134
- NOTES
135137 /* Data section */
136138
139
+#ifdef CONFIG_XIP_KERNEL
140
+ INIT_TEXT_SECTION(PAGE_SIZE)
141
+#else
137142 _sdata = .;
138
- RW_DATA_SECTION(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE)
143
+ RW_DATA(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE)
139144 _edata = .;
140145
141146 /* Initialization code and data: */
....@@ -147,6 +152,11 @@
147152 .init.data :
148153 {
149154 INIT_DATA
155
+ }
156
+#endif
157
+
158
+ .init.rodata :
159
+ {
150160 . = ALIGN(0x4);
151161 __tagtable_begin = .;
152162 *(.taglist)
....@@ -155,7 +165,7 @@
155165 . = ALIGN(16);
156166 __boot_reloc_table_start = ABSOLUTE(.);
157167
158
-#ifdef CONFIG_VECTORS_OFFSET
168
+#if !MERGED_VECTORS
159169 RELOCATE_ENTRY(_WindowVectors_text,
160170 .WindowVectors.text);
161171 #if XCHAL_EXCM_LEVEL >= 2
....@@ -186,19 +196,23 @@
186196 .DoubleExceptionVector.text);
187197 RELOCATE_ENTRY(_DebugInterruptVector_text,
188198 .DebugInterruptVector.text);
199
+ RELOCATE_ENTRY(_exception_text,
200
+ .exception.text);
201
+#endif
202
+#ifdef CONFIG_XIP_KERNEL
203
+ RELOCATE_ENTRY(_xip_data, .data);
204
+ RELOCATE_ENTRY(_xip_init_data, .init.data);
189205 #endif
190206 #if defined(CONFIG_SMP)
191207 RELOCATE_ENTRY(_SecondaryResetVector_text,
192208 .SecondaryResetVector.text);
193209 #endif
194210
195
-
196211 __boot_reloc_table_end = ABSOLUTE(.) ;
197212
198213 INIT_SETUP(XCHAL_ICACHE_LINESIZE)
199214 INIT_CALLS
200215 CON_INITCALL
201
- SECURITY_INITCALL
202216 INIT_RAM_FS
203217 }
204218
....@@ -209,21 +223,24 @@
209223 . = ALIGN(4);
210224 .dummy : { LONG(0) }
211225
212
-#ifdef CONFIG_VECTORS_OFFSET
226
+#undef LAST
227
+#define LAST .dummy
228
+
229
+#if !MERGED_VECTORS
213230 /* The vectors are relocated to the real position at startup time */
214231
215
- SECTION_VECTOR (_WindowVectors_text,
232
+ SECTION_VECTOR4 (_WindowVectors_text,
216233 .WindowVectors.text,
217234 WINDOW_VECTORS_VADDR,
218235 .dummy)
219
- SECTION_VECTOR (_DebugInterruptVector_text,
236
+ SECTION_VECTOR4 (_DebugInterruptVector_text,
220237 .DebugInterruptVector.text,
221238 DEBUG_VECTOR_VADDR,
222239 .WindowVectors.text)
223240 #undef LAST
224241 #define LAST .DebugInterruptVector.text
225242 #if XCHAL_EXCM_LEVEL >= 2
226
- SECTION_VECTOR (_Level2InterruptVector_text,
243
+ SECTION_VECTOR4 (_Level2InterruptVector_text,
227244 .Level2InterruptVector.text,
228245 INTLEVEL2_VECTOR_VADDR,
229246 LAST)
....@@ -231,7 +248,7 @@
231248 # define LAST .Level2InterruptVector.text
232249 #endif
233250 #if XCHAL_EXCM_LEVEL >= 3
234
- SECTION_VECTOR (_Level3InterruptVector_text,
251
+ SECTION_VECTOR4 (_Level3InterruptVector_text,
235252 .Level3InterruptVector.text,
236253 INTLEVEL3_VECTOR_VADDR,
237254 LAST)
....@@ -239,7 +256,7 @@
239256 # define LAST .Level3InterruptVector.text
240257 #endif
241258 #if XCHAL_EXCM_LEVEL >= 4
242
- SECTION_VECTOR (_Level4InterruptVector_text,
259
+ SECTION_VECTOR4 (_Level4InterruptVector_text,
243260 .Level4InterruptVector.text,
244261 INTLEVEL4_VECTOR_VADDR,
245262 LAST)
....@@ -247,7 +264,7 @@
247264 # define LAST .Level4InterruptVector.text
248265 #endif
249266 #if XCHAL_EXCM_LEVEL >= 5
250
- SECTION_VECTOR (_Level5InterruptVector_text,
267
+ SECTION_VECTOR4 (_Level5InterruptVector_text,
251268 .Level5InterruptVector.text,
252269 INTLEVEL5_VECTOR_VADDR,
253270 LAST)
....@@ -255,81 +272,100 @@
255272 # define LAST .Level5InterruptVector.text
256273 #endif
257274 #if XCHAL_EXCM_LEVEL >= 6
258
- SECTION_VECTOR (_Level6InterruptVector_text,
275
+ SECTION_VECTOR4 (_Level6InterruptVector_text,
259276 .Level6InterruptVector.text,
260277 INTLEVEL6_VECTOR_VADDR,
261278 LAST)
262279 # undef LAST
263280 # define LAST .Level6InterruptVector.text
264281 #endif
265
- SECTION_VECTOR (_KernelExceptionVector_text,
282
+ SECTION_VECTOR4 (_KernelExceptionVector_text,
266283 .KernelExceptionVector.text,
267284 KERNEL_VECTOR_VADDR,
268285 LAST)
269286 #undef LAST
270
- SECTION_VECTOR (_UserExceptionVector_text,
287
+ SECTION_VECTOR4 (_UserExceptionVector_text,
271288 .UserExceptionVector.text,
272289 USER_VECTOR_VADDR,
273290 .KernelExceptionVector.text)
274
- SECTION_VECTOR (_DoubleExceptionVector_text,
291
+ SECTION_VECTOR4 (_DoubleExceptionVector_text,
275292 .DoubleExceptionVector.text,
276293 DOUBLEEXC_VECTOR_VADDR,
277294 .UserExceptionVector.text)
278
-
279
- . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
295
+#define LAST .DoubleExceptionVector.text
280296
281297 #endif
282298 #if defined(CONFIG_SMP)
283299
284
- SECTION_VECTOR (_SecondaryResetVector_text,
300
+ SECTION_VECTOR4 (_SecondaryResetVector_text,
285301 .SecondaryResetVector.text,
286302 RESET_VECTOR1_VADDR,
287
- .DoubleExceptionVector.text)
288
-
289
- . = LOADADDR(.SecondaryResetVector.text)+SIZEOF(.SecondaryResetVector.text);
303
+ LAST)
304
+#undef LAST
305
+#define LAST .SecondaryResetVector.text
290306
291307 #endif
308
+#if !MERGED_VECTORS
309
+ SECTION_VECTOR4 (_exception_text,
310
+ .exception.text,
311
+ ,
312
+ LAST)
313
+#undef LAST
314
+#define LAST .exception.text
292315
316
+#endif
317
+ . = (LOADADDR(LAST) + SIZEOF(LAST) + 3) & ~ 3;
318
+
319
+ .dummy1 : AT(ADDR(.dummy1)) { LONG(0) }
293320 . = ALIGN(PAGE_SIZE);
294321
322
+#ifndef CONFIG_XIP_KERNEL
295323 __init_end = .;
296324
297325 BSS_SECTION(0, 8192, 0)
326
+#endif
298327
299328 _end = .;
300329
301
- .xt.lit : { *(.xt.lit) }
302
- .xt.prop : { *(.xt.prop) }
330
+#ifdef CONFIG_XIP_KERNEL
331
+ . = CONFIG_XIP_DATA_ADDR;
303332
304
- .debug 0 : { *(.debug) }
305
- .line 0 : { *(.line) }
306
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
307
- .debug_sfnames 0 : { *(.debug_sfnames) }
308
- .debug_aranges 0 : { *(.debug_aranges) }
309
- .debug_pubnames 0 : { *(.debug_pubnames) }
310
- .debug_info 0 : { *(.debug_info) }
311
- .debug_abbrev 0 : { *(.debug_abbrev) }
312
- .debug_line 0 : { *(.debug_line) }
313
- .debug_frame 0 : { *(.debug_frame) }
314
- .debug_str 0 : { *(.debug_str) }
315
- .debug_loc 0 : { *(.debug_loc) }
316
- .debug_macinfo 0 : { *(.debug_macinfo) }
317
- .debug_weaknames 0 : { *(.debug_weaknames) }
318
- .debug_funcnames 0 : { *(.debug_funcnames) }
319
- .debug_typenames 0 : { *(.debug_typenames) }
320
- .debug_varnames 0 : { *(.debug_varnames) }
333
+ _xip_start = .;
321334
322
- .xt.insn 0 :
335
+#undef LOAD_OFFSET
336
+#define LOAD_OFFSET \
337
+ (CONFIG_XIP_DATA_ADDR - (LOADADDR(.dummy1) + SIZEOF(.dummy1) + 3) & ~ 3)
338
+
339
+ _xip_data_start = .;
340
+ _sdata = .;
341
+ RW_DATA(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE)
342
+ _edata = .;
343
+ _xip_data_end = .;
344
+
345
+ /* Initialization data: */
346
+
347
+ STRUCT_ALIGN();
348
+
349
+ _xip_init_data_start = .;
350
+ __init_begin = .;
351
+ .init.data :
323352 {
324
- *(.xt.insn)
325
- *(.gnu.linkonce.x*)
353
+ INIT_DATA
326354 }
355
+ _xip_init_data_end = .;
356
+ __init_end = .;
357
+ BSS_SECTION(0, 8192, 0)
327358
328
- .xt.lit 0 :
329
- {
330
- *(.xt.lit)
331
- *(.gnu.linkonce.p*)
332
- }
359
+ _xip_end = .;
360
+
361
+#undef LOAD_OFFSET
362
+#endif
363
+
364
+ DWARF_DEBUG
365
+
366
+ .xt.prop 0 : { KEEP(*(.xt.prop .xt.prop.* .gnu.linkonce.prop.*)) }
367
+ .xt.insn 0 : { KEEP(*(.xt.insn .xt.insn.* .gnu.linkonce.x*)) }
368
+ .xt.lit 0 : { KEEP(*(.xt.lit .xt.lit.* .gnu.linkonce.p*)) }
333369
334370 /* Sections to be discarded */
335371 DISCARDS