SPDX: Convert all of our single license tags to Linux Kernel style
[oweals/u-boot.git] / arch / xtensa / include / asm / ldscript.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2007 Tensilica, Inc.
4  * (C) Copyright 2014 - 2016 Cadence Design Systems Inc.
5  */
6
7 #ifndef _XTENSA_LDSCRIPT_H
8 #define _XTENSA_LDSCRIPT_H
9
10 /*
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.
14  */
15
16 #include <asm/arch/core.h>
17 #include <asm/addrspace.h>
18
19 #define ALIGN_LMA       4
20 #define LMA_EQ_VMA
21 #define FORCE_OUTPUT    . = .
22 #define FOLLOWING(sec)                                                  \
23         AT(((LOADADDR(sec) + SIZEOF(sec) + ALIGN_LMA-1)) & ~(ALIGN_LMA-1))
24
25 /*
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').
32  */
33
34 #define RELOCATE1(_sec_)                                                \
35         LONG(_##_sec_##_start);                                         \
36         LONG(_##_sec_##_end);                                           \
37         LONG(LOADADDR(.##_sec_));
38
39 #define RELOCATE2(_sym_, _sec_)                                         \
40         LONG(_##_sym_##_##_sec_##_start);                               \
41         LONG(_##_sym_##_##_sec_##_end);                                 \
42         LONG(LOADADDR(.##_sym_##.##_sec_));
43
44 #define SECTION_VECTOR(_sym_, _sec_, _vma_, _lma_)                      \
45 .##_sym_##.##_sec_ _vma_ : _lma_                                        \
46 {                                                                       \
47         . = ALIGN(4);                                                   \
48         _##_sym_##_##_sec_##_start = ABSOLUTE(.);                       \
49         KEEP(*(.##_sym_##.##_sec_))                                     \
50         _##_sym_##_##_sec_##_end = ABSOLUTE(.);                         \
51 }
52
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.
60  */
61
62 #define SECTION_ResetVector(_vma_, _lma_)                               \
63         .ResetVector.text _vma_ : _lma_                                 \
64         {                                                               \
65                 FORCE_OUTPUT;                                           \
66                 KEEP(*(.ResetVector.text));                             \
67                 KEEP(*(.reset.literal .reset.text))                     \
68         }
69
70 #define SECTION_text(_vma_, _lma_)                                      \
71         .text _vma_ : _lma_                                             \
72         {                                                               \
73                 _text_start = ABSOLUTE(.);                              \
74                 *(.literal .text)                                       \
75                 *(.literal.* .text.* .stub)                             \
76                 *(.gnu.warning .gnu.linkonce.literal.*)                 \
77                 *(.gnu.linkonce.t.*.literal .gnu.linkonce.t.*)          \
78                 *(.fini.literal)                                        \
79                 *(.fini)                                                \
80                 *(.gnu.version)                                         \
81                 _text_end = ABSOLUTE(.);                                \
82         }
83
84 #define SECTION_rodata(_vma_, _lma_)                                    \
85         .rodata _vma_ : _lma_                                           \
86         {                                                               \
87                 _rodata_start = ABSOLUTE(.);                            \
88                 *(.rodata)                                              \
89                 *(.rodata.*)                                            \
90                 *(.dtb.init.rodata)                                     \
91                 *(.gnu.linkonce.r.*)                                    \
92                 *(.rodata1)                                             \
93                 __XT_EXCEPTION_TABLE__ = ABSOLUTE(.);                   \
94                 *(.xt_except_table)                                     \
95                 *(.gcc_except_table)                                    \
96                 *(.gnu.linkonce.e.*)                                    \
97                 *(.gnu.version_r)                                       \
98                 . = ALIGN(16);                                          \
99                  _rodata_end = ABSOLUTE(.);                             \
100         }
101
102 #define SECTION_u_boot_list(_vma_, _lma_)                               \
103         .u_boot_list _vma_ : _lma_                                      \
104         {                                                               \
105                 _u_boot_list_start = ABSOLUTE(.);                       \
106                 KEEP(*(SORT(.u_boot_list*)));                           \
107                 _u_boot_list_end = ABSOLUTE(.);                         \
108         }
109
110 #define SECTION_data(_vma_, _lma_)                                      \
111         .data _vma_ : _lma_                                             \
112         {                                                               \
113                 _data_start = ABSOLUTE(.);                              \
114                 *(.data)                                                \
115                 *(.data.*)                                              \
116                 *(.gnu.linkonce.d.*)                                    \
117                 *(.data1)                                               \
118                 *(.sdata)                                               \
119                 *(.sdata.*)                                             \
120                 *(.gnu.linkonce.s.*)                                    \
121                 *(.sdata2)                                              \
122                 *(.sdata2.*)                                            \
123                 *(.gnu.linkonce.s2.*)                                   \
124                 *(.jcr)                                                 \
125                 *(.eh_frame)                                            \
126                 *(.dynamic)                                             \
127                 *(.gnu.version_d)                                       \
128                 _data_end = ABSOLUTE(.);                                \
129         }
130
131 #define SECTION_lit4(_vma_, _lma_)                                      \
132         .lit4 _vma_ : _lma_                                             \
133         {                                                               \
134                 _lit4_start = ABSOLUTE(.);                              \
135                 *(*.lit4)                                               \
136                 *(.gnu.linkonce.lit4.*)                                 \
137                 _lit4_end = ABSOLUTE(.);                                \
138         }
139
140 #define SECTION_bss(_vma_, _lma_)                                       \
141         .bss _vma_ : _lma_                                              \
142         {                                                               \
143                 . = ALIGN(8);                                           \
144                 _bss_start = ABSOLUTE(.);                               \
145                 __bss_start = ABSOLUTE(.);                              \
146                 *(.dynsbss)                                             \
147                 *(.sbss)                                                \
148                 *(.sbss.*)                                              \
149                 *(.gnu.linkonce.sb.*)                                   \
150                 *(.scommon)                                             \
151                 *(.sbss2)                                               \
152                 *(.sbss2.*)                                             \
153                 *(.gnu.linkonce.sb2.*)                                  \
154                 *(.dynbss)                                              \
155                 *(.bss)                                                 \
156                 *(.bss.*)                                               \
157                 *(.gnu.linkonce.b.*)                                    \
158                 *(COMMON)                                               \
159                 *(.sram.bss)                                            \
160                 . = ALIGN(8);                                           \
161                 _bss_end = ABSOLUTE(.);                                 \
162                 __bss_end = ABSOLUTE(.);                                \
163                 _end = ALIGN(0x8);                                      \
164                 PROVIDE(end = ALIGN(0x8));                              \
165                 _stack_sentry = ALIGN(0x8);                             \
166         }
167
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) }
186
187 #define SECTION_xtensa                                                  \
188         .xt.insn 0 :                                                    \
189         {                                                               \
190                 KEEP (*(.xt.insn))                                      \
191                 KEEP (*(.gnu.linkonce.x.*))                             \
192         }                                                               \
193         .xt.prop 0 :                                                    \
194         {                                                               \
195                 KEEP (*(.xt.prop))                                      \
196                 KEEP (*(.xt.prop.*))                                    \
197                 KEEP (*(.gnu.linkonce.prop.*))                          \
198         }                                                               \
199         .xt.lit 0 :                                                     \
200         {                                                               \
201                 KEEP (*(.xt.lit))                                       \
202                 KEEP (*(.xt.lit.*))                                     \
203                 KEEP (*(.gnu.linkonce.p.*))                             \
204         }                                                               \
205         .xt.profile_range 0 :                                           \
206         {                                                               \
207                 KEEP (*(.xt.profile_range))                             \
208                 KEEP (*(.gnu.linkonce.profile_range.*))                 \
209         }                                                               \
210         .xt.profile_ranges 0 :                                          \
211         {                                                               \
212                 KEEP (*(.xt.profile_ranges))                            \
213                 KEEP (*(.gnu.linkonce.xt.profile_ranges.*))             \
214         }                                                               \
215         .xt.profile_files 0 :                                           \
216         {                                                               \
217                 KEEP (*(.xt.profile_files))                             \
218                 KEEP (*(.gnu.linkonce.xt.profile_files.*))              \
219         }
220
221 #endif  /* _XTENSA_LDSCRIPT_H */