1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * (C) Copyright 2007 Tensilica, Inc.
4 * (C) Copyright 2014 - 2016 Cadence Design Systems Inc.
7 #ifndef _XTENSA_LDSCRIPT_H
8 #define _XTENSA_LDSCRIPT_H
11 * This linker script is pre-processed with CPP to avoid hard-coding
12 * addresses that depend on the Xtensa core configuration, because
13 * this FPGA board can be used with a huge variety of Xtensa cores.
16 #include <asm/arch/core.h>
17 #include <asm/addrspace.h>
21 #define FORCE_OUTPUT . = .
22 #define FOLLOWING(sec) \
23 AT(((LOADADDR(sec) + SIZEOF(sec) + ALIGN_LMA-1)) & ~(ALIGN_LMA-1))
26 * Specify an output section that will be added to the ROM store table
27 * (PACKED_SECTION) or one that will be resident in ROM (RESIDENT_SECTION).
28 * 'symname' is a base name for section boundary symbols *_start & *_end.
29 * 'lma' is the load address at which a section will be packed in ROM.
30 * 'region' is the basename identifying a memory region and program header.
31 * 'keep' prevents removal of empty sections (must be 'KEEP' or 'NOKEEP').
34 #define RELOCATE1(_sec_) \
35 LONG(_##_sec_##_start); \
36 LONG(_##_sec_##_end); \
37 LONG(LOADADDR(.##_sec_));
39 #define RELOCATE2(_sym_, _sec_) \
40 LONG(_##_sym_##_##_sec_##_start); \
41 LONG(_##_sym_##_##_sec_##_end); \
42 LONG(LOADADDR(.##_sym_##.##_sec_));
44 #define SECTION_VECTOR(_sym_, _sec_, _vma_, _lma_) \
45 .##_sym_##.##_sec_ _vma_ : _lma_ \
48 _##_sym_##_##_sec_##_start = ABSOLUTE(.); \
49 KEEP(*(.##_sym_##.##_sec_)) \
50 _##_sym_##_##_sec_##_end = ABSOLUTE(.); \
53 /* In MMU configs there are two aliases of SYSROM, cached and uncached.
54 * For various reasons it is simpler to use the uncached mapping for load
55 * addresses, so ROM sections end up contiguous with the reset vector and
56 * we get a compact binary image. However we can gain performance by doing
57 * the unpacking from the cached ROM mapping. So we adjust all the load
58 * addresses in the ROM store table with an offset to the cached mapping,
59 * including the symbols referring to the ROM store table itself.
62 #define SECTION_ResetVector(_vma_, _lma_) \
63 .ResetVector.text _vma_ : _lma_ \
66 KEEP(*(.ResetVector.text)); \
67 KEEP(*(.reset.literal .reset.text)) \
70 #define SECTION_text(_vma_, _lma_) \
73 _text_start = ABSOLUTE(.); \
75 *(.literal.* .text.* .stub) \
76 *(.gnu.warning .gnu.linkonce.literal.*) \
77 *(.gnu.linkonce.t.*.literal .gnu.linkonce.t.*) \
81 _text_end = ABSOLUTE(.); \
84 #define SECTION_rodata(_vma_, _lma_) \
85 .rodata _vma_ : _lma_ \
87 _rodata_start = ABSOLUTE(.); \
91 *(.gnu.linkonce.r.*) \
93 __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); \
95 *(.gcc_except_table) \
96 *(.gnu.linkonce.e.*) \
99 _rodata_end = ABSOLUTE(.); \
102 #define SECTION_u_boot_list(_vma_, _lma_) \
103 .u_boot_list _vma_ : _lma_ \
105 _u_boot_list_start = ABSOLUTE(.); \
106 KEEP(*(SORT(.u_boot_list*))); \
107 _u_boot_list_end = ABSOLUTE(.); \
110 #define SECTION_data(_vma_, _lma_) \
111 .data _vma_ : _lma_ \
113 _data_start = ABSOLUTE(.); \
116 *(.gnu.linkonce.d.*) \
120 *(.gnu.linkonce.s.*) \
123 *(.gnu.linkonce.s2.*) \
128 _data_end = ABSOLUTE(.); \
131 #define SECTION_lit4(_vma_, _lma_) \
132 .lit4 _vma_ : _lma_ \
134 _lit4_start = ABSOLUTE(.); \
136 *(.gnu.linkonce.lit4.*) \
137 _lit4_end = ABSOLUTE(.); \
140 #define SECTION_bss(_vma_, _lma_) \
144 _bss_start = ABSOLUTE(.); \
145 __bss_start = ABSOLUTE(.); \
149 *(.gnu.linkonce.sb.*) \
153 *(.gnu.linkonce.sb2.*) \
157 *(.gnu.linkonce.b.*) \
161 _bss_end = ABSOLUTE(.); \
162 __bss_end = ABSOLUTE(.); \
164 PROVIDE(end = ALIGN(0x8)); \
165 _stack_sentry = ALIGN(0x8); \
168 #define SECTION_debug \
169 .debug 0 : { *(.debug) } \
170 .line 0 : { *(.line) } \
171 .debug_srcinfo 0 : { *(.debug_srcinfo) } \
172 .debug_sfnames 0 : { *(.debug_sfnames) } \
173 .debug_aranges 0 : { *(.debug_aranges) } \
174 .debug_pubnames 0 : { *(.debug_pubnames) } \
175 .debug_info 0 : { *(.debug_info) } \
176 .debug_abbrev 0 : { *(.debug_abbrev) } \
177 .debug_line 0 : { *(.debug_line) } \
178 .debug_frame 0 : { *(.debug_frame) } \
179 .debug_str 0 : { *(.debug_str) } \
180 .debug_loc 0 : { *(.debug_loc) } \
181 .debug_macinfo 0 : { *(.debug_macinfo) } \
182 .debug_weaknames 0 : { *(.debug_weaknames) } \
183 .debug_funcnames 0 : { *(.debug_funcnames) } \
184 .debug_typenames 0 : { *(.debug_typenames) } \
185 .debug_varnames 0 : { *(.debug_varnames) }
187 #define SECTION_xtensa \
191 KEEP (*(.gnu.linkonce.x.*)) \
196 KEEP (*(.xt.prop.*)) \
197 KEEP (*(.gnu.linkonce.prop.*)) \
202 KEEP (*(.xt.lit.*)) \
203 KEEP (*(.gnu.linkonce.p.*)) \
205 .xt.profile_range 0 : \
207 KEEP (*(.xt.profile_range)) \
208 KEEP (*(.gnu.linkonce.profile_range.*)) \
210 .xt.profile_ranges 0 : \
212 KEEP (*(.xt.profile_ranges)) \
213 KEEP (*(.gnu.linkonce.xt.profile_ranges.*)) \
215 .xt.profile_files 0 : \
217 KEEP (*(.xt.profile_files)) \
218 KEEP (*(.gnu.linkonce.xt.profile_files.*)) \
221 #endif /* _XTENSA_LDSCRIPT_H */