Update my e-mail address.
[binutils-gdb.git] / include / elf / nds32.h
blob8d6ffab77c7c1877a35d87ff4e7df230f5bcaac1
1 /* NDS32 ELF support for BFD.
2 Copyright (C) 2012-2017 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 /* Relocations. */
28 START_RELOC_NUMBERS (elf_nds32_reloc_type)
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)
50 /* RELA relocations. */
51 RELOC_NUMBER (R_NDS32_16_RELA, 19)
52 RELOC_NUMBER (R_NDS32_32_RELA, 20)
53 RELOC_NUMBER (R_NDS32_20_RELA, 21)
54 RELOC_NUMBER (R_NDS32_9_PCREL_RELA, 22)
55 RELOC_NUMBER (R_NDS32_15_PCREL_RELA, 23)
56 RELOC_NUMBER (R_NDS32_17_PCREL_RELA, 24)
57 RELOC_NUMBER (R_NDS32_25_PCREL_RELA, 25)
58 RELOC_NUMBER (R_NDS32_HI20_RELA, 26)
59 RELOC_NUMBER (R_NDS32_LO12S3_RELA, 27)
60 RELOC_NUMBER (R_NDS32_LO12S2_RELA, 28)
61 RELOC_NUMBER (R_NDS32_LO12S1_RELA, 29)
62 RELOC_NUMBER (R_NDS32_LO12S0_RELA, 30)
63 RELOC_NUMBER (R_NDS32_SDA15S3_RELA, 31)
64 RELOC_NUMBER (R_NDS32_SDA15S2_RELA, 32)
65 RELOC_NUMBER (R_NDS32_SDA15S1_RELA, 33)
66 RELOC_NUMBER (R_NDS32_SDA15S0_RELA, 34)
67 RELOC_NUMBER (R_NDS32_RELA_GNU_VTINHERIT, 35)
68 RELOC_NUMBER (R_NDS32_RELA_GNU_VTENTRY, 36)
70 RELOC_NUMBER (R_NDS32_GOT20, 37)
71 RELOC_NUMBER (R_NDS32_25_PLTREL, 38)
72 RELOC_NUMBER (R_NDS32_COPY, 39)
73 RELOC_NUMBER (R_NDS32_GLOB_DAT, 40)
74 RELOC_NUMBER (R_NDS32_JMP_SLOT, 41)
75 RELOC_NUMBER (R_NDS32_RELATIVE, 42)
76 RELOC_NUMBER (R_NDS32_GOTOFF, 43)
77 RELOC_NUMBER (R_NDS32_GOTPC20, 44)
78 RELOC_NUMBER (R_NDS32_GOT_HI20, 45)
79 RELOC_NUMBER (R_NDS32_GOT_LO12, 46)
80 RELOC_NUMBER (R_NDS32_GOTPC_HI20, 47)
81 RELOC_NUMBER (R_NDS32_GOTPC_LO12, 48)
82 RELOC_NUMBER (R_NDS32_GOTOFF_HI20, 49)
83 RELOC_NUMBER (R_NDS32_GOTOFF_LO12, 50)
84 RELOC_NUMBER (R_NDS32_INSN16, 51)
85 RELOC_NUMBER (R_NDS32_LABEL, 52)
86 RELOC_NUMBER (R_NDS32_LONGCALL1, 53)
87 RELOC_NUMBER (R_NDS32_LONGCALL2, 54)
88 RELOC_NUMBER (R_NDS32_LONGCALL3, 55)
89 RELOC_NUMBER (R_NDS32_LONGJUMP1, 56)
90 RELOC_NUMBER (R_NDS32_LONGJUMP2, 57)
91 RELOC_NUMBER (R_NDS32_LONGJUMP3, 58)
92 RELOC_NUMBER (R_NDS32_LOADSTORE, 59)
93 RELOC_NUMBER (R_NDS32_9_FIXED_RELA, 60)
94 RELOC_NUMBER (R_NDS32_15_FIXED_RELA, 61)
95 RELOC_NUMBER (R_NDS32_17_FIXED_RELA, 62)
96 RELOC_NUMBER (R_NDS32_25_FIXED_RELA, 63)
97 RELOC_NUMBER (R_NDS32_PLTREL_HI20, 64) /* This is obsoleted. */
98 RELOC_NUMBER (R_NDS32_PLTREL_LO12, 65) /* This is obsoleted. */
99 RELOC_NUMBER (R_NDS32_PLT_GOTREL_HI20, 66)
100 RELOC_NUMBER (R_NDS32_PLT_GOTREL_LO12, 67)
101 RELOC_NUMBER (R_NDS32_SDA12S2_DP_RELA, 68)
102 RELOC_NUMBER (R_NDS32_SDA12S2_SP_RELA, 69)
103 RELOC_NUMBER (R_NDS32_LO12S2_DP_RELA, 70)
104 RELOC_NUMBER (R_NDS32_LO12S2_SP_RELA, 71)
105 RELOC_NUMBER (R_NDS32_LO12S0_ORI_RELA, 72)
106 RELOC_NUMBER (R_NDS32_SDA16S3_RELA, 73)
107 RELOC_NUMBER (R_NDS32_SDA17S2_RELA, 74)
108 RELOC_NUMBER (R_NDS32_SDA18S1_RELA, 75)
109 RELOC_NUMBER (R_NDS32_SDA19S0_RELA, 76)
110 RELOC_NUMBER (R_NDS32_DWARF2_OP1_RELA, 77)
111 RELOC_NUMBER (R_NDS32_DWARF2_OP2_RELA, 78)
112 RELOC_NUMBER (R_NDS32_DWARF2_LEB_RELA, 79)
113 RELOC_NUMBER (R_NDS32_UPDATE_TA_RELA, 80) /* This is obsoleted. */
114 RELOC_NUMBER (R_NDS32_9_PLTREL, 81)
115 RELOC_NUMBER (R_NDS32_PLT_GOTREL_LO20, 82)
116 RELOC_NUMBER (R_NDS32_PLT_GOTREL_LO15, 83)
117 RELOC_NUMBER (R_NDS32_PLT_GOTREL_LO19, 84)
118 RELOC_NUMBER (R_NDS32_GOT_LO15, 85)
119 RELOC_NUMBER (R_NDS32_GOT_LO19, 86)
120 RELOC_NUMBER (R_NDS32_GOTOFF_LO15, 87)
121 RELOC_NUMBER (R_NDS32_GOTOFF_LO19, 88)
122 RELOC_NUMBER (R_NDS32_GOT15S2_RELA, 89)
123 RELOC_NUMBER (R_NDS32_GOT17S2_RELA, 90)
124 RELOC_NUMBER (R_NDS32_5_RELA, 91)
125 RELOC_NUMBER (R_NDS32_10_UPCREL_RELA, 92) /* This is obsoleted. */
126 RELOC_NUMBER (R_NDS32_SDA_FP7U2_RELA, 93)
127 RELOC_NUMBER (R_NDS32_WORD_9_PCREL_RELA, 94)
128 RELOC_NUMBER (R_NDS32_25_ABS_RELA, 95)
129 RELOC_NUMBER (R_NDS32_17IFC_PCREL_RELA, 96)
130 RELOC_NUMBER (R_NDS32_10IFCU_PCREL_RELA, 97)
131 RELOC_NUMBER (R_NDS32_TLS_LE_HI20, 98)
132 RELOC_NUMBER (R_NDS32_TLS_LE_LO12, 99)
133 RELOC_NUMBER (R_NDS32_TLS_IE_HI20, 100)
134 RELOC_NUMBER (R_NDS32_TLS_IE_LO12S2, 101)
135 RELOC_NUMBER (R_NDS32_TLS_TPOFF, 102)
136 RELOC_NUMBER (R_NDS32_TLS_LE_20, 103)
137 RELOC_NUMBER (R_NDS32_TLS_LE_15S0, 104)
138 RELOC_NUMBER (R_NDS32_TLS_LE_15S1, 105)
139 RELOC_NUMBER (R_NDS32_TLS_LE_15S2, 106)
140 RELOC_NUMBER (R_NDS32_LONGCALL4, 107)
141 RELOC_NUMBER (R_NDS32_LONGCALL5, 108)
142 RELOC_NUMBER (R_NDS32_LONGCALL6, 109)
143 RELOC_NUMBER (R_NDS32_LONGJUMP4, 110)
144 RELOC_NUMBER (R_NDS32_LONGJUMP5, 111)
145 RELOC_NUMBER (R_NDS32_LONGJUMP6, 112)
146 RELOC_NUMBER (R_NDS32_LONGJUMP7, 113)
148 RELOC_NUMBER (R_NDS32_RELAX_ENTRY, 192)
149 RELOC_NUMBER (R_NDS32_GOT_SUFF, 193)
150 RELOC_NUMBER (R_NDS32_GOTOFF_SUFF, 194)
151 RELOC_NUMBER (R_NDS32_PLT_GOT_SUFF, 195)
152 RELOC_NUMBER (R_NDS32_MULCALL_SUFF, 196) /* This is obsoleted. */
153 RELOC_NUMBER (R_NDS32_PTR, 197)
154 RELOC_NUMBER (R_NDS32_PTR_COUNT, 198)
155 RELOC_NUMBER (R_NDS32_PTR_RESOLVED, 199)
156 RELOC_NUMBER (R_NDS32_PLTBLOCK, 200) /* This is obsoleted. */
157 RELOC_NUMBER (R_NDS32_RELAX_REGION_BEGIN, 201)
158 RELOC_NUMBER (R_NDS32_RELAX_REGION_END, 202)
159 RELOC_NUMBER (R_NDS32_MINUEND, 203)
160 RELOC_NUMBER (R_NDS32_SUBTRAHEND, 204)
161 RELOC_NUMBER (R_NDS32_DIFF8, 205)
162 RELOC_NUMBER (R_NDS32_DIFF16, 206)
163 RELOC_NUMBER (R_NDS32_DIFF32, 207)
164 RELOC_NUMBER (R_NDS32_DIFF_ULEB128, 208)
165 RELOC_NUMBER (R_NDS32_DATA, 209)
166 RELOC_NUMBER (R_NDS32_TRAN, 210)
167 RELOC_NUMBER (R_NDS32_TLS_LE_ADD, 211)
168 RELOC_NUMBER (R_NDS32_TLS_LE_LS, 212)
169 RELOC_NUMBER (R_NDS32_EMPTY, 213)
171 END_RELOC_NUMBERS (R_NDS32_max)
173 /* Processor specific section indices. These sections do not actually
174 exist. Symbols with a st_shndx field corresponding to one of these
175 values have a special meaning. */
177 /* Processor specific flags for the ELF header e_flags field.
179 31 28 27 8 7 4 3 0
180 ---------------------------------------------
181 | ARCH | CONFUGURAION FIELD | ABI | ELF_VER |
182 --------------------------------------------- */
184 /* Architechure definition. */
186 /* 4-bit (b31-b28) nds32 architecture field.
187 We can have up to 15 architectures; 0000 is for unknown. */
188 #define EF_NDS_ARCH 0xF0000000
189 #define EF_NDS_ARCH_SHIFT 28
190 /* There could be more architectures. For now, only n1 and n1h. */
191 #define E_NDS_ARCH_STAR_RESERVED 0x00000000
192 #define E_NDS_ARCH_STAR_V1_0 0x10000000
193 #define E_NDS_ARCH_STAR_V2_0 0x20000000
194 #define E_NDS_ARCH_STAR_V3_0 0x30000000
195 #define E_NDS_ARCH_STAR_V3_M 0x40000000
196 #define E_NDS_ARCH_STAR_V0_9 0x90000000 /* Obsoleted. */
197 /* n1 code. */
198 #define E_N1_ARCH E_NDS_ARCH_STAR_V0_9
199 /* n1h code. */
200 #define E_N1H_ARCH E_NDS_ARCH_STAR_V1_0
203 /* Configuration field definitioans. */
204 #define EF_NDS_INST 0x0FFFFF00
206 /* E_NDS_ARCH_STAR_V1_0 configuration fields.
208 E_NDS_ARCH_STAR_V2_0 configuration fields.
209 These are discarded in v2.
210 * E_NDS32_HAS_MFUSR_PC_INST 0x00000100
211 * E_NDS32_HAS_DIV_INST 0x00002000
212 * E_NDS32_HAS_NO_MAC_INST 0x00100000
213 These are added in v2.
214 * E_NDS32_HAS_DIV_DX_INST 0x00002000
215 * E_NDS32_HAS_MAC_DX_INST 0x00100000 */
217 /* MFUSR rt, PC and correct ISYNC, MSYNC instructions.
218 Old N1213HC has no such instructions. */
219 #define E_NDS32_HAS_MFUSR_PC_INST 0x00000100 /* Reclaimed. */
220 #define E_NDS32_HAS_EX9_INST 0x00000100 /* v3, ELF 1.4. */
221 /* C/C++ performance extension instructions. */
222 #define E_NDS32_HAS_EXT_INST 0x00000200
223 /* Performance extension set II instructions. */
224 #define E_NDS32_HAS_EXT2_INST 0x00000400
225 /* Single precision Floating point processor instructions. */
226 #define E_NDS32_HAS_FPU_INST 0x00000800
227 /* Audio instructions with 32-bit audio dx.lo register. */
228 #define E_NDS32_HAS_AUDIO_INST 0x00001000
229 /* DIV instructions. */
230 #define E_NDS32_HAS_DIV_INST 0x00002000 /* Reclaimed. */
231 /* DIV instructions using d0/d1. */
232 #define E_NDS32_HAS_DIV_DX_INST 0x00002000 /* v2. */
233 /* 16-bit instructions. */
234 #define E_NDS32_HAS_16BIT_INST 0x00004000 /* Reclaimed. */
235 #define E_NDS32_HAS_IFC_INST 0x00004000 /* v3, ELF 1.4. */
236 /* String operation instructions. */
237 #define E_NDS32_HAS_STRING_INST 0x00008000
238 /* Reduced register file. */
239 #define E_NDS32_HAS_REDUCED_REGS 0x00010000
240 /* Video instructions. */
241 #define E_NDS32_HAS_VIDEO_INST 0x00020000 /* Reclaimed. */
242 #define E_NDS32_HAS_SATURATION_INST 0x00020000 /* v3, ELF 1.4. */
243 /* Encription instructions. */
244 #define E_NDS32_HAS_ENCRIPT_INST 0x00040000
245 /* Doulbe Precision Floating point processor instructions. */
246 #define E_NDS32_HAS_FPU_DP_INST 0x00080000
247 /* No MAC instruction used. */
248 #define E_NDS32_HAS_NO_MAC_INST 0x00100000 /* Reclaimed when V2/V3. */
249 /* MAC instruction using d0/d1. */
250 #define E_NDS32_HAS_MAC_DX_INST 0x00100000 /* v2. */
251 /* L2 cache instruction. */
252 #define E_NDS32_HAS_L2C_INST 0x00200000
253 /* FPU registers configuration when FPU SP/DP presents; 0x00c00000. */
254 #define E_NDS32_FPU_REG_CONF_SHIFT 22
255 #define E_NDS32_FPU_REG_CONF (0x3 << E_NDS32_FPU_REG_CONF_SHIFT)
256 #define E_NDS32_FPU_REG_8SP_4DP 0x0
257 #define E_NDS32_FPU_REG_16SP_8DP 0x1
258 #define E_NDS32_FPU_REG_32SP_16DP 0x2
259 #define E_NDS32_FPU_REG_32SP_32DP 0x3
260 /* FPU MAC instruction used. */
261 #define E_NDS32_HAS_FPU_MAC_INST 0x01000000
262 /* <<<Empty Check>>>. */
263 #define E_NDS32_NULL 0x02000000
264 /* PIC enabled. */
265 #define E_NDS32_HAS_PIC 0x04000000
266 /* Use custom section. */
267 #define E_NDS32_HAS_CUSTOM_SEC 0x08000000
269 /* 4-bit for ABI signature, allow up to 16 ABIs
270 0: for OLD ABI V0, phase out
271 1: for V1 , starting with V0 toolchain
272 2: for V2
273 3: for V2FP (fs0, fs1 as function parameter)
274 4: for AABI */
275 /* Only old N1213HC use V0.
276 New ABI is used due to return register is changed to r0 from r5. */
277 #define EF_NDS_ABI 0x000000F0
278 #define EF_NDS_ABI_SHIFT 4
279 #define E_NDS_ABI_V0 0x00000000
280 #define E_NDS_ABI_V1 0x00000010
281 #define E_NDS_ABI_V2 0x00000020
282 #define E_NDS_ABI_V2FP 0x00000030
283 #define E_NDS_ABI_AABI 0x00000040
284 #define E_NDS_ABI_V2FP_PLUS 0x00000050
286 /* This flag signifies the version of Andes ELF.
287 Some more information may exist somewhere which is TBD. */
288 #define EF_NDS32_ELF_VERSION 0x0000000F
289 #define EF_NDS32_ELF_VERSION_SHIFT 0
291 /* Andes ELF Version 1.3 and before. */
292 #define E_NDS32_ELF_VER_1_2 0x0
293 /* Andes ELF Version 1.31. */
294 #define E_NDS32_ELF_VER_1_3 0x1
295 /* Andes ELF Version 1.4. Change the way we fix .debug_* and .gcc_except_table.
296 Change three bit for EX9, IFC and SAT. */
297 #define E_NDS32_ELF_VER_1_4 0x2
299 #endif