Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:24

0001 /*  $NetBSD: elf_machdep.h,v 1.15 2011/03/15 07:39:22 matt Exp $    */
0002 
0003 #ifndef _MIPS_ELF_MACHDEP_H_
0004 #define  _MIPS_ELF_MACHDEP_H_
0005 
0006 #ifdef _LP64
0007 #define ARCH_ELFSIZE        64  /* MD native binary size */
0008 #else
0009 #define ARCH_ELFSIZE        32  /* MD native binary size */
0010 #endif
0011 
0012 #if ARCH_ELFSIZE == 32
0013 #define ELF32_MACHDEP_ID_CASES                      \
0014         case EM_MIPS:                       \
0015             break;
0016 
0017 #define ELF32_MACHDEP_ID    EM_MIPS
0018 
0019 #elif ARCH_ELFSIZE == 64
0020 #define ELF64_MACHDEP_ID_CASES                      \
0021         case EM_MIPS:                       \
0022             break;
0023 
0024 #define ELF64_MACHDEP_ID    EM_MIPS
0025 
0026 #endif
0027 
0028 
0029 /* mips relocs.  */
0030 
0031 #define R_MIPS_NONE     0
0032 #define R_MIPS_16       1
0033 #define R_MIPS_32       2
0034 #define R_MIPS_REL32        3
0035 #define R_MIPS_REL      R_MIPS_REL32
0036 #define R_MIPS_26       4
0037 #define R_MIPS_HI16     5   /* high 16 bits of symbol value */
0038 #define R_MIPS_LO16     6   /* low 16 bits of symbol value */
0039 #define R_MIPS_GPREL16      7   /* GP-relative reference  */
0040 #define R_MIPS_LITERAL      8   /* Reference to literal section  */
0041 #define R_MIPS_GOT16        9   /* Reference to global offset table */
0042 #define R_MIPS_GOT      R_MIPS_GOT16
0043 #define R_MIPS_PC16     10      /* 16 bit PC relative reference */
0044 #define R_MIPS_CALL16       11      /* 16 bit call thru glbl offset tbl */
0045 #define R_MIPS_CALL     R_MIPS_CALL16
0046 #define R_MIPS_GPREL32      12
0047 
0048 /* 13, 14, 15 are not defined at this point. */
0049 #define R_MIPS_UNUSED1      13
0050 #define R_MIPS_UNUSED2      14
0051 #define R_MIPS_UNUSED3      15
0052 
0053 /*
0054  * The remaining relocs are apparently part of the 64-bit Irix ELF ABI.
0055  */
0056 #define R_MIPS_SHIFT5       16
0057 #define R_MIPS_SHIFT6       17
0058 
0059 #define R_MIPS_64       18
0060 #define R_MIPS_GOT_DISP     19
0061 #define R_MIPS_GOT_PAGE     20
0062 #define R_MIPS_GOT_OFST     21
0063 #define R_MIPS_GOT_HI16     22
0064 #define R_MIPS_GOT_LO16     23
0065 #define R_MIPS_SUB      24
0066 #define R_MIPS_INSERT_A     25
0067 #define R_MIPS_INSERT_B     26
0068 #define R_MIPS_DELETE       27
0069 #define R_MIPS_HIGHER       28
0070 #define R_MIPS_HIGHEST      29
0071 #define R_MIPS_CALL_HI16    30
0072 #define R_MIPS_CALL_LO16    31
0073 #define R_MIPS_SCN_DISP     32
0074 #define R_MIPS_REL16        33
0075 #define R_MIPS_ADD_IMMEDIATE    34
0076 #define R_MIPS_PJUMP        35
0077 #define R_MIPS_RELGOT       36
0078 #define R_MIPS_JALR     37
0079 /* TLS relocations */
0080 
0081 #define R_MIPS_TLS_DTPMOD32 38  /* Module number 32 bit */
0082 #define R_MIPS_TLS_DTPREL32 39  /* Module-relative offset 32 bit */
0083 #define R_MIPS_TLS_DTPMOD64 40  /* Module number 64 bit */
0084 #define R_MIPS_TLS_DTPREL64 41  /* Module-relative offset 64 bit */
0085 #define R_MIPS_TLS_GD       42  /* 16 bit GOT offset for GD */
0086 #define R_MIPS_TLS_LDM      43  /* 16 bit GOT offset for LDM */
0087 #define R_MIPS_TLS_DTPREL_HI16  44  /* Module-relative offset, high 16 bits */
0088 #define R_MIPS_TLS_DTPREL_LO16  45  /* Module-relative offset, low 16 bits */
0089 #define R_MIPS_TLS_GOTTPREL 46  /* 16 bit GOT offset for IE */
0090 #define R_MIPS_TLS_TPREL32  47  /* TP-relative offset, 32 bit */
0091 #define R_MIPS_TLS_TPREL64  48  /* TP-relative offset, 64 bit */
0092 #define R_MIPS_TLS_TPREL_HI16   49  /* TP-relative offset, high 16 bits */
0093 #define R_MIPS_TLS_TPREL_LO16   50  /* TP-relative offset, low 16 bits */
0094 
0095 #define R_MIPS_max      51
0096 
0097 #define R_TYPE(name)        __CONCAT(R_MIPS_,name)
0098 
0099 #define R_MIPS16_min        100
0100 #define R_MIPS16_26     100
0101 #define R_MIPS16_GPREL      101
0102 #define R_MIPS16_GOT16      102
0103 #define R_MIPS16_CALL16     103
0104 #define R_MIPS16_HI16       104
0105 #define R_MIPS16_LO16       105
0106 #define R_MIPS16_max        106
0107 
0108 
0109 /* mips dynamic tags */
0110 
0111 #define DT_MIPS_RLD_VERSION 0x70000001
0112 #define DT_MIPS_TIME_STAMP  0x70000002
0113 #define DT_MIPS_ICHECKSUM   0x70000003
0114 #define DT_MIPS_IVERSION    0x70000004
0115 #define DT_MIPS_FLAGS       0x70000005
0116 #define DT_MIPS_BASE_ADDRESS    0x70000006
0117 #define DT_MIPS_CONFLICT    0x70000008
0118 #define DT_MIPS_LIBLIST     0x70000009
0119 #define DT_MIPS_CONFLICTNO  0x7000000b
0120 #define DT_MIPS_LOCAL_GOTNO 0x7000000a  /* number of local got ents */
0121 #define DT_MIPS_LIBLISTNO   0x70000010
0122 #define DT_MIPS_SYMTABNO    0x70000011  /* number of .dynsym entries */
0123 #define DT_MIPS_UNREFEXTNO  0x70000012
0124 #define DT_MIPS_GOTSYM      0x70000013  /* first dynamic sym in got */
0125 #define DT_MIPS_HIPAGENO    0x70000014
0126 #define DT_MIPS_RLD_MAP     0x70000016  /* address of loader map */
0127 
0128 /*
0129  * ELF Flags
0130  */
0131 #define EF_MIPS_PIC     0x00000002  /* Contains PIC code */
0132 #define EF_MIPS_CPIC        0x00000004  /* STD PIC calling sequence */
0133 #define EF_MIPS_ABI2        0x00000020  /* N32 */
0134 
0135 #define EF_MIPS_ARCH_ASE    0x0f000000  /* Architectural extensions */
0136 #define EF_MIPS_ARCH_MDMX   0x08000000  /* MDMX multimedia extension */
0137 #define EF_MIPS_ARCH_M16    0x04000000  /* MIPS-16 ISA extensions */
0138 
0139 #define EF_MIPS_ARCH        0xf0000000  /* Architecture field */
0140 #define EF_MIPS_ARCH_1      0x00000000  /* -mips1 code */
0141 #define EF_MIPS_ARCH_2      0x10000000  /* -mips2 code */
0142 #define EF_MIPS_ARCH_3      0x20000000  /* -mips3 code */
0143 #define EF_MIPS_ARCH_4      0x30000000  /* -mips4 code */
0144 #define EF_MIPS_ARCH_5      0x40000000  /* -mips5 code */
0145 #define EF_MIPS_ARCH_32     0x50000000  /* -mips32 code */
0146 #define EF_MIPS_ARCH_64     0x60000000  /* -mips64 code */
0147 #define EF_MIPS_ARCH_32R2   0x70000000  /* -mips32r2 code */
0148 #define EF_MIPS_ARCH_64R2   0x80000000  /* -mips64r2 code */
0149 
0150 #define EF_MIPS_ABI     0x0000f000
0151 #define EF_MIPS_ABI_O32     0x00001000
0152 #define EF_MIPS_ABI_O64     0x00002000
0153 #define EF_MIPS_ABI_EABI32  0x00003000
0154 #define EF_MIPS_ABI_EABI64  0x00004000
0155 
0156 #if defined(__MIPSEB__)
0157 #define ELF32_MACHDEP_ENDIANNESS    ELFDATA2MSB
0158 #define ELF64_MACHDEP_ENDIANNESS    ELFDATA2MSB
0159 #elif defined(__MIPSEL__)
0160 #define ELF32_MACHDEP_ENDIANNESS    ELFDATA2LSB
0161 #define ELF64_MACHDEP_ENDIANNESS    ELFDATA2LSB
0162 #elif !defined(HAVE_NBTOOL_CONFIG_H)
0163 #error neither __MIPSEL__ nor __MIPSEB__ are defined.
0164 #endif
0165 
0166 #ifdef _KERNEL
0167 #ifdef _KERNEL_OPT
0168 #include "opt_compat_netbsd.h"
0169 #endif
0170 #ifdef COMPAT_16
0171 /*
0172  * Up to 1.6, the ELF dynamic loader (ld.elf_so) was not relocatable.
0173  * Tell the kernel ELF exec code not to try relocating the interpreter
0174  * for dynamically-linked ELF binaries.
0175  */
0176 #define ELF_INTERP_NON_RELOCATABLE
0177 #endif /* COMPAT_16 */
0178 
0179 /*
0180  * We need to be able to include the ELF header so we can pick out the
0181  * ABI being used.
0182  */
0183 #ifdef ELFSIZE
0184 #define ELF_MD_PROBE_FUNC   ELFNAME2(mips_netbsd,probe)
0185 #define ELF_MD_COREDUMP_SETUP   ELFNAME2(coredump,setup)
0186 #endif
0187 
0188 struct exec_package;
0189 
0190 int mips_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *,
0191     vaddr_t *);
0192 void coredump_elf32_setup(struct lwp *, void *);
0193 
0194 int mips_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *,
0195     vaddr_t *);
0196 void coredump_elf64_setup(struct lwp *, void *);
0197 #endif /* _KERNEL */
0198 
0199 #endif /* _MIPS_ELF_MACHDEP_H_ */