1*a9fa9459Szrj // mips.h -- ELF definitions specific to EM_MIPS -*- C++ -*-
2*a9fa9459Szrj
3*a9fa9459Szrj // Copyright (C) 2012-2016 Free Software Foundation, Inc.
4*a9fa9459Szrj // Written by Sasa Stankovic <sasa.stankovic@imgtec.com>
5*a9fa9459Szrj // and Aleksandar Simeonov <aleksandar.simeonov@rt-rk.com>.
6*a9fa9459Szrj
7*a9fa9459Szrj // This file is part of elfcpp.
8*a9fa9459Szrj
9*a9fa9459Szrj // This program is free software; you can redistribute it and/or
10*a9fa9459Szrj // modify it under the terms of the GNU Library General Public License
11*a9fa9459Szrj // as published by the Free Software Foundation; either version 2, or
12*a9fa9459Szrj // (at your option) any later version.
13*a9fa9459Szrj
14*a9fa9459Szrj // In addition to the permissions in the GNU Library General Public
15*a9fa9459Szrj // License, the Free Software Foundation gives you unlimited
16*a9fa9459Szrj // permission to link the compiled version of this file into
17*a9fa9459Szrj // combinations with other programs, and to distribute those
18*a9fa9459Szrj // combinations without any restriction coming from the use of this
19*a9fa9459Szrj // file. (The Library Public License restrictions do apply in other
20*a9fa9459Szrj // respects; for example, they cover modification of the file, and
21*a9fa9459Szrj /// distribution when not linked into a combined executable.)
22*a9fa9459Szrj
23*a9fa9459Szrj // This program is distributed in the hope that it will be useful, but
24*a9fa9459Szrj // WITHOUT ANY WARRANTY; without even the implied warranty of
25*a9fa9459Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26*a9fa9459Szrj // Library General Public License for more details.
27*a9fa9459Szrj
28*a9fa9459Szrj // You should have received a copy of the GNU Library General Public
29*a9fa9459Szrj // License along with this program; if not, write to the Free Software
30*a9fa9459Szrj // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
31*a9fa9459Szrj // 02110-1301, USA.
32*a9fa9459Szrj
33*a9fa9459Szrj #ifndef ELFCPP_MIPS_H
34*a9fa9459Szrj #define ELFCPP_MIPS_H
35*a9fa9459Szrj
36*a9fa9459Szrj // Documentation for the MIPS relocs is taken from
37*a9fa9459Szrj // http://math-atlas.sourceforge.net/devel/assembly/mipsabi32.pdf
38*a9fa9459Szrj
39*a9fa9459Szrj namespace elfcpp
40*a9fa9459Szrj {
41*a9fa9459Szrj
42*a9fa9459Szrj //
43*a9fa9459Szrj // MIPS Relocation Codes
44*a9fa9459Szrj //
45*a9fa9459Szrj
46*a9fa9459Szrj enum
47*a9fa9459Szrj {
48*a9fa9459Szrj R_MIPS_NONE = 0,
49*a9fa9459Szrj R_MIPS_16 = 1,
50*a9fa9459Szrj R_MIPS_32 = 2, // In Elf 64: alias R_MIPS_ADD
51*a9fa9459Szrj R_MIPS_REL32 = 3, // In Elf 64: alias R_MIPS_REL
52*a9fa9459Szrj R_MIPS_26 = 4,
53*a9fa9459Szrj R_MIPS_HI16 = 5,
54*a9fa9459Szrj R_MIPS_LO16 = 6,
55*a9fa9459Szrj R_MIPS_GPREL16 = 7, // In Elf 64: alias R_MIPS_GPREL
56*a9fa9459Szrj R_MIPS_LITERAL = 8,
57*a9fa9459Szrj R_MIPS_GOT16 = 9, // In Elf 64: alias R_MIPS_GOT
58*a9fa9459Szrj R_MIPS_PC16 = 10,
59*a9fa9459Szrj R_MIPS_CALL16 = 11, // In Elf 64: alias R_MIPS_CALL
60*a9fa9459Szrj R_MIPS_GPREL32 = 12,
61*a9fa9459Szrj R_MIPS_UNUSED1 = 13,
62*a9fa9459Szrj R_MIPS_UNUSED2 = 14,
63*a9fa9459Szrj R_MIPS_UNUSED3 = 15,
64*a9fa9459Szrj R_MIPS_SHIFT5 = 16,
65*a9fa9459Szrj R_MIPS_SHIFT6 = 17,
66*a9fa9459Szrj R_MIPS_64 = 18,
67*a9fa9459Szrj R_MIPS_GOT_DISP = 19,
68*a9fa9459Szrj R_MIPS_GOT_PAGE = 20,
69*a9fa9459Szrj R_MIPS_GOT_OFST = 21,
70*a9fa9459Szrj R_MIPS_GOT_HI16 = 22,
71*a9fa9459Szrj R_MIPS_GOT_LO16 = 23,
72*a9fa9459Szrj R_MIPS_SUB = 24,
73*a9fa9459Szrj R_MIPS_INSERT_A = 25,
74*a9fa9459Szrj R_MIPS_INSERT_B = 26,
75*a9fa9459Szrj R_MIPS_DELETE = 27,
76*a9fa9459Szrj R_MIPS_HIGHER = 28,
77*a9fa9459Szrj R_MIPS_HIGHEST = 29,
78*a9fa9459Szrj R_MIPS_CALL_HI16 = 30,
79*a9fa9459Szrj R_MIPS_CALL_LO16 = 31,
80*a9fa9459Szrj R_MIPS_SCN_DISP = 32,
81*a9fa9459Szrj R_MIPS_REL16 = 33,
82*a9fa9459Szrj R_MIPS_ADD_IMMEDIATE = 34,
83*a9fa9459Szrj R_MIPS_PJUMP = 35,
84*a9fa9459Szrj R_MIPS_RELGOT = 36,
85*a9fa9459Szrj R_MIPS_JALR = 37,
86*a9fa9459Szrj // TLS relocations.
87*a9fa9459Szrj R_MIPS_TLS_DTPMOD32 = 38,
88*a9fa9459Szrj R_MIPS_TLS_DTPREL32 = 39,
89*a9fa9459Szrj R_MIPS_TLS_DTPMOD64 = 40,
90*a9fa9459Szrj R_MIPS_TLS_DTPREL64 = 41,
91*a9fa9459Szrj R_MIPS_TLS_GD = 42,
92*a9fa9459Szrj R_MIPS_TLS_LDM = 43,
93*a9fa9459Szrj R_MIPS_TLS_DTPREL_HI16 = 44,
94*a9fa9459Szrj R_MIPS_TLS_DTPREL_LO16 = 45,
95*a9fa9459Szrj R_MIPS_TLS_GOTTPREL = 46,
96*a9fa9459Szrj R_MIPS_TLS_TPREL32 = 47,
97*a9fa9459Szrj R_MIPS_TLS_TPREL64 = 48,
98*a9fa9459Szrj R_MIPS_TLS_TPREL_HI16 = 49,
99*a9fa9459Szrj R_MIPS_TLS_TPREL_LO16 = 50,
100*a9fa9459Szrj R_MIPS_GLOB_DAT = 51,
101*a9fa9459Szrj R_MIPS_PC21_S2 = 60,
102*a9fa9459Szrj R_MIPS_PC26_S2 = 61,
103*a9fa9459Szrj R_MIPS_PC18_S3 = 62,
104*a9fa9459Szrj R_MIPS_PC19_S2 = 63,
105*a9fa9459Szrj R_MIPS_PCHI16 = 64,
106*a9fa9459Szrj R_MIPS_PCLO16 = 65,
107*a9fa9459Szrj // These relocs are used for the mips16.
108*a9fa9459Szrj R_MIPS16_26 = 100,
109*a9fa9459Szrj R_MIPS16_GPREL = 101,
110*a9fa9459Szrj R_MIPS16_GOT16 = 102,
111*a9fa9459Szrj R_MIPS16_CALL16 = 103,
112*a9fa9459Szrj R_MIPS16_HI16 = 104,
113*a9fa9459Szrj R_MIPS16_LO16 = 105,
114*a9fa9459Szrj R_MIPS16_TLS_GD = 106,
115*a9fa9459Szrj R_MIPS16_TLS_LDM = 107,
116*a9fa9459Szrj R_MIPS16_TLS_DTPREL_HI16 = 108,
117*a9fa9459Szrj R_MIPS16_TLS_DTPREL_LO16 = 109,
118*a9fa9459Szrj R_MIPS16_TLS_GOTTPREL = 110,
119*a9fa9459Szrj R_MIPS16_TLS_TPREL_HI16 = 111,
120*a9fa9459Szrj R_MIPS16_TLS_TPREL_LO16 = 112,
121*a9fa9459Szrj
122*a9fa9459Szrj R_MIPS_COPY = 126,
123*a9fa9459Szrj R_MIPS_JUMP_SLOT = 127,
124*a9fa9459Szrj
125*a9fa9459Szrj // These relocations are specific to microMIPS.
126*a9fa9459Szrj R_MICROMIPS_26_S1 = 133,
127*a9fa9459Szrj R_MICROMIPS_HI16 = 134,
128*a9fa9459Szrj R_MICROMIPS_LO16 = 135,
129*a9fa9459Szrj R_MICROMIPS_GPREL16 = 136, // In Elf 64: alias R_MICROMIPS_GPREL
130*a9fa9459Szrj R_MICROMIPS_LITERAL = 137,
131*a9fa9459Szrj R_MICROMIPS_GOT16 = 138, // In Elf 64: alias R_MICROMIPS_GOT
132*a9fa9459Szrj R_MICROMIPS_PC7_S1 = 139,
133*a9fa9459Szrj R_MICROMIPS_PC10_S1 = 140,
134*a9fa9459Szrj R_MICROMIPS_PC16_S1 = 141,
135*a9fa9459Szrj R_MICROMIPS_CALL16 = 142, // In Elf 64: alias R_MICROMIPS_CALL
136*a9fa9459Szrj R_MICROMIPS_GOT_DISP = 145,
137*a9fa9459Szrj R_MICROMIPS_GOT_PAGE = 146,
138*a9fa9459Szrj R_MICROMIPS_GOT_OFST = 147,
139*a9fa9459Szrj R_MICROMIPS_GOT_HI16 = 148,
140*a9fa9459Szrj R_MICROMIPS_GOT_LO16 = 149,
141*a9fa9459Szrj R_MICROMIPS_SUB = 150,
142*a9fa9459Szrj R_MICROMIPS_HIGHER = 151,
143*a9fa9459Szrj R_MICROMIPS_HIGHEST = 152,
144*a9fa9459Szrj R_MICROMIPS_CALL_HI16 = 153,
145*a9fa9459Szrj R_MICROMIPS_CALL_LO16 = 154,
146*a9fa9459Szrj R_MICROMIPS_SCN_DISP = 155,
147*a9fa9459Szrj R_MICROMIPS_JALR = 156,
148*a9fa9459Szrj R_MICROMIPS_HI0_LO16 = 157,
149*a9fa9459Szrj // TLS relocations.
150*a9fa9459Szrj R_MICROMIPS_TLS_GD = 162,
151*a9fa9459Szrj R_MICROMIPS_TLS_LDM = 163,
152*a9fa9459Szrj R_MICROMIPS_TLS_DTPREL_HI16 = 164,
153*a9fa9459Szrj R_MICROMIPS_TLS_DTPREL_LO16 = 165,
154*a9fa9459Szrj R_MICROMIPS_TLS_GOTTPREL = 166,
155*a9fa9459Szrj R_MICROMIPS_TLS_TPREL_HI16 = 169,
156*a9fa9459Szrj R_MICROMIPS_TLS_TPREL_LO16 = 170,
157*a9fa9459Szrj // microMIPS GP- and PC-relative relocations.
158*a9fa9459Szrj R_MICROMIPS_GPREL7_S2 = 172,
159*a9fa9459Szrj R_MICROMIPS_PC23_S2 = 173,
160*a9fa9459Szrj
161*a9fa9459Szrj // This was a GNU extension used by embedded-PIC. It was co-opted by
162*a9fa9459Szrj // mips-linux for exception-handling data. GCC stopped using it in
163*a9fa9459Szrj // May, 2004, then started using it again for compact unwind tables.
164*a9fa9459Szrj R_MIPS_PC32 = 248,
165*a9fa9459Szrj R_MIPS_EH = 249,
166*a9fa9459Szrj // This relocation is used internally by gas.
167*a9fa9459Szrj R_MIPS_GNU_REL16_S2 = 250,
168*a9fa9459Szrj // These are GNU extensions to enable C++ vtable garbage collection.
169*a9fa9459Szrj R_MIPS_GNU_VTINHERIT = 253,
170*a9fa9459Szrj R_MIPS_GNU_VTENTRY = 254
171*a9fa9459Szrj };
172*a9fa9459Szrj
173*a9fa9459Szrj // Processor specific flags for the ELF header e_flags field.
174*a9fa9459Szrj enum
175*a9fa9459Szrj {
176*a9fa9459Szrj // At least one .noreorder directive appears in the source.
177*a9fa9459Szrj EF_MIPS_NOREORDER = 0x00000001,
178*a9fa9459Szrj // File contains position independent code.
179*a9fa9459Szrj EF_MIPS_PIC = 0x00000002,
180*a9fa9459Szrj // Code in file uses the standard calling sequence for calling
181*a9fa9459Szrj // position independent code.
182*a9fa9459Szrj EF_MIPS_CPIC = 0x00000004,
183*a9fa9459Szrj // ??? Unknown flag, set in IRIX 6's BSDdup2.o in libbsd.a.
184*a9fa9459Szrj EF_MIPS_XGOT = 0x00000008,
185*a9fa9459Szrj // Code in file uses UCODE (obsolete)
186*a9fa9459Szrj EF_MIPS_UCODE = 0x00000010,
187*a9fa9459Szrj // Code in file uses new ABI (-n32 on Irix 6).
188*a9fa9459Szrj EF_MIPS_ABI2 = 0x00000020,
189*a9fa9459Szrj // Process the .MIPS.options section first by ld
190*a9fa9459Szrj EF_MIPS_OPTIONS_FIRST = 0x00000080,
191*a9fa9459Szrj // Architectural Extensions used by this file
192*a9fa9459Szrj EF_MIPS_ARCH_ASE = 0x0f000000,
193*a9fa9459Szrj // Use MDMX multimedia extensions
194*a9fa9459Szrj EF_MIPS_ARCH_ASE_MDMX = 0x08000000,
195*a9fa9459Szrj // Use MIPS-16 ISA extensions
196*a9fa9459Szrj EF_MIPS_ARCH_ASE_M16 = 0x04000000,
197*a9fa9459Szrj // Use MICROMIPS ISA extensions.
198*a9fa9459Szrj EF_MIPS_ARCH_ASE_MICROMIPS = 0x02000000,
199*a9fa9459Szrj // Indicates code compiled for a 64-bit machine in 32-bit mode.
200*a9fa9459Szrj // (regs are 32-bits wide.)
201*a9fa9459Szrj EF_MIPS_32BITMODE = 0x00000100,
202*a9fa9459Szrj // 32-bit machine but FP registers are 64 bit (-mfp64).
203*a9fa9459Szrj EF_MIPS_FP64 = 0x00000200,
204*a9fa9459Szrj /// Code in file uses the IEEE 754-2008 NaN encoding convention.
205*a9fa9459Szrj EF_MIPS_NAN2008 = 0x00000400,
206*a9fa9459Szrj // MIPS dynamic
207*a9fa9459Szrj EF_MIPS_DYNAMIC = 0x40
208*a9fa9459Szrj };
209*a9fa9459Szrj
210*a9fa9459Szrj // Machine variant if we know it. This field was invented at Cygnus,
211*a9fa9459Szrj // but it is hoped that other vendors will adopt it. If some standard
212*a9fa9459Szrj // is developed, this code should be changed to follow it.
213*a9fa9459Szrj enum
214*a9fa9459Szrj {
215*a9fa9459Szrj EF_MIPS_MACH = 0x00FF0000,
216*a9fa9459Szrj
217*a9fa9459Szrj // Cygnus is choosing values between 80 and 9F;
218*a9fa9459Szrj // 00 - 7F should be left for a future standard;
219*a9fa9459Szrj // the rest are open.
220*a9fa9459Szrj
221*a9fa9459Szrj E_MIPS_MACH_3900 = 0x00810000,
222*a9fa9459Szrj E_MIPS_MACH_4010 = 0x00820000,
223*a9fa9459Szrj E_MIPS_MACH_4100 = 0x00830000,
224*a9fa9459Szrj E_MIPS_MACH_4650 = 0x00850000,
225*a9fa9459Szrj E_MIPS_MACH_4120 = 0x00870000,
226*a9fa9459Szrj E_MIPS_MACH_4111 = 0x00880000,
227*a9fa9459Szrj E_MIPS_MACH_SB1 = 0x008a0000,
228*a9fa9459Szrj E_MIPS_MACH_OCTEON = 0x008b0000,
229*a9fa9459Szrj E_MIPS_MACH_XLR = 0x008c0000,
230*a9fa9459Szrj E_MIPS_MACH_OCTEON2 = 0x008d0000,
231*a9fa9459Szrj E_MIPS_MACH_OCTEON3 = 0x008e0000,
232*a9fa9459Szrj E_MIPS_MACH_5400 = 0x00910000,
233*a9fa9459Szrj E_MIPS_MACH_5900 = 0x00920000,
234*a9fa9459Szrj E_MIPS_MACH_5500 = 0x00980000,
235*a9fa9459Szrj E_MIPS_MACH_9000 = 0x00990000,
236*a9fa9459Szrj E_MIPS_MACH_LS2E = 0x00A00000,
237*a9fa9459Szrj E_MIPS_MACH_LS2F = 0x00A10000,
238*a9fa9459Szrj E_MIPS_MACH_LS3A = 0x00A20000,
239*a9fa9459Szrj };
240*a9fa9459Szrj
241*a9fa9459Szrj // MIPS architecture
242*a9fa9459Szrj enum
243*a9fa9459Szrj {
244*a9fa9459Szrj // Four bit MIPS architecture field.
245*a9fa9459Szrj EF_MIPS_ARCH = 0xf0000000,
246*a9fa9459Szrj // -mips1 code.
247*a9fa9459Szrj E_MIPS_ARCH_1 = 0x00000000,
248*a9fa9459Szrj // -mips2 code.
249*a9fa9459Szrj E_MIPS_ARCH_2 = 0x10000000,
250*a9fa9459Szrj // -mips3 code.
251*a9fa9459Szrj E_MIPS_ARCH_3 = 0x20000000,
252*a9fa9459Szrj // -mips4 code.
253*a9fa9459Szrj E_MIPS_ARCH_4 = 0x30000000,
254*a9fa9459Szrj // -mips5 code.
255*a9fa9459Szrj E_MIPS_ARCH_5 = 0x40000000,
256*a9fa9459Szrj // -mips32 code.
257*a9fa9459Szrj E_MIPS_ARCH_32 = 0x50000000,
258*a9fa9459Szrj // -mips64 code.
259*a9fa9459Szrj E_MIPS_ARCH_64 = 0x60000000,
260*a9fa9459Szrj // -mips32r2 code.
261*a9fa9459Szrj E_MIPS_ARCH_32R2 = 0x70000000,
262*a9fa9459Szrj // -mips64r2 code.
263*a9fa9459Szrj E_MIPS_ARCH_64R2 = 0x80000000,
264*a9fa9459Szrj // -mips32r6 code.
265*a9fa9459Szrj E_MIPS_ARCH_32R6 = 0x90000000,
266*a9fa9459Szrj // -mips64r6 code.
267*a9fa9459Szrj E_MIPS_ARCH_64R6 = 0xa0000000,
268*a9fa9459Szrj };
269*a9fa9459Szrj
270*a9fa9459Szrj // Values for the xxx_size bytes of an ABI flags structure.
271*a9fa9459Szrj enum
272*a9fa9459Szrj {
273*a9fa9459Szrj // No registers.
274*a9fa9459Szrj AFL_REG_NONE = 0x00,
275*a9fa9459Szrj // 32-bit registers.
276*a9fa9459Szrj AFL_REG_32 = 0x01,
277*a9fa9459Szrj // 64-bit registers.
278*a9fa9459Szrj AFL_REG_64 = 0x02,
279*a9fa9459Szrj // 128-bit registers.
280*a9fa9459Szrj AFL_REG_128 = 0x03
281*a9fa9459Szrj };
282*a9fa9459Szrj
283*a9fa9459Szrj // Masks for the ases word of an ABI flags structure.
284*a9fa9459Szrj enum
285*a9fa9459Szrj {
286*a9fa9459Szrj // DSP ASE.
287*a9fa9459Szrj AFL_ASE_DSP = 0x00000001,
288*a9fa9459Szrj // DSP R2 ASE.
289*a9fa9459Szrj AFL_ASE_DSPR2 = 0x00000002,
290*a9fa9459Szrj // Enhanced VA Scheme.
291*a9fa9459Szrj AFL_ASE_EVA = 0x00000004,
292*a9fa9459Szrj // MCU (MicroController) ASE.
293*a9fa9459Szrj AFL_ASE_MCU = 0x00000008,
294*a9fa9459Szrj // MDMX ASE.
295*a9fa9459Szrj AFL_ASE_MDMX = 0x00000010,
296*a9fa9459Szrj // MIPS-3D ASE.
297*a9fa9459Szrj AFL_ASE_MIPS3D = 0x00000020,
298*a9fa9459Szrj // MT ASE.
299*a9fa9459Szrj AFL_ASE_MT = 0x00000040,
300*a9fa9459Szrj // SmartMIPS ASE.
301*a9fa9459Szrj AFL_ASE_SMARTMIPS = 0x00000080,
302*a9fa9459Szrj // VZ ASE.
303*a9fa9459Szrj AFL_ASE_VIRT = 0x00000100,
304*a9fa9459Szrj // MSA ASE.
305*a9fa9459Szrj AFL_ASE_MSA = 0x00000200,
306*a9fa9459Szrj // MIPS16 ASE.
307*a9fa9459Szrj AFL_ASE_MIPS16 = 0x00000400,
308*a9fa9459Szrj // MICROMIPS ASE.
309*a9fa9459Szrj AFL_ASE_MICROMIPS = 0x00000800,
310*a9fa9459Szrj // XPA ASE.
311*a9fa9459Szrj AFL_ASE_XPA = 0x00001000
312*a9fa9459Szrj };
313*a9fa9459Szrj
314*a9fa9459Szrj // Values for the isa_ext word of an ABI flags structure.
315*a9fa9459Szrj enum
316*a9fa9459Szrj {
317*a9fa9459Szrj // RMI Xlr instruction.
318*a9fa9459Szrj AFL_EXT_XLR = 1,
319*a9fa9459Szrj // Cavium Networks Octeon2.
320*a9fa9459Szrj AFL_EXT_OCTEON2 = 2,
321*a9fa9459Szrj // Cavium Networks OcteonP.
322*a9fa9459Szrj AFL_EXT_OCTEONP = 3,
323*a9fa9459Szrj // Loongson 3A.
324*a9fa9459Szrj AFL_EXT_LOONGSON_3A = 4,
325*a9fa9459Szrj // Cavium Networks Octeon.
326*a9fa9459Szrj AFL_EXT_OCTEON = 5,
327*a9fa9459Szrj // MIPS R5900 instruction.
328*a9fa9459Szrj AFL_EXT_5900 = 6,
329*a9fa9459Szrj // MIPS R4650 instruction.
330*a9fa9459Szrj AFL_EXT_4650 = 7,
331*a9fa9459Szrj // LSI R4010 instruction.
332*a9fa9459Szrj AFL_EXT_4010 = 8,
333*a9fa9459Szrj // NEC VR4100 instruction.
334*a9fa9459Szrj AFL_EXT_4100 = 9,
335*a9fa9459Szrj // Toshiba R3900 instruction.
336*a9fa9459Szrj AFL_EXT_3900 = 10,
337*a9fa9459Szrj // MIPS R10000 instruction.
338*a9fa9459Szrj AFL_EXT_10000 = 11,
339*a9fa9459Szrj // Broadcom SB-1 instruction.
340*a9fa9459Szrj AFL_EXT_SB1 = 12,
341*a9fa9459Szrj // NEC VR4111/VR4181 instruction.
342*a9fa9459Szrj AFL_EXT_4111 = 13,
343*a9fa9459Szrj // NEC VR4120 instruction.
344*a9fa9459Szrj AFL_EXT_4120 = 14,
345*a9fa9459Szrj // NEC VR5400 instruction.
346*a9fa9459Szrj AFL_EXT_5400 = 15,
347*a9fa9459Szrj // NEC VR5500 instruction.
348*a9fa9459Szrj AFL_EXT_5500 = 16,
349*a9fa9459Szrj // ST Microelectronics Loongson 2E.
350*a9fa9459Szrj AFL_EXT_LOONGSON_2E = 17,
351*a9fa9459Szrj // ST Microelectronics Loongson 2F.
352*a9fa9459Szrj AFL_EXT_LOONGSON_2F = 18,
353*a9fa9459Szrj // Cavium Networks Octeon3.
354*a9fa9459Szrj AFL_EXT_OCTEON3 = 19
355*a9fa9459Szrj };
356*a9fa9459Szrj
357*a9fa9459Szrj // Masks for the flags1 word of an ABI flags structure.
358*a9fa9459Szrj enum
359*a9fa9459Szrj {
360*a9fa9459Szrj // Uses odd single-precision registers.
361*a9fa9459Szrj AFL_FLAGS1_ODDSPREG = 1
362*a9fa9459Szrj };
363*a9fa9459Szrj
364*a9fa9459Szrj // Object attribute tags.
365*a9fa9459Szrj enum
366*a9fa9459Szrj {
367*a9fa9459Szrj // 0-3 are generic.
368*a9fa9459Szrj // Floating-point ABI used by this object file.
369*a9fa9459Szrj Tag_GNU_MIPS_ABI_FP = 4,
370*a9fa9459Szrj // MSA ABI used by this object file.
371*a9fa9459Szrj Tag_GNU_MIPS_ABI_MSA = 8
372*a9fa9459Szrj };
373*a9fa9459Szrj
374*a9fa9459Szrj // Object attribute values.
375*a9fa9459Szrj enum
376*a9fa9459Szrj {
377*a9fa9459Szrj // Values defined for Tag_GNU_MIPS_ABI_FP.
378*a9fa9459Szrj // Not tagged or not using any ABIs affected by the differences.
379*a9fa9459Szrj Val_GNU_MIPS_ABI_FP_ANY = 0,
380*a9fa9459Szrj // Using hard-float -mdouble-float.
381*a9fa9459Szrj Val_GNU_MIPS_ABI_FP_DOUBLE = 1,
382*a9fa9459Szrj // Using hard-float -msingle-float.
383*a9fa9459Szrj Val_GNU_MIPS_ABI_FP_SINGLE = 2,
384*a9fa9459Szrj // Using soft-float.
385*a9fa9459Szrj Val_GNU_MIPS_ABI_FP_SOFT = 3,
386*a9fa9459Szrj // Using -mips32r2 -mfp64.
387*a9fa9459Szrj Val_GNU_MIPS_ABI_FP_OLD_64 = 4,
388*a9fa9459Szrj // Using -mfpxx
389*a9fa9459Szrj Val_GNU_MIPS_ABI_FP_XX = 5,
390*a9fa9459Szrj // Using -mips32r2 -mfp64.
391*a9fa9459Szrj Val_GNU_MIPS_ABI_FP_64 = 6,
392*a9fa9459Szrj // Using -mips32r2 -mfp64 -mno-odd-spreg.
393*a9fa9459Szrj Val_GNU_MIPS_ABI_FP_64A = 7,
394*a9fa9459Szrj // This is reserved for backward-compatibility with an earlier
395*a9fa9459Szrj // implementation of the MIPS NaN2008 functionality.
396*a9fa9459Szrj Val_GNU_MIPS_ABI_FP_NAN2008 = 8,
397*a9fa9459Szrj
398*a9fa9459Szrj // Values defined for Tag_GNU_MIPS_ABI_MSA.
399*a9fa9459Szrj // Not tagged or not using any ABIs affected by the differences.
400*a9fa9459Szrj Val_GNU_MIPS_ABI_MSA_ANY = 0,
401*a9fa9459Szrj // Using 128-bit MSA.
402*a9fa9459Szrj Val_GNU_MIPS_ABI_MSA_128 = 1
403*a9fa9459Szrj };
404*a9fa9459Szrj
405*a9fa9459Szrj enum
406*a9fa9459Szrj {
407*a9fa9459Szrj // Mask to extract ABI version, not really a flag value.
408*a9fa9459Szrj EF_MIPS_ABI = 0x0000F000,
409*a9fa9459Szrj
410*a9fa9459Szrj // The original o32 abi.
411*a9fa9459Szrj E_MIPS_ABI_O32 = 0x00001000,
412*a9fa9459Szrj // O32 extended to work on 64 bit architectures
413*a9fa9459Szrj E_MIPS_ABI_O64 = 0x00002000,
414*a9fa9459Szrj // EABI in 32 bit mode
415*a9fa9459Szrj E_MIPS_ABI_EABI32 = 0x00003000,
416*a9fa9459Szrj // EABI in 64 bit mode
417*a9fa9459Szrj E_MIPS_ABI_EABI64 = 0x00004000,
418*a9fa9459Szrj };
419*a9fa9459Szrj
420*a9fa9459Szrj // Dynamic section MIPS flags
421*a9fa9459Szrj enum
422*a9fa9459Szrj {
423*a9fa9459Szrj // None
424*a9fa9459Szrj RHF_NONE = 0x00000000,
425*a9fa9459Szrj // Use shortcut pointers
426*a9fa9459Szrj RHF_QUICKSTART = 0x00000001,
427*a9fa9459Szrj // Hash size not power of two
428*a9fa9459Szrj RHF_NOTPOT = 0x00000002,
429*a9fa9459Szrj // Ignore LD_LIBRARY_PATH
430*a9fa9459Szrj RHF_NO_LIBRARY_REPLACEMENT = 0x00000004
431*a9fa9459Szrj };
432*a9fa9459Szrj
433*a9fa9459Szrj // Special values for the st_other field in the symbol table.
434*a9fa9459Szrj enum
435*a9fa9459Szrj {
436*a9fa9459Szrj // Two topmost bits denote the MIPS ISA for .text symbols:
437*a9fa9459Szrj // + 00 -- standard MIPS code,
438*a9fa9459Szrj // + 10 -- microMIPS code,
439*a9fa9459Szrj // + 11 -- MIPS16 code; requires the following two bits to be set too.
440*a9fa9459Szrj // Note that one of the MIPS16 bits overlaps with STO_MIPS_PIC.
441*a9fa9459Szrj STO_MIPS_ISA = 0xc0,
442*a9fa9459Szrj
443*a9fa9459Szrj // The mask spanning the rest of MIPS psABI flags. At most one is expected
444*a9fa9459Szrj // to be set except for STO_MIPS16.
445*a9fa9459Szrj STO_MIPS_FLAGS = ~(STO_MIPS_ISA | 0x3),
446*a9fa9459Szrj
447*a9fa9459Szrj // The MIPS psABI was updated in 2008 with support for PLTs and copy
448*a9fa9459Szrj // relocs. There are therefore two types of nonzero SHN_UNDEF functions:
449*a9fa9459Szrj // PLT entries and traditional MIPS lazy binding stubs. We mark the former
450*a9fa9459Szrj // with STO_MIPS_PLT to distinguish them from the latter.
451*a9fa9459Szrj STO_MIPS_PLT = 0x8,
452*a9fa9459Szrj
453*a9fa9459Szrj // This value is used to mark PIC functions in an object that mixes
454*a9fa9459Szrj // PIC and non-PIC. Note that this bit overlaps with STO_MIPS16,
455*a9fa9459Szrj // although MIPS16 symbols are never considered to be MIPS_PIC.
456*a9fa9459Szrj STO_MIPS_PIC = 0x20,
457*a9fa9459Szrj
458*a9fa9459Szrj // This value is used for a mips16 .text symbol.
459*a9fa9459Szrj STO_MIPS16 = 0xf0,
460*a9fa9459Szrj
461*a9fa9459Szrj // This value is used for a microMIPS .text symbol. To distinguish from
462*a9fa9459Szrj // STO_MIPS16, we set top two bits to be 10 to denote STO_MICROMIPS. The
463*a9fa9459Szrj // mask is STO_MIPS_ISA.
464*a9fa9459Szrj STO_MICROMIPS = 0x80
465*a9fa9459Szrj };
466*a9fa9459Szrj
467*a9fa9459Szrj // Values for base offsets for thread-local storage
468*a9fa9459Szrj enum
469*a9fa9459Szrj {
470*a9fa9459Szrj TP_OFFSET = 0x7000,
471*a9fa9459Szrj DTP_OFFSET = 0x8000
472*a9fa9459Szrj };
473*a9fa9459Szrj
474*a9fa9459Szrj
475*a9fa9459Szrj bool
elf_st_is_mips16(unsigned char st_other)476*a9fa9459Szrj elf_st_is_mips16(unsigned char st_other)
477*a9fa9459Szrj { return (st_other & elfcpp::STO_MIPS16) == elfcpp::STO_MIPS16; }
478*a9fa9459Szrj
479*a9fa9459Szrj bool
elf_st_is_micromips(unsigned char st_other)480*a9fa9459Szrj elf_st_is_micromips(unsigned char st_other)
481*a9fa9459Szrj { return (st_other & elfcpp::STO_MIPS_ISA) == elfcpp::STO_MICROMIPS; }
482*a9fa9459Szrj
483*a9fa9459Szrj // Whether the ABI is N32.
484*a9fa9459Szrj bool
abi_n32(elfcpp::Elf_Word e_flags)485*a9fa9459Szrj abi_n32(elfcpp::Elf_Word e_flags)
486*a9fa9459Szrj { return (e_flags & elfcpp::EF_MIPS_ABI2) != 0; }
487*a9fa9459Szrj
488*a9fa9459Szrj // Whether the ISA is R6.
489*a9fa9459Szrj bool
r6_isa(elfcpp::Elf_Word e_flags)490*a9fa9459Szrj r6_isa(elfcpp::Elf_Word e_flags)
491*a9fa9459Szrj {
492*a9fa9459Szrj return ((e_flags & elfcpp::EF_MIPS_ARCH) == elfcpp::E_MIPS_ARCH_32R6)
493*a9fa9459Szrj || ((e_flags & elfcpp::EF_MIPS_ARCH) == elfcpp::E_MIPS_ARCH_64R6);
494*a9fa9459Szrj }
495*a9fa9459Szrj
496*a9fa9459Szrj // Whether the file has microMIPS code.
497*a9fa9459Szrj bool
is_micromips(elfcpp::Elf_Word e_flags)498*a9fa9459Szrj is_micromips(elfcpp::Elf_Word e_flags)
499*a9fa9459Szrj { return (e_flags & elfcpp::EF_MIPS_ARCH_ASE_MICROMIPS) != 0; }
500*a9fa9459Szrj
501*a9fa9459Szrj // Values which may appear in the kind field of an Elf_Options structure.
502*a9fa9459Szrj enum
503*a9fa9459Szrj {
504*a9fa9459Szrj // Undefined.
505*a9fa9459Szrj ODK_NULL = 0,
506*a9fa9459Szrj // Register usage and GP value.
507*a9fa9459Szrj ODK_REGINFO = 1,
508*a9fa9459Szrj // Exception processing information.
509*a9fa9459Szrj ODK_EXCEPTIONS = 2,
510*a9fa9459Szrj // Section padding information.
511*a9fa9459Szrj ODK_PAD = 3,
512*a9fa9459Szrj // Hardware workarounds performed.
513*a9fa9459Szrj ODK_HWPATCH = 4,
514*a9fa9459Szrj // Fill value used by the linker.
515*a9fa9459Szrj ODK_FILL = 5,
516*a9fa9459Szrj // Reserved space for desktop tools.
517*a9fa9459Szrj ODK_TAGS = 6,
518*a9fa9459Szrj // Hardware workarounds, AND bits when merging.
519*a9fa9459Szrj ODK_HWAND = 7,
520*a9fa9459Szrj // Hardware workarounds, OR bits when merging.
521*a9fa9459Szrj ODK_HWOR = 8,
522*a9fa9459Szrj // GP group to use for text/data sections.
523*a9fa9459Szrj ODK_GP_GROUP = 9,
524*a9fa9459Szrj // ID information.
525*a9fa9459Szrj ODK_IDENT = 10
526*a9fa9459Szrj };
527*a9fa9459Szrj
528*a9fa9459Szrj } // End namespace elfcpp.
529*a9fa9459Szrj
530*a9fa9459Szrj #endif // !defined(ELFCPP_MIPS_H)
531