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