Home | History | Annotate | Line # | Download | only in include
elf_machdep.h revision 1.10.96.6
      1 /*	$NetBSD: elf_machdep.h,v 1.10.96.6 2009/09/05 03:15:08 matt Exp $	*/
      2 
      3 #ifndef _MIPS_ELF_MACHDEP_H_
      4 #define  _MIPS_ELF_MACHDEP_H_
      5 
      6 #if defined(ELFSIZE)
      7 #if ELFSIZE == 32
      8 #ifdef _LP64
      9 #define	ELF32_MACHDEP_ID_CASES		/* xxx */
     10 #else
     11 #define	ELF32_MACHDEP_ID_CASES						\
     12 		case EM_MIPS:						\
     13 			break;
     14 #endif /* _LP64 */
     15 
     16 #define	ELF32_MACHDEP_ID	EM_MIPS
     17 #endif /* ELFSIZE == 32 */
     18 #if ELFSIZE == 64
     19 #ifdef _LP64
     20 #define	ELF64_MACHDEP_ID_CASES						\
     21 		case EM_MIPS:						\
     22 			break;
     23 #else
     24 #define	ELF64_MACHDEP_ID_CASES		/* xxx */
     25 #endif /* _LP64 */
     26 
     27 #define	ELF64_MACHDEP_ID	EM_MIPS
     28 #endif /* ELFSIZE == 64 */
     29 #endif /* defined(ELFSIZE) */
     30 
     31 #ifdef _LP64
     32 #define ARCH_ELFSIZE		64	/* MD native binary size */
     33 #else
     34 #define ARCH_ELFSIZE		32	/* MD native binary size */
     35 #endif
     36 
     37 /* mips relocs.  */
     38 
     39 #define R_MIPS_NONE		0
     40 #define R_MIPS_16		1
     41 #define R_MIPS_32		2
     42 #define R_MIPS_REL32		3
     43 #define R_MIPS_REL		R_MIPS_REL32
     44 #define R_MIPS_26		4
     45 #define R_MIPS_HI16		5	/* high 16 bits of symbol value */
     46 #define R_MIPS_LO16		6	/* low 16 bits of symbol value */
     47 #define R_MIPS_GPREL16		7  	/* GP-relative reference  */
     48 #define R_MIPS_LITERAL		8 	/* Reference to literal section  */
     49 #define R_MIPS_GOT16		9	/* Reference to global offset table */
     50 #define R_MIPS_GOT		R_MIPS_GOT16
     51 #define R_MIPS_PC16		10  	/* 16 bit PC relative reference */
     52 #define R_MIPS_CALL16 		11  	/* 16 bit call thru glbl offset tbl */
     53 #define R_MIPS_CALL		R_MIPS_CALL16
     54 #define R_MIPS_GPREL32		12
     55 
     56 /* 13, 14, 15 are not defined at this point. */
     57 #define R_MIPS_UNUSED1		13
     58 #define R_MIPS_UNUSED2		14
     59 #define R_MIPS_UNUSED3		15
     60 
     61 /*
     62  * The remaining relocs are apparently part of the 64-bit Irix ELF ABI.
     63  */
     64 #define R_MIPS_SHIFT5		16
     65 #define R_MIPS_SHIFT6		17
     66 
     67 #define R_MIPS_64		18
     68 #define R_MIPS_GOT_DISP		19
     69 #define R_MIPS_GOT_PAGE		20
     70 #define R_MIPS_GOT_OFST		21
     71 #define R_MIPS_GOT_HI16		22
     72 #define R_MIPS_GOT_LO16		23
     73 #define R_MIPS_SUB 		24
     74 #define R_MIPS_INSERT_A		25
     75 #define R_MIPS_INSERT_B		26
     76 #define R_MIPS_DELETE		27
     77 #define R_MIPS_HIGHER		28
     78 #define R_MIPS_HIGHEST		29
     79 #define R_MIPS_CALL_HI16	30
     80 #define R_MIPS_CALL_LO16	31
     81 #define R_MIPS_SCN_DISP		32
     82 #define R_MIPS_REL16		33
     83 #define R_MIPS_ADD_IMMEDIATE	34
     84 #define R_MIPS_PJUMP		35
     85 #define R_MIPS_RELGOT		36
     86 #define	R_MIPS_JALR		37
     87 /* TLS relocations */
     88 #define	R_MIPS_TLS_DTPMOD32	38
     89 #define	R_MIPS_TLS_DTPREL32	39
     90 #define	R_MIPS_TLS_DTPMOD64	40
     91 #define	R_MIPS_TLS_DTPREL64	41
     92 #define	R_MIPS_TLS_GD		42
     93 #define	R_MIPS_TLS_LDM		43
     94 #define	R_MIPS_TLS_DTPREL_HI16	44
     95 #define	R_MIPS_TLS_DTPREL_LO16	45
     96 #define	R_MIPS_TLS_GOTTPREL	46
     97 #define	R_MIPS_TLS_TPREL32	47
     98 #define	R_MIPS_TLS_TPREL64	48
     99 #define	R_MIPS_TLS_TPREL_HI16	49
    100 #define	R_MIPS_TLS_TPREL_LO16	50
    101 
    102 #define R_MIPS_max		51
    103 #define R_TYPE(name)		__CONCAT(R_MIPS_,name)
    104 
    105 #define	R_MIPS16_min		100
    106 #define	R_MIPS16_26		100
    107 #define	R_MIPS16_GPREL		101
    108 #define	R_MIPS16_GOT16		102
    109 #define	R_MIPS16_CALL16		103
    110 #define	R_MIPS16_HI16		104
    111 #define	R_MIPS16_LO16		105
    112 #define	R_MIPS16_max		106
    113 
    114 
    115 /* mips dynamic tags */
    116 
    117 #define DT_MIPS_RLD_VERSION	0x70000001
    118 #define DT_MIPS_TIME_STAMP	0x70000002
    119 #define DT_MIPS_ICHECKSUM	0x70000003
    120 #define DT_MIPS_IVERSION	0x70000004
    121 #define DT_MIPS_FLAGS		0x70000005
    122 #define DT_MIPS_BASE_ADDRESS	0x70000006
    123 #define DT_MIPS_CONFLICT	0x70000008
    124 #define DT_MIPS_LIBLIST		0x70000009
    125 #define DT_MIPS_CONFLICTNO	0x7000000b
    126 #define	DT_MIPS_LOCAL_GOTNO	0x7000000a	/* number of local got ents */
    127 #define DT_MIPS_LIBLISTNO	0x70000010
    128 #define	DT_MIPS_SYMTABNO	0x70000011	/* number of .dynsym entries */
    129 #define DT_MIPS_UNREFEXTNO	0x70000012
    130 #define	DT_MIPS_GOTSYM		0x70000013	/* first dynamic sym in got */
    131 #define DT_MIPS_HIPAGENO	0x70000014
    132 #define	DT_MIPS_RLD_MAP		0x70000016	/* address of loader map */
    133 
    134 /*
    135  * ELF Flags
    136  */
    137 #define	EF_MIPS_PIC		0x00000002	/* Contains PIC code */
    138 #define	EF_MIPS_CPIC		0x00000004	/* STD PIC calling sequence */
    139 #define	EF_MIPS_ABI2		0x00000020	/* N32 */
    140 
    141 #define	EF_MIPS_ARCH_ASE	0x0f000000	/* Architectural extensions */
    142 #define	EF_MIPS_ARCH_MDMX	0x08000000	/* MDMX multimedia extension */
    143 #define	EF_MIPS_ARCH_M16	0x04000000	/* MIPS-16 ISA extensions */
    144 
    145 #define	EF_MIPS_ARCH		0xf0000000	/* Architecture field */
    146 #define	EF_MIPS_ARCH_1		0x00000000	/* -mips1 code */
    147 #define	EF_MIPS_ARCH_2		0x10000000	/* -mips2 code */
    148 #define	EF_MIPS_ARCH_3		0x20000000	/* -mips3 code */
    149 #define	EF_MIPS_ARCH_4		0x30000000	/* -mips4 code */
    150 #define	EF_MIPS_ARCH_5		0x40000000	/* -mips5 code */
    151 #define	EF_MIPS_ARCH_32		0x50000000	/* -mips32 code */
    152 #define	EF_MIPS_ARCH_64		0x60000000	/* -mips64 code */
    153 #define	EF_MIPS_ARCH_32R2	0x70000000	/* -mips32r2 code */
    154 #define	EF_MIPS_ARCH_64R4	0x80000000	/* -mips64r2 code */
    155 
    156 #define	EF_MIPS_ABI		0x0000f000
    157 #define	EF_MIPS_ABI_O32		0x00001000
    158 #define	EF_MIPS_ABI_O64		0x00002000
    159 #define	EF_MIPS_ABI_EABI32	0x00003000
    160 #define	EF_MIPS_ABI_EABI64	0x00004000
    161 
    162 #if defined(__MIPSEB__)
    163 #define	ELF32_MACHDEP_ENDIANNESS	ELFDATA2MSB
    164 #define	ELF64_MACHDEP_ENDIANNESS	ELFDATA2MSB
    165 #elif defined(__MIPSEL__)
    166 #define	ELF32_MACHDEP_ENDIANNESS	ELFDATA2LSB
    167 #define	ELF64_MACHDEP_ENDIANNESS	ELFDATA2LSB
    168 #elif !defined(HAVE_NBTOOL_CONFIG_H)
    169 #error neither __MIPSEL__ nor __MIPSEB__ are defined.
    170 #endif
    171 
    172 #ifdef _KERNEL
    173 #ifdef _KERNEL_OPT
    174 #include "opt_compat_netbsd.h"
    175 #endif
    176 #ifdef COMPAT_16
    177 /*
    178  * Up to 1.6, the ELF dynamic loader (ld.elf_so) was not relocatable.
    179  * Tell the kernel ELF exec code not to try relocating the interpreter
    180  * for dynamically-linked ELF binaries.
    181  */
    182 #define ELF_INTERP_NON_RELOCATABLE
    183 #endif /* COMPAT_16 */
    184 
    185 /*
    186  * We need to be able to include the ELF header so we can pick out the
    187  * ABI being used.
    188  */
    189 #ifdef ELFSIZE
    190 #define	ELF_MD_PROBE_FUNC	ELFNAME2(mips_netbsd,probe)
    191 #define	ELF_MD_COREDUMP_SETUP	ELFNAME2(coredump,setup)
    192 #endif
    193 
    194 int mips_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *,
    195 	vaddr_t *);
    196 void coredump_elf32_setup(struct lwp *, void *);
    197 
    198 int mips_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *,
    199 	vaddr_t *);
    200 void coredump_elf64_setup(struct lwp *, void *);
    201 #endif /* _KERNEL */
    202 
    203 #endif /* _MIPS_ELF_MACHDEP_H_ */
    204