Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / support / sdbinutils / include / elf / nds32.h
blob58d7e000bc6616f0331da177661eece81fad71a5
1 /* NDS32 ELF support for BFD.
2 Copyright (C) 2012-2022 Free Software Foundation, Inc.
3 Contributed by Andes Technology Corporation.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
20 02110-1301, USA. */
22 #ifndef _ELF_NDS32_H
23 #define _ELF_NDS32_H
25 #include "elf/reloc-macros.h"
27 START_RELOC_NUMBERS (elf_nds32_reloc_type)
28 /* These used for relocations. */
29 RELOC_NUMBER (R_NDS32_NONE, 0)
30 /* REL relocations. */
31 RELOC_NUMBER (R_NDS32_16, 1)
32 RELOC_NUMBER (R_NDS32_32, 2)
33 RELOC_NUMBER (R_NDS32_20, 3)
34 RELOC_NUMBER (R_NDS32_9_PCREL, 4)
35 RELOC_NUMBER (R_NDS32_15_PCREL, 5)
36 RELOC_NUMBER (R_NDS32_17_PCREL, 6)
37 RELOC_NUMBER (R_NDS32_25_PCREL, 7)
38 RELOC_NUMBER (R_NDS32_HI20, 8)
39 RELOC_NUMBER (R_NDS32_LO12S3, 9)
40 RELOC_NUMBER (R_NDS32_LO12S2, 10)
41 RELOC_NUMBER (R_NDS32_LO12S1, 11)
42 RELOC_NUMBER (R_NDS32_LO12S0, 12)
43 RELOC_NUMBER (R_NDS32_SDA15S3, 13)
44 RELOC_NUMBER (R_NDS32_SDA15S2, 14)
45 RELOC_NUMBER (R_NDS32_SDA15S1, 15)
46 RELOC_NUMBER (R_NDS32_SDA15S0, 16)
47 RELOC_NUMBER (R_NDS32_GNU_VTINHERIT, 17)
48 RELOC_NUMBER (R_NDS32_GNU_VTENTRY, 18)
49 /* RELA relocations. */
50 RELOC_NUMBER (R_NDS32_16_RELA, 19)
51 RELOC_NUMBER (R_NDS32_32_RELA, 20)
52 RELOC_NUMBER (R_NDS32_20_RELA, 21)
53 RELOC_NUMBER (R_NDS32_9_PCREL_RELA, 22)
54 RELOC_NUMBER (R_NDS32_15_PCREL_RELA, 23)
55 RELOC_NUMBER (R_NDS32_17_PCREL_RELA, 24)
56 RELOC_NUMBER (R_NDS32_25_PCREL_RELA, 25)
57 RELOC_NUMBER (R_NDS32_HI20_RELA, 26)
58 RELOC_NUMBER (R_NDS32_LO12S3_RELA, 27)
59 RELOC_NUMBER (R_NDS32_LO12S2_RELA, 28)
60 RELOC_NUMBER (R_NDS32_LO12S1_RELA, 29)
61 RELOC_NUMBER (R_NDS32_LO12S0_RELA, 30)
62 RELOC_NUMBER (R_NDS32_SDA15S3_RELA, 31)
63 RELOC_NUMBER (R_NDS32_SDA15S2_RELA, 32)
64 RELOC_NUMBER (R_NDS32_SDA15S1_RELA, 33)
65 RELOC_NUMBER (R_NDS32_SDA15S0_RELA, 34)
66 RELOC_NUMBER (R_NDS32_RELA_GNU_VTINHERIT, 35)
67 RELOC_NUMBER (R_NDS32_RELA_GNU_VTENTRY, 36)
68 /* GOT and PLT. */
69 RELOC_NUMBER (R_NDS32_GOT20, 37)
70 RELOC_NUMBER (R_NDS32_25_PLTREL, 38)
71 RELOC_NUMBER (R_NDS32_COPY, 39)
72 RELOC_NUMBER (R_NDS32_GLOB_DAT, 40)
73 RELOC_NUMBER (R_NDS32_JMP_SLOT, 41)
74 RELOC_NUMBER (R_NDS32_RELATIVE, 42)
75 RELOC_NUMBER (R_NDS32_GOTOFF, 43)
76 RELOC_NUMBER (R_NDS32_GOTPC20, 44)
77 RELOC_NUMBER (R_NDS32_GOT_HI20, 45)
78 RELOC_NUMBER (R_NDS32_GOT_LO12, 46)
79 RELOC_NUMBER (R_NDS32_GOTPC_HI20, 47)
80 RELOC_NUMBER (R_NDS32_GOTPC_LO12, 48)
81 RELOC_NUMBER (R_NDS32_GOTOFF_HI20, 49)
82 RELOC_NUMBER (R_NDS32_GOTOFF_LO12, 50)
83 /* 32_to_16 relaxations. */
84 RELOC_NUMBER (R_NDS32_INSN16, 51)
85 /* Alignment tag. */
86 RELOC_NUMBER (R_NDS32_LABEL, 52)
87 RELOC_NUMBER (R_NDS32_LONGCALL1, 53) /* This is obsoleted. */
88 RELOC_NUMBER (R_NDS32_LONGCALL2, 54) /* This is obsoleted. */
89 RELOC_NUMBER (R_NDS32_LONGCALL3, 55) /* This is obsoleted. */
90 RELOC_NUMBER (R_NDS32_LONGJUMP1, 56) /* This is obsoleted. */
91 RELOC_NUMBER (R_NDS32_LONGJUMP2, 57) /* This is obsoleted. */
92 RELOC_NUMBER (R_NDS32_LONGJUMP3, 58) /* This is obsoleted. */
93 RELOC_NUMBER (R_NDS32_LOADSTORE, 59) /* This is obsoleted. */
94 RELOC_NUMBER (R_NDS32_9_FIXED_RELA, 60)
95 RELOC_NUMBER (R_NDS32_15_FIXED_RELA, 61)
96 RELOC_NUMBER (R_NDS32_17_FIXED_RELA, 62)
97 RELOC_NUMBER (R_NDS32_25_FIXED_RELA, 63)
98 RELOC_NUMBER (R_NDS32_PLTREL_HI20, 64) /* This is obsoleted. */
99 RELOC_NUMBER (R_NDS32_PLTREL_LO12, 65) /* This is obsoleted. */
100 RELOC_NUMBER (R_NDS32_PLT_GOTREL_HI20, 66)
101 RELOC_NUMBER (R_NDS32_PLT_GOTREL_LO12, 67)
102 RELOC_NUMBER (R_NDS32_SDA12S2_DP_RELA, 68)
103 RELOC_NUMBER (R_NDS32_SDA12S2_SP_RELA, 69)
104 RELOC_NUMBER (R_NDS32_LO12S2_DP_RELA, 70)
105 RELOC_NUMBER (R_NDS32_LO12S2_SP_RELA, 71)
106 RELOC_NUMBER (R_NDS32_LO12S0_ORI_RELA, 72)
107 RELOC_NUMBER (R_NDS32_SDA16S3_RELA, 73)
108 RELOC_NUMBER (R_NDS32_SDA17S2_RELA, 74)
109 RELOC_NUMBER (R_NDS32_SDA18S1_RELA, 75)
110 RELOC_NUMBER (R_NDS32_SDA19S0_RELA, 76)
111 RELOC_NUMBER (R_NDS32_DWARF2_OP1_RELA, 77) /* This is obsoleted. */
112 RELOC_NUMBER (R_NDS32_DWARF2_OP2_RELA, 78) /* This is obsoleted. */
113 RELOC_NUMBER (R_NDS32_DWARF2_LEB_RELA, 79) /* This is obsoleted. */
114 RELOC_NUMBER (R_NDS32_UPDATE_TA_RELA, 80) /* This is obsoleted. */
115 RELOC_NUMBER (R_NDS32_9_PLTREL, 81)
116 RELOC_NUMBER (R_NDS32_PLT_GOTREL_LO20, 82)
117 RELOC_NUMBER (R_NDS32_PLT_GOTREL_LO15, 83)
118 RELOC_NUMBER (R_NDS32_PLT_GOTREL_LO19, 84)
119 RELOC_NUMBER (R_NDS32_GOT_LO15, 85)
120 RELOC_NUMBER (R_NDS32_GOT_LO19, 86)
121 RELOC_NUMBER (R_NDS32_GOTOFF_LO15, 87)
122 RELOC_NUMBER (R_NDS32_GOTOFF_LO19, 88)
123 RELOC_NUMBER (R_NDS32_GOT15S2_RELA, 89)
124 RELOC_NUMBER (R_NDS32_GOT17S2_RELA, 90)
125 RELOC_NUMBER (R_NDS32_5_RELA, 91)
126 RELOC_NUMBER (R_NDS32_10_UPCREL_RELA, 92) /* This is obsoleted. */
127 RELOC_NUMBER (R_NDS32_SDA_FP7U2_RELA, 93)
128 RELOC_NUMBER (R_NDS32_WORD_9_PCREL_RELA, 94)
129 RELOC_NUMBER (R_NDS32_25_ABS_RELA, 95)
130 RELOC_NUMBER (R_NDS32_17IFC_PCREL_RELA, 96) /* This is obsoleted. */
131 RELOC_NUMBER (R_NDS32_10IFCU_PCREL_RELA, 97) /* This is obsoleted. */
132 /* TLS support. */
133 RELOC_NUMBER (R_NDS32_TLS_LE_HI20, 98)
134 RELOC_NUMBER (R_NDS32_TLS_LE_LO12, 99)
135 RELOC_NUMBER (R_NDS32_TLS_IE_HI20, 100)
136 RELOC_NUMBER (R_NDS32_TLS_IE_LO12S2, 101)
137 RELOC_NUMBER (R_NDS32_TLS_TPOFF, 102)
138 RELOC_NUMBER (R_NDS32_TLS_LE_20, 103)
139 RELOC_NUMBER (R_NDS32_TLS_LE_15S0, 104)
140 RELOC_NUMBER (R_NDS32_TLS_LE_15S1, 105)
141 RELOC_NUMBER (R_NDS32_TLS_LE_15S2, 106)
142 RELOC_NUMBER (R_NDS32_LONGCALL4, 107)
143 RELOC_NUMBER (R_NDS32_LONGCALL5, 108)
144 RELOC_NUMBER (R_NDS32_LONGCALL6, 109)
145 RELOC_NUMBER (R_NDS32_LONGJUMP4, 110)
146 RELOC_NUMBER (R_NDS32_LONGJUMP5, 111)
147 RELOC_NUMBER (R_NDS32_LONGJUMP6, 112)
148 RELOC_NUMBER (R_NDS32_LONGJUMP7, 113)
149 /* Reserved numbers: 114. */
150 /* TLS support */
151 RELOC_NUMBER (R_NDS32_TLS_IE_LO12, 115)
152 RELOC_NUMBER (R_NDS32_TLS_IEGP_HI20, 116)
153 RELOC_NUMBER (R_NDS32_TLS_IEGP_LO12, 117)
154 RELOC_NUMBER (R_NDS32_TLS_IEGP_LO12S2, 118)
155 RELOC_NUMBER (R_NDS32_TLS_DESC, 119)
156 RELOC_NUMBER (R_NDS32_TLS_DESC_HI20, 120)
157 RELOC_NUMBER (R_NDS32_TLS_DESC_LO12, 121)
158 RELOC_NUMBER (R_NDS32_TLS_DESC_20, 122)
159 RELOC_NUMBER (R_NDS32_TLS_DESC_SDA17S2, 123)
160 /* Reserved numbers: 124-191. */
162 /* These used only for relaxations */
163 RELOC_NUMBER (R_NDS32_RELAX_ENTRY, 192)
164 RELOC_NUMBER (R_NDS32_GOT_SUFF, 193)
165 RELOC_NUMBER (R_NDS32_GOTOFF_SUFF, 194)
166 RELOC_NUMBER (R_NDS32_PLT_GOT_SUFF, 195)
167 RELOC_NUMBER (R_NDS32_MULCALL_SUFF, 196) /* This is obsoleted. */
168 RELOC_NUMBER (R_NDS32_PTR, 197)
169 RELOC_NUMBER (R_NDS32_PTR_COUNT, 198)
170 RELOC_NUMBER (R_NDS32_PTR_RESOLVED, 199)
171 RELOC_NUMBER (R_NDS32_PLTBLOCK, 200) /* This is obsoleted. */
172 RELOC_NUMBER (R_NDS32_RELAX_REGION_BEGIN, 201)
173 RELOC_NUMBER (R_NDS32_RELAX_REGION_END, 202)
174 RELOC_NUMBER (R_NDS32_MINUEND, 203)
175 RELOC_NUMBER (R_NDS32_SUBTRAHEND, 204)
176 RELOC_NUMBER (R_NDS32_DIFF8, 205)
177 RELOC_NUMBER (R_NDS32_DIFF16, 206)
178 RELOC_NUMBER (R_NDS32_DIFF32, 207)
179 RELOC_NUMBER (R_NDS32_DIFF_ULEB128, 208)
180 RELOC_NUMBER (R_NDS32_DATA, 209)
181 RELOC_NUMBER (R_NDS32_TRAN, 210)
182 /* TLS support */
183 RELOC_NUMBER (R_NDS32_TLS_LE_ADD, 211)
184 RELOC_NUMBER (R_NDS32_TLS_LE_LS, 212)
185 RELOC_NUMBER (R_NDS32_EMPTY, 213)
186 RELOC_NUMBER (R_NDS32_TLS_DESC_ADD, 214)
187 RELOC_NUMBER (R_NDS32_TLS_DESC_FUNC, 215)
188 RELOC_NUMBER (R_NDS32_TLS_DESC_CALL, 216)
189 RELOC_NUMBER (R_NDS32_TLS_DESC_MEM, 217)
190 RELOC_NUMBER (R_NDS32_RELAX_REMOVE, 218)
191 RELOC_NUMBER (R_NDS32_RELAX_GROUP, 219)
192 RELOC_NUMBER (R_NDS32_TLS_IEGP_LW, 220)
193 RELOC_NUMBER (R_NDS32_LSI, 221)
194 /* Reserved numbers: 222-255. */
196 END_RELOC_NUMBERS (R_NDS32_max)
198 /* Processor specific section indices. These sections do not actually
199 exist. Symbols with a st_shndx field corresponding to one of these
200 values have a special meaning. */
202 /* Processor specific flags for the ELF header e_flags field.
204 31 28 27 8 7 4 3 0
205 ---------------------------------------------
206 | ARCH | CONFUGURAION FIELD | ABI | ELF_VER |
207 --------------------------------------------- */
209 /* Architechure definition. */
211 /* 4-bit (b31-b28) nds32 architecture field.
212 We can have up to 15 architectures; 0000 is for unknown. */
213 #define EF_NDS_ARCH 0xF0000000
214 #define EF_NDS_ARCH_SHIFT 28
215 /* There could be more architectures. For now, only n1 and n1h. */
216 #define E_NDS_ARCH_STAR_RESERVED 0x00000000
217 #define E_NDS_ARCH_STAR_V1_0 0x10000000
218 #define E_NDS_ARCH_STAR_V2_0 0x20000000
219 #define E_NDS_ARCH_STAR_V3_0 0x30000000
220 #define E_NDS_ARCH_STAR_V3_M 0x40000000
221 #define E_NDS_ARCH_STAR_V0_9 0x90000000 /* Obsoleted. */
222 /* n1 code. */
223 #define E_N1_ARCH E_NDS_ARCH_STAR_V0_9
224 /* n1h code. */
225 #define E_N1H_ARCH E_NDS_ARCH_STAR_V1_0
228 /* Configuration field definitioans. */
229 #define EF_NDS_INST 0x0FFFFF00
231 /* E_NDS_ARCH_STAR_V1_0 configuration fields.
233 E_NDS_ARCH_STAR_V2_0 configuration fields.
234 These are discarded in v2.
235 * E_NDS32_HAS_MFUSR_PC_INST 0x00000100
236 * E_NDS32_HAS_DIV_INST 0x00002000
237 * E_NDS32_HAS_NO_MAC_INST 0x00100000
238 These are added in v2.
239 * E_NDS32_HAS_DIV_DX_INST 0x00002000
240 * E_NDS32_HAS_MAC_DX_INST 0x00100000 */
242 /* MFUSR rt, PC and correct ISYNC, MSYNC instructions.
243 Old N1213HC has no such instructions. */
244 #define E_NDS32_HAS_MFUSR_PC_INST 0x00000100 /* Reclaimed. */
245 /* C/C++ performance extension instructions. */
246 #define E_NDS32_HAS_EXT_INST 0x00000200
247 /* Performance extension set II instructions. */
248 #define E_NDS32_HAS_EXT2_INST 0x00000400
249 /* Single precision Floating point processor instructions. */
250 #define E_NDS32_HAS_FPU_INST 0x00000800
251 /* Audio instructions with 32-bit audio dx.lo register. */
252 #define E_NDS32_HAS_AUDIO_INST 0x00001000
253 /* DIV instructions. */
254 #define E_NDS32_HAS_DIV_INST 0x00002000 /* Reclaimed. */
255 /* DIV instructions using d0/d1. */
256 #define E_NDS32_HAS_DIV_DX_INST 0x00002000 /* v2. */
257 /* 16-bit instructions. */
258 #define E_NDS32_HAS_16BIT_INST 0x00004000 /* Reclaimed. */
259 /* String operation instructions. */
260 #define E_NDS32_HAS_STRING_INST 0x00008000
261 /* Reduced register file. */
262 #define E_NDS32_HAS_REDUCED_REGS 0x00010000
263 /* Video instructions. */
264 #define E_NDS32_HAS_VIDEO_INST 0x00020000 /* Reclaimed. */
265 #define E_NDS32_HAS_SATURATION_INST 0x00020000 /* v3, ELF 1.4. */
266 /* Encription instructions. */
267 #define E_NDS32_HAS_ENCRIPT_INST 0x00040000
268 /* Doulbe Precision Floating point processor instructions. */
269 #define E_NDS32_HAS_FPU_DP_INST 0x00080000
270 /* No MAC instruction used. */
271 #define E_NDS32_HAS_NO_MAC_INST 0x00100000 /* Reclaimed when V2/V3. */
272 /* MAC instruction using d0/d1. */
273 #define E_NDS32_HAS_MAC_DX_INST 0x00100000 /* v2. */
274 /* L2 cache instruction. */
275 #define E_NDS32_HAS_L2C_INST 0x00200000
276 /* FPU registers configuration when FPU SP/DP presents; 0x00c00000. */
277 #define E_NDS32_FPU_REG_CONF_SHIFT 22
278 #define E_NDS32_FPU_REG_CONF (0x3 << E_NDS32_FPU_REG_CONF_SHIFT)
279 #define E_NDS32_FPU_REG_8SP_4DP 0x0
280 #define E_NDS32_FPU_REG_16SP_8DP 0x1
281 #define E_NDS32_FPU_REG_32SP_16DP 0x2
282 #define E_NDS32_FPU_REG_32SP_32DP 0x3
283 /* FPU MAC instruction used. */
284 #define E_NDS32_HAS_FPU_MAC_INST 0x01000000
285 /* DSP extension. */
286 #define E_NDS32_HAS_DSP_INST 0x02000000
287 /* PIC enabled. */
288 #define E_NDS32_HAS_PIC 0x04000000
289 /* Use custom section. */
290 #define E_NDS32_HAS_CUSTOM_SEC 0x08000000
291 /* Hardware zero-overhead loop enabled. */
292 #define E_NDS32_HAS_ZOL (1 << 26)
294 /* 4-bit for ABI signature, allow up to 16 ABIs
295 0: for OLD ABI V0, phase out
296 1: for V1 , starting with V0 toolchain
297 2: for V2
298 3: for V2FP (fs0, fs1 as function parameter)
299 4: for AABI */
300 /* Only old N1213HC use V0.
301 New ABI is used due to return register is changed to r0 from r5. */
302 #define EF_NDS_ABI 0x000000F0
303 #define EF_NDS_ABI_SHIFT 4
304 #define E_NDS_ABI_V0 0x00000000
305 #define E_NDS_ABI_V1 0x00000010
306 #define E_NDS_ABI_V2 0x00000020
307 #define E_NDS_ABI_V2FP 0x00000030
308 #define E_NDS_ABI_AABI 0x00000040
309 #define E_NDS_ABI_V2FP_PLUS 0x00000050
311 /* This flag signifies the version of Andes ELF.
312 Some more information may exist somewhere which is TBD. */
313 #define EF_NDS32_ELF_VERSION 0x0000000F
314 #define EF_NDS32_ELF_VERSION_SHIFT 0
316 /* Andes ELF Version 1.3 and before. */
317 #define E_NDS32_ELF_VER_1_2 0x0
318 /* Andes ELF Version 1.31. */
319 #define E_NDS32_ELF_VER_1_3 0x1
320 /* Andes ELF Version 1.4. Change the way we fix .debug_* and .gcc_except_table.
321 Change three bit for SAT. */
322 #define E_NDS32_ELF_VER_1_4 0x2
324 #endif