blob: 62a1c052685764c8a51c4fb7814ad62c44985ea4 [file] [log] [blame]
Chris Zankel1387dab2016-08-10 18:36:44 +03001/*
2 * (C) Copyright 2007 Tensilica, Inc.
3 * (C) Copyright 2014 - 2016 Cadence Design Systems Inc.
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#ifndef _XTENSA_LDSCRIPT_H
9#define _XTENSA_LDSCRIPT_H
10
11/*
12 * This linker script is pre-processed with CPP to avoid hard-coding
13 * addresses that depend on the Xtensa core configuration, because
14 * this FPGA board can be used with a huge variety of Xtensa cores.
15 */
16
17#include <asm/arch/core.h>
18#include <asm/addrspace.h>
19
20#define ALIGN_LMA 4
21#define LMA_EQ_VMA
22#define FORCE_OUTPUT . = .
23#define FOLLOWING(sec) \
24 AT(((LOADADDR(sec) + SIZEOF(sec) + ALIGN_LMA-1)) & ~(ALIGN_LMA-1))
25
26/*
27 * Specify an output section that will be added to the ROM store table
28 * (PACKED_SECTION) or one that will be resident in ROM (RESIDENT_SECTION).
29 * 'symname' is a base name for section boundary symbols *_start & *_end.
30 * 'lma' is the load address at which a section will be packed in ROM.
31 * 'region' is the basename identifying a memory region and program header.
32 * 'keep' prevents removal of empty sections (must be 'KEEP' or 'NOKEEP').
33 */
34
35#define RELOCATE1(_sec_) \
36 LONG(_##_sec_##_start); \
37 LONG(_##_sec_##_end); \
38 LONG(LOADADDR(.##_sec_));
39
40#define RELOCATE2(_sym_, _sec_) \
41 LONG(_##_sym_##_##_sec_##_start); \
42 LONG(_##_sym_##_##_sec_##_end); \
43 LONG(LOADADDR(.##_sym_##.##_sec_));
44
45#define SECTION_VECTOR(_sym_, _sec_, _vma_, _lma_) \
46.##_sym_##.##_sec_ _vma_ : _lma_ \
47{ \
48 . = ALIGN(4); \
49 _##_sym_##_##_sec_##_start = ABSOLUTE(.); \
50 KEEP(*(.##_sym_##.##_sec_)) \
51 _##_sym_##_##_sec_##_end = ABSOLUTE(.); \
52}
53
54/* In MMU configs there are two aliases of SYSROM, cached and uncached.
55 * For various reasons it is simpler to use the uncached mapping for load
56 * addresses, so ROM sections end up contiguous with the reset vector and
57 * we get a compact binary image. However we can gain performance by doing
58 * the unpacking from the cached ROM mapping. So we adjust all the load
59 * addresses in the ROM store table with an offset to the cached mapping,
60 * including the symbols referring to the ROM store table itself.
61 */
62
63#define SECTION_ResetVector(_vma_, _lma_) \
64 .ResetVector.text _vma_ : _lma_ \
65 { \
66 FORCE_OUTPUT; \
67 KEEP(*(.ResetVector.text)); \
68 KEEP(*(.reset.literal .reset.text)) \
69 }
70
71#define SECTION_text(_vma_, _lma_) \
72 .text _vma_ : _lma_ \
73 { \
74 _text_start = ABSOLUTE(.); \
75 *(.literal .text) \
76 *(.literal.* .text.* .stub) \
77 *(.gnu.warning .gnu.linkonce.literal.*) \
78 *(.gnu.linkonce.t.*.literal .gnu.linkonce.t.*) \
79 *(.fini.literal) \
80 *(.fini) \
81 *(.gnu.version) \
82 _text_end = ABSOLUTE(.); \
83 }
84
85#define SECTION_rodata(_vma_, _lma_) \
86 .rodata _vma_ : _lma_ \
87 { \
88 _rodata_start = ABSOLUTE(.); \
89 *(.rodata) \
90 *(.rodata.*) \
91 *(.dtb.init.rodata) \
92 *(.gnu.linkonce.r.*) \
93 *(.rodata1) \
94 __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); \
95 *(.xt_except_table) \
96 *(.gcc_except_table) \
97 *(.gnu.linkonce.e.*) \
98 *(.gnu.version_r) \
99 . = ALIGN(16); \
100 _rodata_end = ABSOLUTE(.); \
101 }
102
103#define SECTION_u_boot_list(_vma_, _lma_) \
104 .u_boot_list _vma_ : _lma_ \
105 { \
106 _u_boot_list_start = ABSOLUTE(.); \
107 KEEP(*(SORT(.u_boot_list*))); \
108 _u_boot_list_end = ABSOLUTE(.); \
109 }
110
111#define SECTION_data(_vma_, _lma_) \
112 .data _vma_ : _lma_ \
113 { \
114 _data_start = ABSOLUTE(.); \
115 *(.data) \
116 *(.data.*) \
117 *(.gnu.linkonce.d.*) \
118 *(.data1) \
119 *(.sdata) \
120 *(.sdata.*) \
121 *(.gnu.linkonce.s.*) \
122 *(.sdata2) \
123 *(.sdata2.*) \
124 *(.gnu.linkonce.s2.*) \
125 *(.jcr) \
126 *(.eh_frame) \
127 *(.dynamic) \
128 *(.gnu.version_d) \
129 _data_end = ABSOLUTE(.); \
130 }
131
132#define SECTION_lit4(_vma_, _lma_) \
133 .lit4 _vma_ : _lma_ \
134 { \
135 _lit4_start = ABSOLUTE(.); \
136 *(*.lit4) \
137 *(.gnu.linkonce.lit4.*) \
138 _lit4_end = ABSOLUTE(.); \
139 }
140
141#define SECTION_bss(_vma_, _lma_) \
142 .bss _vma_ : _lma_ \
143 { \
144 . = ALIGN(8); \
145 _bss_start = ABSOLUTE(.); \
146 __bss_start = ABSOLUTE(.); \
147 *(.dynsbss) \
148 *(.sbss) \
149 *(.sbss.*) \
150 *(.gnu.linkonce.sb.*) \
151 *(.scommon) \
152 *(.sbss2) \
153 *(.sbss2.*) \
154 *(.gnu.linkonce.sb2.*) \
155 *(.dynbss) \
156 *(.bss) \
157 *(.bss.*) \
158 *(.gnu.linkonce.b.*) \
159 *(COMMON) \
160 *(.sram.bss) \
161 . = ALIGN(8); \
162 _bss_end = ABSOLUTE(.); \
163 __bss_end = ABSOLUTE(.); \
164 _end = ALIGN(0x8); \
165 PROVIDE(end = ALIGN(0x8)); \
166 _stack_sentry = ALIGN(0x8); \
167 }
168
169#define SECTION_debug \
170 .debug 0 : { *(.debug) } \
171 .line 0 : { *(.line) } \
172 .debug_srcinfo 0 : { *(.debug_srcinfo) } \
173 .debug_sfnames 0 : { *(.debug_sfnames) } \
174 .debug_aranges 0 : { *(.debug_aranges) } \
175 .debug_pubnames 0 : { *(.debug_pubnames) } \
176 .debug_info 0 : { *(.debug_info) } \
177 .debug_abbrev 0 : { *(.debug_abbrev) } \
178 .debug_line 0 : { *(.debug_line) } \
179 .debug_frame 0 : { *(.debug_frame) } \
180 .debug_str 0 : { *(.debug_str) } \
181 .debug_loc 0 : { *(.debug_loc) } \
182 .debug_macinfo 0 : { *(.debug_macinfo) } \
183 .debug_weaknames 0 : { *(.debug_weaknames) } \
184 .debug_funcnames 0 : { *(.debug_funcnames) } \
185 .debug_typenames 0 : { *(.debug_typenames) } \
186 .debug_varnames 0 : { *(.debug_varnames) }
187
188#define SECTION_xtensa \
189 .xt.insn 0 : \
190 { \
191 KEEP (*(.xt.insn)) \
192 KEEP (*(.gnu.linkonce.x.*)) \
193 } \
194 .xt.prop 0 : \
195 { \
196 KEEP (*(.xt.prop)) \
197 KEEP (*(.xt.prop.*)) \
198 KEEP (*(.gnu.linkonce.prop.*)) \
199 } \
200 .xt.lit 0 : \
201 { \
202 KEEP (*(.xt.lit)) \
203 KEEP (*(.xt.lit.*)) \
204 KEEP (*(.gnu.linkonce.p.*)) \
205 } \
206 .xt.profile_range 0 : \
207 { \
208 KEEP (*(.xt.profile_range)) \
209 KEEP (*(.gnu.linkonce.profile_range.*)) \
210 } \
211 .xt.profile_ranges 0 : \
212 { \
213 KEEP (*(.xt.profile_ranges)) \
214 KEEP (*(.gnu.linkonce.xt.profile_ranges.*)) \
215 } \
216 .xt.profile_files 0 : \
217 { \
218 KEEP (*(.xt.profile_files)) \
219 KEEP (*(.gnu.linkonce.xt.profile_files.*)) \
220 }
221
222#endif /* _XTENSA_LDSCRIPT_H */