175fd0b74Schristos // mips.h -- ELF definitions specific to EM_MIPS -*- C++ -*-
275fd0b74Schristos
3*e992f068Schristos // Copyright (C) 2012-2022 Free Software Foundation, Inc.
475fd0b74Schristos // Written by Sasa Stankovic <sasa.stankovic@imgtec.com>
575fd0b74Schristos // and Aleksandar Simeonov <aleksandar.simeonov@rt-rk.com>.
675fd0b74Schristos
775fd0b74Schristos // This file is part of elfcpp.
875fd0b74Schristos
975fd0b74Schristos // This program is free software; you can redistribute it and/or
1075fd0b74Schristos // modify it under the terms of the GNU Library General Public License
1175fd0b74Schristos // as published by the Free Software Foundation; either version 2, or
1275fd0b74Schristos // (at your option) any later version.
1375fd0b74Schristos
1475fd0b74Schristos // In addition to the permissions in the GNU Library General Public
1575fd0b74Schristos // License, the Free Software Foundation gives you unlimited
1675fd0b74Schristos // permission to link the compiled version of this file into
1775fd0b74Schristos // combinations with other programs, and to distribute those
1875fd0b74Schristos // combinations without any restriction coming from the use of this
1975fd0b74Schristos // file. (The Library Public License restrictions do apply in other
2075fd0b74Schristos // respects; for example, they cover modification of the file, and
2175fd0b74Schristos /// distribution when not linked into a combined executable.)
2275fd0b74Schristos
2375fd0b74Schristos // This program is distributed in the hope that it will be useful, but
2475fd0b74Schristos // WITHOUT ANY WARRANTY; without even the implied warranty of
2575fd0b74Schristos // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2675fd0b74Schristos // Library General Public License for more details.
2775fd0b74Schristos
2875fd0b74Schristos // You should have received a copy of the GNU Library General Public
2975fd0b74Schristos // License along with this program; if not, write to the Free Software
3075fd0b74Schristos // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
3175fd0b74Schristos // 02110-1301, USA.
3275fd0b74Schristos
3375fd0b74Schristos #ifndef ELFCPP_MIPS_H
3475fd0b74Schristos #define ELFCPP_MIPS_H
3575fd0b74Schristos
3675fd0b74Schristos // Documentation for the MIPS relocs is taken from
3775fd0b74Schristos // http://math-atlas.sourceforge.net/devel/assembly/mipsabi32.pdf
3875fd0b74Schristos
3975fd0b74Schristos namespace elfcpp
4075fd0b74Schristos {
4175fd0b74Schristos
4275fd0b74Schristos //
4375fd0b74Schristos // MIPS Relocation Codes
4475fd0b74Schristos //
4575fd0b74Schristos
4675fd0b74Schristos enum
4775fd0b74Schristos {
4875fd0b74Schristos R_MIPS_NONE = 0,
4975fd0b74Schristos R_MIPS_16 = 1,
5075fd0b74Schristos R_MIPS_32 = 2, // In Elf 64: alias R_MIPS_ADD
5175fd0b74Schristos R_MIPS_REL32 = 3, // In Elf 64: alias R_MIPS_REL
5275fd0b74Schristos R_MIPS_26 = 4,
5375fd0b74Schristos R_MIPS_HI16 = 5,
5475fd0b74Schristos R_MIPS_LO16 = 6,
5575fd0b74Schristos R_MIPS_GPREL16 = 7, // In Elf 64: alias R_MIPS_GPREL
5675fd0b74Schristos R_MIPS_LITERAL = 8,
5775fd0b74Schristos R_MIPS_GOT16 = 9, // In Elf 64: alias R_MIPS_GOT
5875fd0b74Schristos R_MIPS_PC16 = 10,
5975fd0b74Schristos R_MIPS_CALL16 = 11, // In Elf 64: alias R_MIPS_CALL
6075fd0b74Schristos R_MIPS_GPREL32 = 12,
6175fd0b74Schristos R_MIPS_UNUSED1 = 13,
6275fd0b74Schristos R_MIPS_UNUSED2 = 14,
6375fd0b74Schristos R_MIPS_UNUSED3 = 15,
6475fd0b74Schristos R_MIPS_SHIFT5 = 16,
6575fd0b74Schristos R_MIPS_SHIFT6 = 17,
6675fd0b74Schristos R_MIPS_64 = 18,
6775fd0b74Schristos R_MIPS_GOT_DISP = 19,
6875fd0b74Schristos R_MIPS_GOT_PAGE = 20,
6975fd0b74Schristos R_MIPS_GOT_OFST = 21,
7075fd0b74Schristos R_MIPS_GOT_HI16 = 22,
7175fd0b74Schristos R_MIPS_GOT_LO16 = 23,
7275fd0b74Schristos R_MIPS_SUB = 24,
7375fd0b74Schristos R_MIPS_INSERT_A = 25,
7475fd0b74Schristos R_MIPS_INSERT_B = 26,
7575fd0b74Schristos R_MIPS_DELETE = 27,
7675fd0b74Schristos R_MIPS_HIGHER = 28,
7775fd0b74Schristos R_MIPS_HIGHEST = 29,
7875fd0b74Schristos R_MIPS_CALL_HI16 = 30,
7975fd0b74Schristos R_MIPS_CALL_LO16 = 31,
8075fd0b74Schristos R_MIPS_SCN_DISP = 32,
8175fd0b74Schristos R_MIPS_REL16 = 33,
8275fd0b74Schristos R_MIPS_ADD_IMMEDIATE = 34,
8375fd0b74Schristos R_MIPS_PJUMP = 35,
8475fd0b74Schristos R_MIPS_RELGOT = 36,
8575fd0b74Schristos R_MIPS_JALR = 37,
8675fd0b74Schristos // TLS relocations.
8775fd0b74Schristos R_MIPS_TLS_DTPMOD32 = 38,
8875fd0b74Schristos R_MIPS_TLS_DTPREL32 = 39,
8975fd0b74Schristos R_MIPS_TLS_DTPMOD64 = 40,
9075fd0b74Schristos R_MIPS_TLS_DTPREL64 = 41,
9175fd0b74Schristos R_MIPS_TLS_GD = 42,
9275fd0b74Schristos R_MIPS_TLS_LDM = 43,
9375fd0b74Schristos R_MIPS_TLS_DTPREL_HI16 = 44,
9475fd0b74Schristos R_MIPS_TLS_DTPREL_LO16 = 45,
9575fd0b74Schristos R_MIPS_TLS_GOTTPREL = 46,
9675fd0b74Schristos R_MIPS_TLS_TPREL32 = 47,
9775fd0b74Schristos R_MIPS_TLS_TPREL64 = 48,
9875fd0b74Schristos R_MIPS_TLS_TPREL_HI16 = 49,
9975fd0b74Schristos R_MIPS_TLS_TPREL_LO16 = 50,
10075fd0b74Schristos R_MIPS_GLOB_DAT = 51,
10175fd0b74Schristos R_MIPS_PC21_S2 = 60,
10275fd0b74Schristos R_MIPS_PC26_S2 = 61,
10375fd0b74Schristos R_MIPS_PC18_S3 = 62,
10475fd0b74Schristos R_MIPS_PC19_S2 = 63,
10575fd0b74Schristos R_MIPS_PCHI16 = 64,
10675fd0b74Schristos R_MIPS_PCLO16 = 65,
10775fd0b74Schristos // These relocs are used for the mips16.
10875fd0b74Schristos R_MIPS16_26 = 100,
10975fd0b74Schristos R_MIPS16_GPREL = 101,
11075fd0b74Schristos R_MIPS16_GOT16 = 102,
11175fd0b74Schristos R_MIPS16_CALL16 = 103,
11275fd0b74Schristos R_MIPS16_HI16 = 104,
11375fd0b74Schristos R_MIPS16_LO16 = 105,
11475fd0b74Schristos R_MIPS16_TLS_GD = 106,
11575fd0b74Schristos R_MIPS16_TLS_LDM = 107,
11675fd0b74Schristos R_MIPS16_TLS_DTPREL_HI16 = 108,
11775fd0b74Schristos R_MIPS16_TLS_DTPREL_LO16 = 109,
11875fd0b74Schristos R_MIPS16_TLS_GOTTPREL = 110,
11975fd0b74Schristos R_MIPS16_TLS_TPREL_HI16 = 111,
12075fd0b74Schristos R_MIPS16_TLS_TPREL_LO16 = 112,
12175fd0b74Schristos
12275fd0b74Schristos R_MIPS_COPY = 126,
12375fd0b74Schristos R_MIPS_JUMP_SLOT = 127,
12475fd0b74Schristos
12575fd0b74Schristos // These relocations are specific to microMIPS.
12675fd0b74Schristos R_MICROMIPS_26_S1 = 133,
12775fd0b74Schristos R_MICROMIPS_HI16 = 134,
12875fd0b74Schristos R_MICROMIPS_LO16 = 135,
12975fd0b74Schristos R_MICROMIPS_GPREL16 = 136, // In Elf 64: alias R_MICROMIPS_GPREL
13075fd0b74Schristos R_MICROMIPS_LITERAL = 137,
13175fd0b74Schristos R_MICROMIPS_GOT16 = 138, // In Elf 64: alias R_MICROMIPS_GOT
13275fd0b74Schristos R_MICROMIPS_PC7_S1 = 139,
13375fd0b74Schristos R_MICROMIPS_PC10_S1 = 140,
13475fd0b74Schristos R_MICROMIPS_PC16_S1 = 141,
13575fd0b74Schristos R_MICROMIPS_CALL16 = 142, // In Elf 64: alias R_MICROMIPS_CALL
13675fd0b74Schristos R_MICROMIPS_GOT_DISP = 145,
13775fd0b74Schristos R_MICROMIPS_GOT_PAGE = 146,
13875fd0b74Schristos R_MICROMIPS_GOT_OFST = 147,
13975fd0b74Schristos R_MICROMIPS_GOT_HI16 = 148,
14075fd0b74Schristos R_MICROMIPS_GOT_LO16 = 149,
14175fd0b74Schristos R_MICROMIPS_SUB = 150,
14275fd0b74Schristos R_MICROMIPS_HIGHER = 151,
14375fd0b74Schristos R_MICROMIPS_HIGHEST = 152,
14475fd0b74Schristos R_MICROMIPS_CALL_HI16 = 153,
14575fd0b74Schristos R_MICROMIPS_CALL_LO16 = 154,
14675fd0b74Schristos R_MICROMIPS_SCN_DISP = 155,
14775fd0b74Schristos R_MICROMIPS_JALR = 156,
14875fd0b74Schristos R_MICROMIPS_HI0_LO16 = 157,
14975fd0b74Schristos // TLS relocations.
15075fd0b74Schristos R_MICROMIPS_TLS_GD = 162,
15175fd0b74Schristos R_MICROMIPS_TLS_LDM = 163,
15275fd0b74Schristos R_MICROMIPS_TLS_DTPREL_HI16 = 164,
15375fd0b74Schristos R_MICROMIPS_TLS_DTPREL_LO16 = 165,
15475fd0b74Schristos R_MICROMIPS_TLS_GOTTPREL = 166,
15575fd0b74Schristos R_MICROMIPS_TLS_TPREL_HI16 = 169,
15675fd0b74Schristos R_MICROMIPS_TLS_TPREL_LO16 = 170,
15775fd0b74Schristos // microMIPS GP- and PC-relative relocations.
15875fd0b74Schristos R_MICROMIPS_GPREL7_S2 = 172,
15975fd0b74Schristos R_MICROMIPS_PC23_S2 = 173,
16075fd0b74Schristos
16175fd0b74Schristos // This was a GNU extension used by embedded-PIC. It was co-opted by
16275fd0b74Schristos // mips-linux for exception-handling data. GCC stopped using it in
16375fd0b74Schristos // May, 2004, then started using it again for compact unwind tables.
16475fd0b74Schristos R_MIPS_PC32 = 248,
16575fd0b74Schristos R_MIPS_EH = 249,
16675fd0b74Schristos // This relocation is used internally by gas.
16775fd0b74Schristos R_MIPS_GNU_REL16_S2 = 250,
16875fd0b74Schristos // These are GNU extensions to enable C++ vtable garbage collection.
16975fd0b74Schristos R_MIPS_GNU_VTINHERIT = 253,
17075fd0b74Schristos R_MIPS_GNU_VTENTRY = 254
17175fd0b74Schristos };
17275fd0b74Schristos
17375fd0b74Schristos // Processor specific flags for the ELF header e_flags field.
17475fd0b74Schristos enum
17575fd0b74Schristos {
17675fd0b74Schristos // At least one .noreorder directive appears in the source.
17775fd0b74Schristos EF_MIPS_NOREORDER = 0x00000001,
17875fd0b74Schristos // File contains position independent code.
17975fd0b74Schristos EF_MIPS_PIC = 0x00000002,
18075fd0b74Schristos // Code in file uses the standard calling sequence for calling
18175fd0b74Schristos // position independent code.
18275fd0b74Schristos EF_MIPS_CPIC = 0x00000004,
18375fd0b74Schristos // ??? Unknown flag, set in IRIX 6's BSDdup2.o in libbsd.a.
18475fd0b74Schristos EF_MIPS_XGOT = 0x00000008,
18575fd0b74Schristos // Code in file uses UCODE (obsolete)
18675fd0b74Schristos EF_MIPS_UCODE = 0x00000010,
18775fd0b74Schristos // Code in file uses new ABI (-n32 on Irix 6).
18875fd0b74Schristos EF_MIPS_ABI2 = 0x00000020,
18975fd0b74Schristos // Process the .MIPS.options section first by ld
19075fd0b74Schristos EF_MIPS_OPTIONS_FIRST = 0x00000080,
19175fd0b74Schristos // Architectural Extensions used by this file
19275fd0b74Schristos EF_MIPS_ARCH_ASE = 0x0f000000,
19375fd0b74Schristos // Use MDMX multimedia extensions
19475fd0b74Schristos EF_MIPS_ARCH_ASE_MDMX = 0x08000000,
19575fd0b74Schristos // Use MIPS-16 ISA extensions
19675fd0b74Schristos EF_MIPS_ARCH_ASE_M16 = 0x04000000,
19775fd0b74Schristos // Use MICROMIPS ISA extensions.
19875fd0b74Schristos EF_MIPS_ARCH_ASE_MICROMIPS = 0x02000000,
19975fd0b74Schristos // Indicates code compiled for a 64-bit machine in 32-bit mode.
20075fd0b74Schristos // (regs are 32-bits wide.)
20175fd0b74Schristos EF_MIPS_32BITMODE = 0x00000100,
20275fd0b74Schristos // 32-bit machine but FP registers are 64 bit (-mfp64).
20375fd0b74Schristos EF_MIPS_FP64 = 0x00000200,
20475fd0b74Schristos /// Code in file uses the IEEE 754-2008 NaN encoding convention.
20575fd0b74Schristos EF_MIPS_NAN2008 = 0x00000400,
20675fd0b74Schristos // MIPS dynamic
20775fd0b74Schristos EF_MIPS_DYNAMIC = 0x40
20875fd0b74Schristos };
20975fd0b74Schristos
21075fd0b74Schristos // Machine variant if we know it. This field was invented at Cygnus,
21175fd0b74Schristos // but it is hoped that other vendors will adopt it. If some standard
21275fd0b74Schristos // is developed, this code should be changed to follow it.
21375fd0b74Schristos enum
21475fd0b74Schristos {
21575fd0b74Schristos EF_MIPS_MACH = 0x00FF0000,
21675fd0b74Schristos
21775fd0b74Schristos // Cygnus is choosing values between 80 and 9F;
21875fd0b74Schristos // 00 - 7F should be left for a future standard;
21975fd0b74Schristos // the rest are open.
22075fd0b74Schristos
22175fd0b74Schristos E_MIPS_MACH_3900 = 0x00810000,
22275fd0b74Schristos E_MIPS_MACH_4010 = 0x00820000,
22375fd0b74Schristos E_MIPS_MACH_4100 = 0x00830000,
22475fd0b74Schristos E_MIPS_MACH_4650 = 0x00850000,
22575fd0b74Schristos E_MIPS_MACH_4120 = 0x00870000,
22675fd0b74Schristos E_MIPS_MACH_4111 = 0x00880000,
22775fd0b74Schristos E_MIPS_MACH_SB1 = 0x008a0000,
22875fd0b74Schristos E_MIPS_MACH_OCTEON = 0x008b0000,
22975fd0b74Schristos E_MIPS_MACH_XLR = 0x008c0000,
23075fd0b74Schristos E_MIPS_MACH_OCTEON2 = 0x008d0000,
23175fd0b74Schristos E_MIPS_MACH_OCTEON3 = 0x008e0000,
23275fd0b74Schristos E_MIPS_MACH_5400 = 0x00910000,
23375fd0b74Schristos E_MIPS_MACH_5900 = 0x00920000,
23475fd0b74Schristos E_MIPS_MACH_5500 = 0x00980000,
23575fd0b74Schristos E_MIPS_MACH_9000 = 0x00990000,
23675fd0b74Schristos E_MIPS_MACH_LS2E = 0x00A00000,
23775fd0b74Schristos E_MIPS_MACH_LS2F = 0x00A10000,
238012573ebSchristos E_MIPS_MACH_GS464 = 0x00A20000,
239012573ebSchristos E_MIPS_MACH_GS464E = 0x00A30000,
240012573ebSchristos E_MIPS_MACH_GS264E = 0x00A40000,
24175fd0b74Schristos };
24275fd0b74Schristos
24375fd0b74Schristos // MIPS architecture
24475fd0b74Schristos enum
24575fd0b74Schristos {
24675fd0b74Schristos // Four bit MIPS architecture field.
24775fd0b74Schristos EF_MIPS_ARCH = 0xf0000000,
24875fd0b74Schristos // -mips1 code.
24975fd0b74Schristos E_MIPS_ARCH_1 = 0x00000000,
25075fd0b74Schristos // -mips2 code.
25175fd0b74Schristos E_MIPS_ARCH_2 = 0x10000000,
25275fd0b74Schristos // -mips3 code.
25375fd0b74Schristos E_MIPS_ARCH_3 = 0x20000000,
25475fd0b74Schristos // -mips4 code.
25575fd0b74Schristos E_MIPS_ARCH_4 = 0x30000000,
25675fd0b74Schristos // -mips5 code.
25775fd0b74Schristos E_MIPS_ARCH_5 = 0x40000000,
25875fd0b74Schristos // -mips32 code.
25975fd0b74Schristos E_MIPS_ARCH_32 = 0x50000000,
26075fd0b74Schristos // -mips64 code.
26175fd0b74Schristos E_MIPS_ARCH_64 = 0x60000000,
26275fd0b74Schristos // -mips32r2 code.
26375fd0b74Schristos E_MIPS_ARCH_32R2 = 0x70000000,
26475fd0b74Schristos // -mips64r2 code.
26575fd0b74Schristos E_MIPS_ARCH_64R2 = 0x80000000,
26675fd0b74Schristos // -mips32r6 code.
26775fd0b74Schristos E_MIPS_ARCH_32R6 = 0x90000000,
26875fd0b74Schristos // -mips64r6 code.
26975fd0b74Schristos E_MIPS_ARCH_64R6 = 0xa0000000,
27075fd0b74Schristos };
27175fd0b74Schristos
27275fd0b74Schristos // Values for the xxx_size bytes of an ABI flags structure.
27375fd0b74Schristos enum
27475fd0b74Schristos {
27575fd0b74Schristos // No registers.
27675fd0b74Schristos AFL_REG_NONE = 0x00,
27775fd0b74Schristos // 32-bit registers.
27875fd0b74Schristos AFL_REG_32 = 0x01,
27975fd0b74Schristos // 64-bit registers.
28075fd0b74Schristos AFL_REG_64 = 0x02,
28175fd0b74Schristos // 128-bit registers.
28275fd0b74Schristos AFL_REG_128 = 0x03
28375fd0b74Schristos };
28475fd0b74Schristos
28575fd0b74Schristos // Masks for the ases word of an ABI flags structure.
28675fd0b74Schristos enum
28775fd0b74Schristos {
28875fd0b74Schristos // DSP ASE.
28975fd0b74Schristos AFL_ASE_DSP = 0x00000001,
29075fd0b74Schristos // DSP R2 ASE.
29175fd0b74Schristos AFL_ASE_DSPR2 = 0x00000002,
29275fd0b74Schristos // Enhanced VA Scheme.
29375fd0b74Schristos AFL_ASE_EVA = 0x00000004,
29475fd0b74Schristos // MCU (MicroController) ASE.
29575fd0b74Schristos AFL_ASE_MCU = 0x00000008,
29675fd0b74Schristos // MDMX ASE.
29775fd0b74Schristos AFL_ASE_MDMX = 0x00000010,
29875fd0b74Schristos // MIPS-3D ASE.
29975fd0b74Schristos AFL_ASE_MIPS3D = 0x00000020,
30075fd0b74Schristos // MT ASE.
30175fd0b74Schristos AFL_ASE_MT = 0x00000040,
30275fd0b74Schristos // SmartMIPS ASE.
30375fd0b74Schristos AFL_ASE_SMARTMIPS = 0x00000080,
30475fd0b74Schristos // VZ ASE.
30575fd0b74Schristos AFL_ASE_VIRT = 0x00000100,
30675fd0b74Schristos // MSA ASE.
30775fd0b74Schristos AFL_ASE_MSA = 0x00000200,
30875fd0b74Schristos // MIPS16 ASE.
30975fd0b74Schristos AFL_ASE_MIPS16 = 0x00000400,
31075fd0b74Schristos // MICROMIPS ASE.
31175fd0b74Schristos AFL_ASE_MICROMIPS = 0x00000800,
31275fd0b74Schristos // XPA ASE.
313012573ebSchristos AFL_ASE_XPA = 0x00001000,
314012573ebSchristos // Loongson EXT ASE.
315012573ebSchristos AFL_ASE_LOONGSON_EXT = 0x00002000
31675fd0b74Schristos };
31775fd0b74Schristos
31875fd0b74Schristos // Values for the isa_ext word of an ABI flags structure.
31975fd0b74Schristos enum
32075fd0b74Schristos {
32175fd0b74Schristos // RMI Xlr instruction.
32275fd0b74Schristos AFL_EXT_XLR = 1,
32375fd0b74Schristos // Cavium Networks Octeon2.
32475fd0b74Schristos AFL_EXT_OCTEON2 = 2,
32575fd0b74Schristos // Cavium Networks OcteonP.
32675fd0b74Schristos AFL_EXT_OCTEONP = 3,
32775fd0b74Schristos // Loongson 3A.
32875fd0b74Schristos AFL_EXT_LOONGSON_3A = 4,
32975fd0b74Schristos // Cavium Networks Octeon.
33075fd0b74Schristos AFL_EXT_OCTEON = 5,
33175fd0b74Schristos // MIPS R5900 instruction.
33275fd0b74Schristos AFL_EXT_5900 = 6,
33375fd0b74Schristos // MIPS R4650 instruction.
33475fd0b74Schristos AFL_EXT_4650 = 7,
33575fd0b74Schristos // LSI R4010 instruction.
33675fd0b74Schristos AFL_EXT_4010 = 8,
33775fd0b74Schristos // NEC VR4100 instruction.
33875fd0b74Schristos AFL_EXT_4100 = 9,
33975fd0b74Schristos // Toshiba R3900 instruction.
34075fd0b74Schristos AFL_EXT_3900 = 10,
34175fd0b74Schristos // MIPS R10000 instruction.
34275fd0b74Schristos AFL_EXT_10000 = 11,
34375fd0b74Schristos // Broadcom SB-1 instruction.
34475fd0b74Schristos AFL_EXT_SB1 = 12,
34575fd0b74Schristos // NEC VR4111/VR4181 instruction.
34675fd0b74Schristos AFL_EXT_4111 = 13,
34775fd0b74Schristos // NEC VR4120 instruction.
34875fd0b74Schristos AFL_EXT_4120 = 14,
34975fd0b74Schristos // NEC VR5400 instruction.
35075fd0b74Schristos AFL_EXT_5400 = 15,
35175fd0b74Schristos // NEC VR5500 instruction.
35275fd0b74Schristos AFL_EXT_5500 = 16,
35375fd0b74Schristos // ST Microelectronics Loongson 2E.
35475fd0b74Schristos AFL_EXT_LOONGSON_2E = 17,
35575fd0b74Schristos // ST Microelectronics Loongson 2F.
35675fd0b74Schristos AFL_EXT_LOONGSON_2F = 18,
35775fd0b74Schristos // Cavium Networks Octeon3.
35875fd0b74Schristos AFL_EXT_OCTEON3 = 19
35975fd0b74Schristos };
36075fd0b74Schristos
36175fd0b74Schristos // Masks for the flags1 word of an ABI flags structure.
36275fd0b74Schristos enum
36375fd0b74Schristos {
36475fd0b74Schristos // Uses odd single-precision registers.
36575fd0b74Schristos AFL_FLAGS1_ODDSPREG = 1
36675fd0b74Schristos };
36775fd0b74Schristos
36875fd0b74Schristos // Object attribute tags.
36975fd0b74Schristos enum
37075fd0b74Schristos {
37175fd0b74Schristos // 0-3 are generic.
37275fd0b74Schristos // Floating-point ABI used by this object file.
37375fd0b74Schristos Tag_GNU_MIPS_ABI_FP = 4,
37475fd0b74Schristos // MSA ABI used by this object file.
37575fd0b74Schristos Tag_GNU_MIPS_ABI_MSA = 8
37675fd0b74Schristos };
37775fd0b74Schristos
37875fd0b74Schristos // Object attribute values.
37975fd0b74Schristos enum
38075fd0b74Schristos {
38175fd0b74Schristos // Values defined for Tag_GNU_MIPS_ABI_FP.
38275fd0b74Schristos // Not tagged or not using any ABIs affected by the differences.
38375fd0b74Schristos Val_GNU_MIPS_ABI_FP_ANY = 0,
38475fd0b74Schristos // Using hard-float -mdouble-float.
38575fd0b74Schristos Val_GNU_MIPS_ABI_FP_DOUBLE = 1,
38675fd0b74Schristos // Using hard-float -msingle-float.
38775fd0b74Schristos Val_GNU_MIPS_ABI_FP_SINGLE = 2,
38875fd0b74Schristos // Using soft-float.
38975fd0b74Schristos Val_GNU_MIPS_ABI_FP_SOFT = 3,
39075fd0b74Schristos // Using -mips32r2 -mfp64.
39175fd0b74Schristos Val_GNU_MIPS_ABI_FP_OLD_64 = 4,
39275fd0b74Schristos // Using -mfpxx
39375fd0b74Schristos Val_GNU_MIPS_ABI_FP_XX = 5,
39475fd0b74Schristos // Using -mips32r2 -mfp64.
39575fd0b74Schristos Val_GNU_MIPS_ABI_FP_64 = 6,
39675fd0b74Schristos // Using -mips32r2 -mfp64 -mno-odd-spreg.
39775fd0b74Schristos Val_GNU_MIPS_ABI_FP_64A = 7,
39875fd0b74Schristos // This is reserved for backward-compatibility with an earlier
39975fd0b74Schristos // implementation of the MIPS NaN2008 functionality.
40075fd0b74Schristos Val_GNU_MIPS_ABI_FP_NAN2008 = 8,
40175fd0b74Schristos
40275fd0b74Schristos // Values defined for Tag_GNU_MIPS_ABI_MSA.
40375fd0b74Schristos // Not tagged or not using any ABIs affected by the differences.
40475fd0b74Schristos Val_GNU_MIPS_ABI_MSA_ANY = 0,
40575fd0b74Schristos // Using 128-bit MSA.
40675fd0b74Schristos Val_GNU_MIPS_ABI_MSA_128 = 1
40775fd0b74Schristos };
40875fd0b74Schristos
40975fd0b74Schristos enum
41075fd0b74Schristos {
41175fd0b74Schristos // Mask to extract ABI version, not really a flag value.
41275fd0b74Schristos EF_MIPS_ABI = 0x0000F000,
41375fd0b74Schristos
41475fd0b74Schristos // The original o32 abi.
41575fd0b74Schristos E_MIPS_ABI_O32 = 0x00001000,
41675fd0b74Schristos // O32 extended to work on 64 bit architectures
41775fd0b74Schristos E_MIPS_ABI_O64 = 0x00002000,
41875fd0b74Schristos // EABI in 32 bit mode
41975fd0b74Schristos E_MIPS_ABI_EABI32 = 0x00003000,
42075fd0b74Schristos // EABI in 64 bit mode
42175fd0b74Schristos E_MIPS_ABI_EABI64 = 0x00004000,
42275fd0b74Schristos };
42375fd0b74Schristos
42475fd0b74Schristos // Dynamic section MIPS flags
42575fd0b74Schristos enum
42675fd0b74Schristos {
42775fd0b74Schristos // None
42875fd0b74Schristos RHF_NONE = 0x00000000,
42975fd0b74Schristos // Use shortcut pointers
43075fd0b74Schristos RHF_QUICKSTART = 0x00000001,
43175fd0b74Schristos // Hash size not power of two
43275fd0b74Schristos RHF_NOTPOT = 0x00000002,
43375fd0b74Schristos // Ignore LD_LIBRARY_PATH
43475fd0b74Schristos RHF_NO_LIBRARY_REPLACEMENT = 0x00000004
43575fd0b74Schristos };
43675fd0b74Schristos
43775fd0b74Schristos // Special values for the st_other field in the symbol table.
43875fd0b74Schristos enum
43975fd0b74Schristos {
44075fd0b74Schristos // Two topmost bits denote the MIPS ISA for .text symbols:
44175fd0b74Schristos // + 00 -- standard MIPS code,
44275fd0b74Schristos // + 10 -- microMIPS code,
44375fd0b74Schristos // + 11 -- MIPS16 code; requires the following two bits to be set too.
44475fd0b74Schristos // Note that one of the MIPS16 bits overlaps with STO_MIPS_PIC.
44575fd0b74Schristos STO_MIPS_ISA = 0xc0,
44675fd0b74Schristos
44775fd0b74Schristos // The mask spanning the rest of MIPS psABI flags. At most one is expected
44875fd0b74Schristos // to be set except for STO_MIPS16.
44975fd0b74Schristos STO_MIPS_FLAGS = ~(STO_MIPS_ISA | 0x3),
45075fd0b74Schristos
45175fd0b74Schristos // The MIPS psABI was updated in 2008 with support for PLTs and copy
45275fd0b74Schristos // relocs. There are therefore two types of nonzero SHN_UNDEF functions:
45375fd0b74Schristos // PLT entries and traditional MIPS lazy binding stubs. We mark the former
45475fd0b74Schristos // with STO_MIPS_PLT to distinguish them from the latter.
45575fd0b74Schristos STO_MIPS_PLT = 0x8,
45675fd0b74Schristos
45775fd0b74Schristos // This value is used to mark PIC functions in an object that mixes
45875fd0b74Schristos // PIC and non-PIC. Note that this bit overlaps with STO_MIPS16,
45975fd0b74Schristos // although MIPS16 symbols are never considered to be MIPS_PIC.
46075fd0b74Schristos STO_MIPS_PIC = 0x20,
46175fd0b74Schristos
46275fd0b74Schristos // This value is used for a mips16 .text symbol.
46375fd0b74Schristos STO_MIPS16 = 0xf0,
46475fd0b74Schristos
46575fd0b74Schristos // This value is used for a microMIPS .text symbol. To distinguish from
46675fd0b74Schristos // STO_MIPS16, we set top two bits to be 10 to denote STO_MICROMIPS. The
46775fd0b74Schristos // mask is STO_MIPS_ISA.
46875fd0b74Schristos STO_MICROMIPS = 0x80
46975fd0b74Schristos };
47075fd0b74Schristos
47175fd0b74Schristos // Values for base offsets for thread-local storage
47275fd0b74Schristos enum
47375fd0b74Schristos {
47475fd0b74Schristos TP_OFFSET = 0x7000,
47575fd0b74Schristos DTP_OFFSET = 0x8000
47675fd0b74Schristos };
47775fd0b74Schristos
47875fd0b74Schristos
47975fd0b74Schristos bool
elf_st_is_mips16(unsigned char st_other)48075fd0b74Schristos elf_st_is_mips16(unsigned char st_other)
48175fd0b74Schristos { return (st_other & elfcpp::STO_MIPS16) == elfcpp::STO_MIPS16; }
48275fd0b74Schristos
48375fd0b74Schristos bool
elf_st_is_micromips(unsigned char st_other)48475fd0b74Schristos elf_st_is_micromips(unsigned char st_other)
48575fd0b74Schristos { return (st_other & elfcpp::STO_MIPS_ISA) == elfcpp::STO_MICROMIPS; }
48675fd0b74Schristos
48775fd0b74Schristos // Whether the ABI is N32.
48875fd0b74Schristos bool
abi_n32(elfcpp::Elf_Word e_flags)48975fd0b74Schristos abi_n32(elfcpp::Elf_Word e_flags)
49075fd0b74Schristos { return (e_flags & elfcpp::EF_MIPS_ABI2) != 0; }
49175fd0b74Schristos
49275fd0b74Schristos // Whether the ISA is R6.
49375fd0b74Schristos bool
r6_isa(elfcpp::Elf_Word e_flags)49475fd0b74Schristos r6_isa(elfcpp::Elf_Word e_flags)
49575fd0b74Schristos {
49675fd0b74Schristos return ((e_flags & elfcpp::EF_MIPS_ARCH) == elfcpp::E_MIPS_ARCH_32R6)
49775fd0b74Schristos || ((e_flags & elfcpp::EF_MIPS_ARCH) == elfcpp::E_MIPS_ARCH_64R6);
49875fd0b74Schristos }
49975fd0b74Schristos
50075fd0b74Schristos // Whether the file has microMIPS code.
50175fd0b74Schristos bool
is_micromips(elfcpp::Elf_Word e_flags)50275fd0b74Schristos is_micromips(elfcpp::Elf_Word e_flags)
50375fd0b74Schristos { return (e_flags & elfcpp::EF_MIPS_ARCH_ASE_MICROMIPS) != 0; }
50475fd0b74Schristos
50575fd0b74Schristos // Values which may appear in the kind field of an Elf_Options structure.
50675fd0b74Schristos enum
50775fd0b74Schristos {
50875fd0b74Schristos // Undefined.
50975fd0b74Schristos ODK_NULL = 0,
51075fd0b74Schristos // Register usage and GP value.
51175fd0b74Schristos ODK_REGINFO = 1,
51275fd0b74Schristos // Exception processing information.
51375fd0b74Schristos ODK_EXCEPTIONS = 2,
51475fd0b74Schristos // Section padding information.
51575fd0b74Schristos ODK_PAD = 3,
51675fd0b74Schristos // Hardware workarounds performed.
51775fd0b74Schristos ODK_HWPATCH = 4,
51875fd0b74Schristos // Fill value used by the linker.
51975fd0b74Schristos ODK_FILL = 5,
52075fd0b74Schristos // Reserved space for desktop tools.
52175fd0b74Schristos ODK_TAGS = 6,
52275fd0b74Schristos // Hardware workarounds, AND bits when merging.
52375fd0b74Schristos ODK_HWAND = 7,
52475fd0b74Schristos // Hardware workarounds, OR bits when merging.
52575fd0b74Schristos ODK_HWOR = 8,
52675fd0b74Schristos // GP group to use for text/data sections.
52775fd0b74Schristos ODK_GP_GROUP = 9,
52875fd0b74Schristos // ID information.
52975fd0b74Schristos ODK_IDENT = 10
53075fd0b74Schristos };
53175fd0b74Schristos
53275fd0b74Schristos } // End namespace elfcpp.
53375fd0b74Schristos
53475fd0b74Schristos #endif // !defined(ELFCPP_MIPS_H)
535