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