xref: /netbsd-src/external/gpl3/binutils/dist/elfcpp/mips.h (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1883529b6Schristos // mips.h -- ELF definitions specific to EM_MIPS  -*- C++ -*-
2883529b6Schristos 
3*cb63e24eSchristos // Copyright (C) 2012-2024 Free Software Foundation, Inc.
49573673dSchristos // Written by Sasa Stankovic <sasa.stankovic@imgtec.com>
59573673dSchristos //        and Aleksandar Simeonov <aleksandar.simeonov@rt-rk.com>.
6883529b6Schristos 
7883529b6Schristos // This file is part of elfcpp.
8883529b6Schristos 
9883529b6Schristos // This program is free software; you can redistribute it and/or
10883529b6Schristos // modify it under the terms of the GNU Library General Public License
11883529b6Schristos // as published by the Free Software Foundation; either version 2, or
12883529b6Schristos // (at your option) any later version.
13883529b6Schristos 
14883529b6Schristos // In addition to the permissions in the GNU Library General Public
15883529b6Schristos // License, the Free Software Foundation gives you unlimited
16883529b6Schristos // permission to link the compiled version of this file into
17883529b6Schristos // combinations with other programs, and to distribute those
18883529b6Schristos // combinations without any restriction coming from the use of this
19883529b6Schristos // file.  (The Library Public License restrictions do apply in other
20883529b6Schristos // respects; for example, they cover modification of the file, and
21883529b6Schristos /// distribution when not linked into a combined executable.)
22883529b6Schristos 
23883529b6Schristos // This program is distributed in the hope that it will be useful, but
24883529b6Schristos // WITHOUT ANY WARRANTY; without even the implied warranty of
25883529b6Schristos // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26883529b6Schristos // Library General Public License for more details.
27883529b6Schristos 
28883529b6Schristos // You should have received a copy of the GNU Library General Public
29883529b6Schristos // License along with this program; if not, write to the Free Software
30883529b6Schristos // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
31883529b6Schristos // 02110-1301, USA.
32883529b6Schristos 
33883529b6Schristos #ifndef ELFCPP_MIPS_H
34883529b6Schristos #define ELFCPP_MIPS_H
35883529b6Schristos 
36883529b6Schristos // Documentation for the MIPS relocs is taken from
37883529b6Schristos //   http://math-atlas.sourceforge.net/devel/assembly/mipsabi32.pdf
38883529b6Schristos 
39883529b6Schristos namespace elfcpp
40883529b6Schristos {
41883529b6Schristos 
42883529b6Schristos //
43883529b6Schristos // MIPS Relocation Codes
44883529b6Schristos //
45883529b6Schristos 
46883529b6Schristos enum
47883529b6Schristos {
48883529b6Schristos   R_MIPS_NONE = 0,
49883529b6Schristos   R_MIPS_16 = 1,
509573673dSchristos   R_MIPS_32 = 2,                   // In Elf 64: alias R_MIPS_ADD
519573673dSchristos   R_MIPS_REL32 = 3,                // In Elf 64: alias R_MIPS_REL
52883529b6Schristos   R_MIPS_26 = 4,
53883529b6Schristos   R_MIPS_HI16 = 5,
54883529b6Schristos   R_MIPS_LO16 = 6,
559573673dSchristos   R_MIPS_GPREL16 = 7,              // In Elf 64: alias R_MIPS_GPREL
56883529b6Schristos   R_MIPS_LITERAL = 8,
579573673dSchristos   R_MIPS_GOT16 = 9,                // In Elf 64: alias R_MIPS_GOT
58883529b6Schristos   R_MIPS_PC16 = 10,
599573673dSchristos   R_MIPS_CALL16 = 11,              // In Elf 64: alias R_MIPS_CALL
60883529b6Schristos   R_MIPS_GPREL32 = 12,
61883529b6Schristos   R_MIPS_UNUSED1 = 13,
62883529b6Schristos   R_MIPS_UNUSED2 = 14,
63883529b6Schristos   R_MIPS_UNUSED3 = 15,
64883529b6Schristos   R_MIPS_SHIFT5 = 16,
65883529b6Schristos   R_MIPS_SHIFT6 = 17,
66883529b6Schristos   R_MIPS_64 = 18,
67883529b6Schristos   R_MIPS_GOT_DISP = 19,
68883529b6Schristos   R_MIPS_GOT_PAGE = 20,
69883529b6Schristos   R_MIPS_GOT_OFST = 21,
70883529b6Schristos   R_MIPS_GOT_HI16 = 22,
71883529b6Schristos   R_MIPS_GOT_LO16 = 23,
72883529b6Schristos   R_MIPS_SUB = 24,
739573673dSchristos   R_MIPS_INSERT_A = 25,
749573673dSchristos   R_MIPS_INSERT_B = 26,
759573673dSchristos   R_MIPS_DELETE = 27,
76883529b6Schristos   R_MIPS_HIGHER = 28,
77883529b6Schristos   R_MIPS_HIGHEST = 29,
78883529b6Schristos   R_MIPS_CALL_HI16 = 30,
79883529b6Schristos   R_MIPS_CALL_LO16 = 31,
80883529b6Schristos   R_MIPS_SCN_DISP = 32,
819573673dSchristos   R_MIPS_REL16 = 33,
829573673dSchristos   R_MIPS_ADD_IMMEDIATE = 34,
839573673dSchristos   R_MIPS_PJUMP = 35,
849573673dSchristos   R_MIPS_RELGOT = 36,
85883529b6Schristos   R_MIPS_JALR = 37,
869573673dSchristos   // TLS relocations.
87883529b6Schristos   R_MIPS_TLS_DTPMOD32 = 38,
88883529b6Schristos   R_MIPS_TLS_DTPREL32 = 39,
899573673dSchristos   R_MIPS_TLS_DTPMOD64 = 40,
909573673dSchristos   R_MIPS_TLS_DTPREL64 = 41,
91883529b6Schristos   R_MIPS_TLS_GD = 42,
92883529b6Schristos   R_MIPS_TLS_LDM = 43,
93883529b6Schristos   R_MIPS_TLS_DTPREL_HI16 = 44,
94883529b6Schristos   R_MIPS_TLS_DTPREL_LO16 = 45,
95883529b6Schristos   R_MIPS_TLS_GOTTPREL = 46,
96883529b6Schristos   R_MIPS_TLS_TPREL32 = 47,
979573673dSchristos   R_MIPS_TLS_TPREL64 = 48,
98883529b6Schristos   R_MIPS_TLS_TPREL_HI16 = 49,
99883529b6Schristos   R_MIPS_TLS_TPREL_LO16 = 50,
100883529b6Schristos   R_MIPS_GLOB_DAT = 51,
1018cbf5cb7Schristos   R_MIPS_PC21_S2 = 60,
1028cbf5cb7Schristos   R_MIPS_PC26_S2 = 61,
1038cbf5cb7Schristos   R_MIPS_PC18_S3 = 62,
1048cbf5cb7Schristos   R_MIPS_PC19_S2 = 63,
1058cbf5cb7Schristos   R_MIPS_PCHI16 = 64,
1068cbf5cb7Schristos   R_MIPS_PCLO16 = 65,
1079573673dSchristos   // These relocs are used for the mips16.
108883529b6Schristos   R_MIPS16_26 = 100,
109883529b6Schristos   R_MIPS16_GPREL = 101,
110883529b6Schristos   R_MIPS16_GOT16 = 102,
111883529b6Schristos   R_MIPS16_CALL16 = 103,
112883529b6Schristos   R_MIPS16_HI16 = 104,
113883529b6Schristos   R_MIPS16_LO16 = 105,
1149573673dSchristos   R_MIPS16_TLS_GD = 106,
1159573673dSchristos   R_MIPS16_TLS_LDM = 107,
1169573673dSchristos   R_MIPS16_TLS_DTPREL_HI16 = 108,
1179573673dSchristos   R_MIPS16_TLS_DTPREL_LO16 = 109,
1189573673dSchristos   R_MIPS16_TLS_GOTTPREL = 110,
1199573673dSchristos   R_MIPS16_TLS_TPREL_HI16 = 111,
1209573673dSchristos   R_MIPS16_TLS_TPREL_LO16 = 112,
1219573673dSchristos 
122883529b6Schristos   R_MIPS_COPY = 126,
123883529b6Schristos   R_MIPS_JUMP_SLOT = 127,
1249573673dSchristos 
1259573673dSchristos   // These relocations are specific to microMIPS.
1269573673dSchristos   R_MICROMIPS_26_S1 = 133,
1279573673dSchristos   R_MICROMIPS_HI16 = 134,
1289573673dSchristos   R_MICROMIPS_LO16 = 135,
1299573673dSchristos   R_MICROMIPS_GPREL16 = 136,       // In Elf 64: alias R_MICROMIPS_GPREL
1309573673dSchristos   R_MICROMIPS_LITERAL = 137,
1319573673dSchristos   R_MICROMIPS_GOT16 = 138,         // In Elf 64: alias R_MICROMIPS_GOT
1329573673dSchristos   R_MICROMIPS_PC7_S1 = 139,
1339573673dSchristos   R_MICROMIPS_PC10_S1 = 140,
1349573673dSchristos   R_MICROMIPS_PC16_S1 = 141,
1359573673dSchristos   R_MICROMIPS_CALL16 = 142,        // In Elf 64: alias R_MICROMIPS_CALL
1369573673dSchristos   R_MICROMIPS_GOT_DISP = 145,
1379573673dSchristos   R_MICROMIPS_GOT_PAGE = 146,
1389573673dSchristos   R_MICROMIPS_GOT_OFST = 147,
1399573673dSchristos   R_MICROMIPS_GOT_HI16 = 148,
1409573673dSchristos   R_MICROMIPS_GOT_LO16 = 149,
1419573673dSchristos   R_MICROMIPS_SUB = 150,
1429573673dSchristos   R_MICROMIPS_HIGHER = 151,
1439573673dSchristos   R_MICROMIPS_HIGHEST = 152,
1449573673dSchristos   R_MICROMIPS_CALL_HI16 = 153,
1459573673dSchristos   R_MICROMIPS_CALL_LO16 = 154,
1469573673dSchristos   R_MICROMIPS_SCN_DISP = 155,
1479573673dSchristos   R_MICROMIPS_JALR = 156,
1489573673dSchristos   R_MICROMIPS_HI0_LO16 = 157,
1499573673dSchristos   // TLS relocations.
1509573673dSchristos   R_MICROMIPS_TLS_GD = 162,
1519573673dSchristos   R_MICROMIPS_TLS_LDM = 163,
1529573673dSchristos   R_MICROMIPS_TLS_DTPREL_HI16 = 164,
1539573673dSchristos   R_MICROMIPS_TLS_DTPREL_LO16 = 165,
1549573673dSchristos   R_MICROMIPS_TLS_GOTTPREL = 166,
1559573673dSchristos   R_MICROMIPS_TLS_TPREL_HI16 = 169,
1569573673dSchristos   R_MICROMIPS_TLS_TPREL_LO16 = 170,
1579573673dSchristos   // microMIPS GP- and PC-relative relocations.
1589573673dSchristos   R_MICROMIPS_GPREL7_S2 = 172,
1599573673dSchristos   R_MICROMIPS_PC23_S2 = 173,
1609573673dSchristos 
1619573673dSchristos   // This was a GNU extension used by embedded-PIC.  It was co-opted by
1629573673dSchristos   // mips-linux for exception-handling data.  GCC stopped using it in
1639573673dSchristos   // May, 2004, then started using it again for compact unwind tables.
164883529b6Schristos   R_MIPS_PC32 = 248,
1659573673dSchristos   R_MIPS_EH = 249,
1669573673dSchristos   // This relocation is used internally by gas.
167883529b6Schristos   R_MIPS_GNU_REL16_S2 = 250,
1689573673dSchristos   // These are GNU extensions to enable C++ vtable garbage collection.
169883529b6Schristos   R_MIPS_GNU_VTINHERIT = 253,
170883529b6Schristos   R_MIPS_GNU_VTENTRY = 254
171883529b6Schristos };
172883529b6Schristos 
1739573673dSchristos // Processor specific flags for the ELF header e_flags field.
174883529b6Schristos enum
175883529b6Schristos {
176883529b6Schristos   // At least one .noreorder directive appears in the source.
177883529b6Schristos   EF_MIPS_NOREORDER = 0x00000001,
178883529b6Schristos   // File contains position independent code.
179883529b6Schristos   EF_MIPS_PIC = 0x00000002,
180883529b6Schristos   // Code in file uses the standard calling sequence for calling
181883529b6Schristos   // position independent code.
182883529b6Schristos   EF_MIPS_CPIC = 0x00000004,
183883529b6Schristos   // ???  Unknown flag, set in IRIX 6's BSDdup2.o in libbsd.a.
184883529b6Schristos   EF_MIPS_XGOT = 0x00000008,
185883529b6Schristos   // Code in file uses UCODE (obsolete)
186883529b6Schristos   EF_MIPS_UCODE = 0x00000010,
187883529b6Schristos   // Code in file uses new ABI (-n32 on Irix 6).
188883529b6Schristos   EF_MIPS_ABI2 = 0x00000020,
189883529b6Schristos   // Process the .MIPS.options section first by ld
190883529b6Schristos   EF_MIPS_OPTIONS_FIRST = 0x00000080,
191883529b6Schristos   // Architectural Extensions used by this file
192883529b6Schristos   EF_MIPS_ARCH_ASE = 0x0f000000,
193883529b6Schristos   // Use MDMX multimedia extensions
194883529b6Schristos   EF_MIPS_ARCH_ASE_MDMX = 0x08000000,
195883529b6Schristos   // Use MIPS-16 ISA extensions
196883529b6Schristos   EF_MIPS_ARCH_ASE_M16 = 0x04000000,
197883529b6Schristos   // Use MICROMIPS ISA extensions.
198883529b6Schristos   EF_MIPS_ARCH_ASE_MICROMIPS = 0x02000000,
199883529b6Schristos   // Indicates code compiled for a 64-bit machine in 32-bit mode.
200883529b6Schristos   // (regs are 32-bits wide.)
201883529b6Schristos   EF_MIPS_32BITMODE = 0x00000100,
2028cbf5cb7Schristos   // 32-bit machine but FP registers are 64 bit (-mfp64).
2038cbf5cb7Schristos   EF_MIPS_FP64 = 0x00000200,
2048cbf5cb7Schristos   /// Code in file uses the IEEE 754-2008 NaN encoding convention.
2058cbf5cb7Schristos   EF_MIPS_NAN2008 = 0x00000400,
206883529b6Schristos   // MIPS dynamic
207883529b6Schristos   EF_MIPS_DYNAMIC = 0x40
208883529b6Schristos };
209883529b6Schristos 
210883529b6Schristos // Machine variant if we know it.  This field was invented at Cygnus,
211883529b6Schristos // but it is hoped that other vendors will adopt it.  If some standard
212883529b6Schristos // is developed, this code should be changed to follow it.
213883529b6Schristos enum
214883529b6Schristos {
215883529b6Schristos   EF_MIPS_MACH = 0x00FF0000,
216883529b6Schristos 
217883529b6Schristos // Cygnus is choosing values between 80 and 9F;
218883529b6Schristos // 00 - 7F should be left for a future standard;
219883529b6Schristos // the rest are open.
220883529b6Schristos 
221*cb63e24eSchristos   EF_MIPS_MACH_3900 = 0x00810000,
222*cb63e24eSchristos   EF_MIPS_MACH_4010 = 0x00820000,
223*cb63e24eSchristos   EF_MIPS_MACH_4100 = 0x00830000,
224*cb63e24eSchristos   EF_MIPS_MACH_4650 = 0x00850000,
225*cb63e24eSchristos   EF_MIPS_MACH_4120 = 0x00870000,
226*cb63e24eSchristos   EF_MIPS_MACH_4111 = 0x00880000,
227*cb63e24eSchristos   EF_MIPS_MACH_SB1 = 0x008a0000,
228*cb63e24eSchristos   EF_MIPS_MACH_OCTEON = 0x008b0000,
229*cb63e24eSchristos   EF_MIPS_MACH_XLR = 0x008c0000,
230*cb63e24eSchristos   EF_MIPS_MACH_OCTEON2 = 0x008d0000,
231*cb63e24eSchristos   EF_MIPS_MACH_OCTEON3 = 0x008e0000,
232*cb63e24eSchristos   EF_MIPS_MACH_5400 = 0x00910000,
233*cb63e24eSchristos   EF_MIPS_MACH_5900 = 0x00920000,
234*cb63e24eSchristos   EF_MIPS_MACH_5500 = 0x00980000,
235*cb63e24eSchristos   EF_MIPS_MACH_9000 = 0x00990000,
236*cb63e24eSchristos   EF_MIPS_MACH_LS2E = 0x00A00000,
237*cb63e24eSchristos   EF_MIPS_MACH_LS2F = 0x00A10000,
238*cb63e24eSchristos   EF_MIPS_MACH_GS464 = 0x00A20000,
239*cb63e24eSchristos   EF_MIPS_MACH_GS464E = 0x00A30000,
240*cb63e24eSchristos   EF_MIPS_MACH_GS264E = 0x00A40000,
241*cb63e24eSchristos 
242*cb63e24eSchristos   // In order to support backwards compatibility we also
243*cb63e24eSchristos   // define the old versions of some of these constants.
244*cb63e24eSchristos   E_MIPS_MACH_3900    = EF_MIPS_MACH_3900,
245*cb63e24eSchristos   E_MIPS_MACH_4010    = EF_MIPS_MACH_4010,
246*cb63e24eSchristos   E_MIPS_MACH_4100    = EF_MIPS_MACH_4100,
247*cb63e24eSchristos   E_MIPS_MACH_4650    = EF_MIPS_MACH_4650,
248*cb63e24eSchristos   E_MIPS_MACH_4120    = EF_MIPS_MACH_4120,
249*cb63e24eSchristos   E_MIPS_MACH_4111    = EF_MIPS_MACH_4111,
250*cb63e24eSchristos   E_MIPS_MACH_SB1     = EF_MIPS_MACH_SB1,
251*cb63e24eSchristos   E_MIPS_MACH_OCTEON  = EF_MIPS_MACH_OCTEON,
252*cb63e24eSchristos   E_MIPS_MACH_XLR     = EF_MIPS_MACH_XLR,
253*cb63e24eSchristos   E_MIPS_MACH_OCTEON2 = EF_MIPS_MACH_OCTEON2,
254*cb63e24eSchristos   E_MIPS_MACH_OCTEON3 = EF_MIPS_MACH_OCTEON3,
255*cb63e24eSchristos   E_MIPS_MACH_5400    = EF_MIPS_MACH_5400,
256*cb63e24eSchristos   E_MIPS_MACH_5900    = EF_MIPS_MACH_5900,
257*cb63e24eSchristos   E_MIPS_MACH_5500    = EF_MIPS_MACH_5500,
258*cb63e24eSchristos   E_MIPS_MACH_9000    = EF_MIPS_MACH_9000,
259*cb63e24eSchristos   E_MIPS_MACH_LS2E    = EF_MIPS_MACH_LS2E,
260*cb63e24eSchristos   E_MIPS_MACH_LS2F    = EF_MIPS_MACH_LS2F,
261*cb63e24eSchristos   E_MIPS_MACH_GS464   = EF_MIPS_MACH_GS464,
262*cb63e24eSchristos   E_MIPS_MACH_GS464E  = EF_MIPS_MACH_GS464E,
263*cb63e24eSchristos   E_MIPS_MACH_GS264E  = EF_MIPS_MACH_GS264E,
264883529b6Schristos };
265883529b6Schristos 
266883529b6Schristos // MIPS architecture
267883529b6Schristos enum
268883529b6Schristos {
269883529b6Schristos   // Four bit MIPS architecture field.
270883529b6Schristos   EF_MIPS_ARCH = 0xf0000000,
271883529b6Schristos   // -mips1 code.
272*cb63e24eSchristos   EF_MIPS_ARCH_1 = 0x00000000,
273883529b6Schristos   // -mips2 code.
274*cb63e24eSchristos   EF_MIPS_ARCH_2 = 0x10000000,
275883529b6Schristos   // -mips3 code.
276*cb63e24eSchristos   EF_MIPS_ARCH_3 = 0x20000000,
277883529b6Schristos   // -mips4 code.
278*cb63e24eSchristos   EF_MIPS_ARCH_4 = 0x30000000,
279883529b6Schristos   // -mips5 code.
280*cb63e24eSchristos   EF_MIPS_ARCH_5 = 0x40000000,
281883529b6Schristos   // -mips32 code.
282*cb63e24eSchristos   EF_MIPS_ARCH_32 = 0x50000000,
283883529b6Schristos   // -mips64 code.
284*cb63e24eSchristos   EF_MIPS_ARCH_64 = 0x60000000,
285883529b6Schristos   // -mips32r2 code.
286*cb63e24eSchristos   EF_MIPS_ARCH_32R2 = 0x70000000,
287883529b6Schristos   // -mips64r2 code.
288*cb63e24eSchristos   EF_MIPS_ARCH_64R2 = 0x80000000,
2899573673dSchristos   // -mips32r6 code.
290*cb63e24eSchristos   EF_MIPS_ARCH_32R6 = 0x90000000,
2919573673dSchristos   // -mips64r6 code.
292*cb63e24eSchristos   EF_MIPS_ARCH_64R6 = 0xa0000000,
293*cb63e24eSchristos 
294*cb63e24eSchristos   // In order to support backwards compatibility we also
295*cb63e24eSchristos   // define the old versions of some of these constants.
296*cb63e24eSchristos   E_MIPS_ARCH_1    = EF_MIPS_ARCH_1,
297*cb63e24eSchristos   E_MIPS_ARCH_2    = EF_MIPS_ARCH_2,
298*cb63e24eSchristos   E_MIPS_ARCH_3    = EF_MIPS_ARCH_3,
299*cb63e24eSchristos   E_MIPS_ARCH_4    = EF_MIPS_ARCH_4,
300*cb63e24eSchristos   E_MIPS_ARCH_5    = EF_MIPS_ARCH_5,
301*cb63e24eSchristos   E_MIPS_ARCH_32   = EF_MIPS_ARCH_32,
302*cb63e24eSchristos   E_MIPS_ARCH_64   = EF_MIPS_ARCH_64,
303*cb63e24eSchristos   E_MIPS_ARCH_32R2 = EF_MIPS_ARCH_32R2,
304*cb63e24eSchristos   E_MIPS_ARCH_64R2 = EF_MIPS_ARCH_64R2,
305*cb63e24eSchristos   E_MIPS_ARCH_32R6 = EF_MIPS_ARCH_32R6,
306*cb63e24eSchristos   E_MIPS_ARCH_64R6 = EF_MIPS_ARCH_64R6,
307*cb63e24eSchristos 
308883529b6Schristos };
309883529b6Schristos 
3108cbf5cb7Schristos // Values for the xxx_size bytes of an ABI flags structure.
3118cbf5cb7Schristos enum
3128cbf5cb7Schristos {
3138cbf5cb7Schristos   // No registers.
3148cbf5cb7Schristos   AFL_REG_NONE = 0x00,
3158cbf5cb7Schristos   // 32-bit registers.
3168cbf5cb7Schristos   AFL_REG_32 = 0x01,
3178cbf5cb7Schristos   // 64-bit registers.
3188cbf5cb7Schristos   AFL_REG_64 = 0x02,
3198cbf5cb7Schristos   // 128-bit registers.
3208cbf5cb7Schristos   AFL_REG_128 = 0x03
3218cbf5cb7Schristos };
3228cbf5cb7Schristos 
3238cbf5cb7Schristos // Masks for the ases word of an ABI flags structure.
3248cbf5cb7Schristos enum
3258cbf5cb7Schristos {
3268cbf5cb7Schristos   // DSP ASE.
3278cbf5cb7Schristos   AFL_ASE_DSP = 0x00000001,
3288cbf5cb7Schristos   // DSP R2 ASE.
3298cbf5cb7Schristos   AFL_ASE_DSPR2 = 0x00000002,
3308cbf5cb7Schristos   // Enhanced VA Scheme.
3318cbf5cb7Schristos   AFL_ASE_EVA = 0x00000004,
3328cbf5cb7Schristos   // MCU (MicroController) ASE.
3338cbf5cb7Schristos   AFL_ASE_MCU = 0x00000008,
3348cbf5cb7Schristos   // MDMX ASE.
3358cbf5cb7Schristos   AFL_ASE_MDMX = 0x00000010,
3368cbf5cb7Schristos   // MIPS-3D ASE.
3378cbf5cb7Schristos   AFL_ASE_MIPS3D = 0x00000020,
3388cbf5cb7Schristos   // MT ASE.
3398cbf5cb7Schristos   AFL_ASE_MT  = 0x00000040,
3408cbf5cb7Schristos   // SmartMIPS ASE.
3418cbf5cb7Schristos   AFL_ASE_SMARTMIPS = 0x00000080,
3428cbf5cb7Schristos   // VZ ASE.
3438cbf5cb7Schristos   AFL_ASE_VIRT = 0x00000100,
3448cbf5cb7Schristos   // MSA ASE.
3458cbf5cb7Schristos   AFL_ASE_MSA = 0x00000200,
3468cbf5cb7Schristos   // MIPS16 ASE.
3478cbf5cb7Schristos   AFL_ASE_MIPS16 = 0x00000400,
3488cbf5cb7Schristos   // MICROMIPS ASE.
3498cbf5cb7Schristos   AFL_ASE_MICROMIPS = 0x00000800,
3508cbf5cb7Schristos   // XPA ASE.
3516f4ced0bSchristos   AFL_ASE_XPA = 0x00001000,
3526f4ced0bSchristos   // Loongson EXT ASE.
3536f4ced0bSchristos   AFL_ASE_LOONGSON_EXT = 0x00002000
3548cbf5cb7Schristos };
3558cbf5cb7Schristos 
3568cbf5cb7Schristos // Values for the isa_ext word of an ABI flags structure.
3578cbf5cb7Schristos enum
3588cbf5cb7Schristos {
3598cbf5cb7Schristos   // RMI Xlr instruction.
3608cbf5cb7Schristos   AFL_EXT_XLR = 1,
3618cbf5cb7Schristos   // Cavium Networks Octeon2.
3628cbf5cb7Schristos   AFL_EXT_OCTEON2 = 2,
3638cbf5cb7Schristos   // Cavium Networks OcteonP.
3648cbf5cb7Schristos   AFL_EXT_OCTEONP = 3,
3658cbf5cb7Schristos   // Loongson 3A.
3668cbf5cb7Schristos   AFL_EXT_LOONGSON_3A = 4,
3678cbf5cb7Schristos   // Cavium Networks Octeon.
3688cbf5cb7Schristos   AFL_EXT_OCTEON = 5,
3698cbf5cb7Schristos   // MIPS R5900 instruction.
3708cbf5cb7Schristos   AFL_EXT_5900 = 6,
3718cbf5cb7Schristos   // MIPS R4650 instruction.
3728cbf5cb7Schristos   AFL_EXT_4650 = 7,
3738cbf5cb7Schristos   // LSI R4010 instruction.
3748cbf5cb7Schristos   AFL_EXT_4010 = 8,
3758cbf5cb7Schristos   // NEC VR4100 instruction.
3768cbf5cb7Schristos   AFL_EXT_4100 = 9,
3778cbf5cb7Schristos   // Toshiba R3900 instruction.
3788cbf5cb7Schristos   AFL_EXT_3900 = 10,
3798cbf5cb7Schristos   // MIPS R10000 instruction.
3808cbf5cb7Schristos   AFL_EXT_10000 = 11,
3818cbf5cb7Schristos   // Broadcom SB-1 instruction.
3828cbf5cb7Schristos   AFL_EXT_SB1 = 12,
3838cbf5cb7Schristos   // NEC VR4111/VR4181 instruction.
3848cbf5cb7Schristos   AFL_EXT_4111 = 13,
3858cbf5cb7Schristos   // NEC VR4120 instruction.
3868cbf5cb7Schristos   AFL_EXT_4120 = 14,
3878cbf5cb7Schristos   // NEC VR5400 instruction.
3888cbf5cb7Schristos   AFL_EXT_5400 = 15,
3898cbf5cb7Schristos   // NEC VR5500 instruction.
3908cbf5cb7Schristos   AFL_EXT_5500 = 16,
3918cbf5cb7Schristos   // ST Microelectronics Loongson 2E.
3928cbf5cb7Schristos   AFL_EXT_LOONGSON_2E = 17,
3938cbf5cb7Schristos   // ST Microelectronics Loongson 2F.
3948cbf5cb7Schristos   AFL_EXT_LOONGSON_2F = 18,
3958cbf5cb7Schristos   // Cavium Networks Octeon3.
3968cbf5cb7Schristos   AFL_EXT_OCTEON3 = 19
3978cbf5cb7Schristos };
3988cbf5cb7Schristos 
3998cbf5cb7Schristos // Masks for the flags1 word of an ABI flags structure.
4008cbf5cb7Schristos enum
4018cbf5cb7Schristos {
4028cbf5cb7Schristos   // Uses odd single-precision registers.
4038cbf5cb7Schristos   AFL_FLAGS1_ODDSPREG = 1
4048cbf5cb7Schristos };
4058cbf5cb7Schristos 
4068cbf5cb7Schristos // Object attribute tags.
4078cbf5cb7Schristos enum
4088cbf5cb7Schristos {
4098cbf5cb7Schristos   // 0-3 are generic.
4108cbf5cb7Schristos   // Floating-point ABI used by this object file.
4118cbf5cb7Schristos   Tag_GNU_MIPS_ABI_FP = 4,
4128cbf5cb7Schristos   // MSA ABI used by this object file.
4138cbf5cb7Schristos   Tag_GNU_MIPS_ABI_MSA = 8
4148cbf5cb7Schristos };
4158cbf5cb7Schristos 
4168cbf5cb7Schristos // Object attribute values.
4178cbf5cb7Schristos enum
4188cbf5cb7Schristos {
4198cbf5cb7Schristos   // Values defined for Tag_GNU_MIPS_ABI_FP.
4208cbf5cb7Schristos   // Not tagged or not using any ABIs affected by the differences.
4218cbf5cb7Schristos   Val_GNU_MIPS_ABI_FP_ANY = 0,
4228cbf5cb7Schristos   // Using hard-float -mdouble-float.
4238cbf5cb7Schristos   Val_GNU_MIPS_ABI_FP_DOUBLE = 1,
4248cbf5cb7Schristos   // Using hard-float -msingle-float.
4258cbf5cb7Schristos   Val_GNU_MIPS_ABI_FP_SINGLE = 2,
4268cbf5cb7Schristos   // Using soft-float.
4278cbf5cb7Schristos   Val_GNU_MIPS_ABI_FP_SOFT = 3,
4288cbf5cb7Schristos   // Using -mips32r2 -mfp64.
4298cbf5cb7Schristos   Val_GNU_MIPS_ABI_FP_OLD_64 = 4,
4308cbf5cb7Schristos   // Using -mfpxx
4318cbf5cb7Schristos   Val_GNU_MIPS_ABI_FP_XX = 5,
4328cbf5cb7Schristos   // Using -mips32r2 -mfp64.
4338cbf5cb7Schristos   Val_GNU_MIPS_ABI_FP_64 = 6,
4348cbf5cb7Schristos   // Using -mips32r2 -mfp64 -mno-odd-spreg.
4358cbf5cb7Schristos   Val_GNU_MIPS_ABI_FP_64A = 7,
4368cbf5cb7Schristos   // This is reserved for backward-compatibility with an earlier
4378cbf5cb7Schristos   // implementation of the MIPS NaN2008 functionality.
4388cbf5cb7Schristos   Val_GNU_MIPS_ABI_FP_NAN2008 = 8,
4398cbf5cb7Schristos 
4408cbf5cb7Schristos   // Values defined for Tag_GNU_MIPS_ABI_MSA.
4418cbf5cb7Schristos   // Not tagged or not using any ABIs affected by the differences.
4428cbf5cb7Schristos   Val_GNU_MIPS_ABI_MSA_ANY = 0,
4438cbf5cb7Schristos   // Using 128-bit MSA.
4448cbf5cb7Schristos   Val_GNU_MIPS_ABI_MSA_128 = 1
4458cbf5cb7Schristos };
4468cbf5cb7Schristos 
447883529b6Schristos enum
448883529b6Schristos {
449883529b6Schristos   // Mask to extract ABI version, not really a flag value.
450883529b6Schristos   EF_MIPS_ABI = 0x0000F000,
451883529b6Schristos 
452883529b6Schristos   // The original o32 abi.
453*cb63e24eSchristos   EF_MIPS_ABI_O32 = 0x00001000,
454883529b6Schristos   // O32 extended to work on 64 bit architectures
455*cb63e24eSchristos   EF_MIPS_ABI_O64 = 0x00002000,
456883529b6Schristos   // EABI in 32 bit mode
457*cb63e24eSchristos   EF_MIPS_ABI_EABI32 = 0x00003000,
458883529b6Schristos   // EABI in 64 bit mode
459*cb63e24eSchristos   EF_MIPS_ABI_EABI64 = 0x00004000,
460*cb63e24eSchristos 
461*cb63e24eSchristos   // In order to support backwards compatibility we also
462*cb63e24eSchristos   // define the old versions of some of these constants.
463*cb63e24eSchristos   E_MIPS_ABI_O32    = EF_MIPS_ABI_O32,
464*cb63e24eSchristos   E_MIPS_ABI_O64    = EF_MIPS_ABI_O64,
465*cb63e24eSchristos   E_MIPS_ABI_EABI32 = EF_MIPS_ABI_EABI32,
466*cb63e24eSchristos   E_MIPS_ABI_EABI64 = EF_MIPS_ABI_EABI64,
467883529b6Schristos };
468883529b6Schristos 
469883529b6Schristos // Dynamic section MIPS flags
470883529b6Schristos enum
471883529b6Schristos {
472883529b6Schristos   // None
473883529b6Schristos   RHF_NONE = 0x00000000,
474883529b6Schristos   // Use shortcut pointers
475883529b6Schristos   RHF_QUICKSTART = 0x00000001,
476883529b6Schristos   // Hash size not power of two
477883529b6Schristos   RHF_NOTPOT = 0x00000002,
478883529b6Schristos   // Ignore LD_LIBRARY_PATH
479883529b6Schristos   RHF_NO_LIBRARY_REPLACEMENT = 0x00000004
480883529b6Schristos };
481883529b6Schristos 
482883529b6Schristos // Special values for the st_other field in the symbol table.
483883529b6Schristos enum
484883529b6Schristos {
485883529b6Schristos   // Two topmost bits denote the MIPS ISA for .text symbols:
486883529b6Schristos   // + 00 -- standard MIPS code,
487883529b6Schristos   // + 10 -- microMIPS code,
488883529b6Schristos   // + 11 -- MIPS16 code; requires the following two bits to be set too.
489883529b6Schristos   // Note that one of the MIPS16 bits overlaps with STO_MIPS_PIC.
490883529b6Schristos   STO_MIPS_ISA = 0xc0,
491883529b6Schristos 
4929573673dSchristos   // The mask spanning the rest of MIPS psABI flags.  At most one is expected
4939573673dSchristos   // to be set except for STO_MIPS16.
4949573673dSchristos   STO_MIPS_FLAGS = ~(STO_MIPS_ISA | 0x3),
4959573673dSchristos 
496883529b6Schristos   // The MIPS psABI was updated in 2008 with support for PLTs and copy
497883529b6Schristos   // relocs.  There are therefore two types of nonzero SHN_UNDEF functions:
498883529b6Schristos   // PLT entries and traditional MIPS lazy binding stubs.  We mark the former
499883529b6Schristos   // with STO_MIPS_PLT to distinguish them from the latter.
500883529b6Schristos   STO_MIPS_PLT = 0x8,
501883529b6Schristos 
502883529b6Schristos   // This value is used to mark PIC functions in an object that mixes
503883529b6Schristos   // PIC and non-PIC.  Note that this bit overlaps with STO_MIPS16,
504883529b6Schristos   // although MIPS16 symbols are never considered to be MIPS_PIC.
505883529b6Schristos   STO_MIPS_PIC = 0x20,
506883529b6Schristos 
507883529b6Schristos   // This value is used for a mips16 .text symbol.
508883529b6Schristos   STO_MIPS16 = 0xf0,
509883529b6Schristos 
510883529b6Schristos   // This value is used for a microMIPS .text symbol.  To distinguish from
511883529b6Schristos   // STO_MIPS16, we set top two bits to be 10 to denote STO_MICROMIPS.  The
512883529b6Schristos   // mask is STO_MIPS_ISA.
513883529b6Schristos   STO_MICROMIPS  = 0x80
514883529b6Schristos };
515883529b6Schristos 
516883529b6Schristos // Values for base offsets for thread-local storage
517883529b6Schristos enum
518883529b6Schristos {
519883529b6Schristos   TP_OFFSET = 0x7000,
520883529b6Schristos   DTP_OFFSET = 0x8000
521883529b6Schristos };
522883529b6Schristos 
5239573673dSchristos 
5249573673dSchristos bool
elf_st_is_mips16(unsigned char st_other)5259573673dSchristos elf_st_is_mips16(unsigned char st_other)
5269573673dSchristos { return (st_other & elfcpp::STO_MIPS16) == elfcpp::STO_MIPS16; }
5279573673dSchristos 
5289573673dSchristos bool
elf_st_is_micromips(unsigned char st_other)5299573673dSchristos elf_st_is_micromips(unsigned char st_other)
5309573673dSchristos { return (st_other & elfcpp::STO_MIPS_ISA) == elfcpp::STO_MICROMIPS; }
5319573673dSchristos 
5329573673dSchristos // Whether the ABI is N32.
5339573673dSchristos bool
abi_n32(elfcpp::Elf_Word e_flags)5349573673dSchristos abi_n32(elfcpp::Elf_Word e_flags)
5359573673dSchristos { return (e_flags & elfcpp::EF_MIPS_ABI2) != 0; }
5369573673dSchristos 
5378cbf5cb7Schristos // Whether the ISA is R6.
5389573673dSchristos bool
r6_isa(elfcpp::Elf_Word e_flags)5398cbf5cb7Schristos r6_isa(elfcpp::Elf_Word e_flags)
5408cbf5cb7Schristos {
541*cb63e24eSchristos   return ((e_flags & elfcpp::EF_MIPS_ARCH) == elfcpp::EF_MIPS_ARCH_32R6)
542*cb63e24eSchristos            || ((e_flags & elfcpp::EF_MIPS_ARCH) == elfcpp::EF_MIPS_ARCH_64R6);
5438cbf5cb7Schristos }
5449573673dSchristos 
5459573673dSchristos // Whether the file has microMIPS code.
5469573673dSchristos bool
is_micromips(elfcpp::Elf_Word e_flags)5479573673dSchristos is_micromips(elfcpp::Elf_Word e_flags)
5489573673dSchristos { return (e_flags & elfcpp::EF_MIPS_ARCH_ASE_MICROMIPS) != 0; }
5499573673dSchristos 
5509573673dSchristos // Values which may appear in the kind field of an Elf_Options structure.
5519573673dSchristos enum
5529573673dSchristos {
5539573673dSchristos   // Undefined.
5549573673dSchristos   ODK_NULL = 0,
5559573673dSchristos   // Register usage and GP value.
5569573673dSchristos   ODK_REGINFO = 1,
5579573673dSchristos   // Exception processing information.
5589573673dSchristos   ODK_EXCEPTIONS = 2,
5599573673dSchristos   // Section padding information.
5609573673dSchristos   ODK_PAD = 3,
5619573673dSchristos   // Hardware workarounds performed.
5629573673dSchristos   ODK_HWPATCH = 4,
5639573673dSchristos   // Fill value used by the linker.
5649573673dSchristos   ODK_FILL = 5,
5659573673dSchristos   // Reserved space for desktop tools.
5669573673dSchristos   ODK_TAGS = 6,
5679573673dSchristos   // Hardware workarounds, AND bits when merging.
5689573673dSchristos   ODK_HWAND = 7,
5699573673dSchristos   // Hardware workarounds, OR bits when merging.
5709573673dSchristos   ODK_HWOR = 8,
5719573673dSchristos   // GP group to use for text/data sections.
5729573673dSchristos   ODK_GP_GROUP = 9,
5739573673dSchristos   // ID information.
5749573673dSchristos   ODK_IDENT = 10
5759573673dSchristos };
5769573673dSchristos 
577883529b6Schristos } // End namespace elfcpp.
578883529b6Schristos 
579883529b6Schristos #endif // !defined(ELFCPP_MIPS_H)
580