1/*	$NetBSD: elf_machdep.h,v 1.15 2011/03/15 07:39:22 matt Exp $	*/
2
3#ifndef _MIPS_ELF_MACHDEP_H_
4#define  _MIPS_ELF_MACHDEP_H_
5
6#ifdef _LP64
7#define ARCH_ELFSIZE		64	/* MD native binary size */
8#else
9#define ARCH_ELFSIZE		32	/* MD native binary size */
10#endif
11
12#if ELFSIZE == 32
13#define	ELF32_MACHDEP_ID_CASES						\
14		case EM_MIPS:						\
15			break;
16
17#define	ELF32_MACHDEP_ID	EM_MIPS
18#elif ELFSIZE == 64
19#define	ELF64_MACHDEP_ID_CASES						\
20		case EM_MIPS:						\
21			break;
22
23#define	ELF64_MACHDEP_ID	EM_MIPS
24#endif
25
26/* mips relocs.  */
27
28#define R_MIPS_NONE		0
29#define R_MIPS_16		1
30#define R_MIPS_32		2
31#define R_MIPS_REL32		3
32#define R_MIPS_REL		R_MIPS_REL32
33#define R_MIPS_26		4
34#define R_MIPS_HI16		5	/* high 16 bits of symbol value */
35#define R_MIPS_LO16		6	/* low 16 bits of symbol value */
36#define R_MIPS_GPREL16		7  	/* GP-relative reference  */
37#define R_MIPS_LITERAL		8 	/* Reference to literal section  */
38#define R_MIPS_GOT16		9	/* Reference to global offset table */
39#define R_MIPS_GOT		R_MIPS_GOT16
40#define R_MIPS_PC16		10  	/* 16 bit PC relative reference */
41#define R_MIPS_CALL16 		11  	/* 16 bit call thru glbl offset tbl */
42#define R_MIPS_CALL		R_MIPS_CALL16
43#define R_MIPS_GPREL32		12
44
45/* 13, 14, 15 are not defined at this point. */
46#define R_MIPS_UNUSED1		13
47#define R_MIPS_UNUSED2		14
48#define R_MIPS_UNUSED3		15
49
50/*
51 * The remaining relocs are apparently part of the 64-bit Irix ELF ABI.
52 */
53#define R_MIPS_SHIFT5		16
54#define R_MIPS_SHIFT6		17
55
56#define R_MIPS_64		18
57#define R_MIPS_GOT_DISP		19
58#define R_MIPS_GOT_PAGE		20
59#define R_MIPS_GOT_OFST		21
60#define R_MIPS_GOT_HI16		22
61#define R_MIPS_GOT_LO16		23
62#define R_MIPS_SUB 		24
63#define R_MIPS_INSERT_A		25
64#define R_MIPS_INSERT_B		26
65#define R_MIPS_DELETE		27
66#define R_MIPS_HIGHER		28
67#define R_MIPS_HIGHEST		29
68#define R_MIPS_CALL_HI16	30
69#define R_MIPS_CALL_LO16	31
70#define R_MIPS_SCN_DISP		32
71#define R_MIPS_REL16		33
72#define R_MIPS_ADD_IMMEDIATE	34
73#define R_MIPS_PJUMP		35
74#define R_MIPS_RELGOT		36
75#define	R_MIPS_JALR		37
76/* TLS relocations */
77
78#define R_MIPS_TLS_DTPMOD32	38	/* Module number 32 bit */
79#define R_MIPS_TLS_DTPREL32	39	/* Module-relative offset 32 bit */
80#define R_MIPS_TLS_DTPMOD64	40	/* Module number 64 bit */
81#define R_MIPS_TLS_DTPREL64	41	/* Module-relative offset 64 bit */
82#define R_MIPS_TLS_GD		42	/* 16 bit GOT offset for GD */
83#define R_MIPS_TLS_LDM		43	/* 16 bit GOT offset for LDM */
84#define R_MIPS_TLS_DTPREL_HI16	44	/* Module-relative offset, high 16 bits */
85#define R_MIPS_TLS_DTPREL_LO16	45	/* Module-relative offset, low 16 bits */
86#define R_MIPS_TLS_GOTTPREL	46	/* 16 bit GOT offset for IE */
87#define R_MIPS_TLS_TPREL32	47	/* TP-relative offset, 32 bit */
88#define R_MIPS_TLS_TPREL64	48	/* TP-relative offset, 64 bit */
89#define R_MIPS_TLS_TPREL_HI16	49	/* TP-relative offset, high 16 bits */
90#define R_MIPS_TLS_TPREL_LO16	50	/* TP-relative offset, low 16 bits */
91
92#define R_MIPS_max		51
93
94#define R_TYPE(name)		__CONCAT(R_MIPS_,name)
95
96#define	R_MIPS16_min		100
97#define	R_MIPS16_26		100
98#define	R_MIPS16_GPREL		101
99#define	R_MIPS16_GOT16		102
100#define	R_MIPS16_CALL16		103
101#define	R_MIPS16_HI16		104
102#define	R_MIPS16_LO16		105
103#define	R_MIPS16_max		106
104
105
106/* mips dynamic tags */
107
108#define DT_MIPS_RLD_VERSION	0x70000001
109#define DT_MIPS_TIME_STAMP	0x70000002
110#define DT_MIPS_ICHECKSUM	0x70000003
111#define DT_MIPS_IVERSION	0x70000004
112#define DT_MIPS_FLAGS		0x70000005
113#define DT_MIPS_BASE_ADDRESS	0x70000006
114#define DT_MIPS_CONFLICT	0x70000008
115#define DT_MIPS_LIBLIST		0x70000009
116#define DT_MIPS_CONFLICTNO	0x7000000b
117#define	DT_MIPS_LOCAL_GOTNO	0x7000000a	/* number of local got ents */
118#define DT_MIPS_LIBLISTNO	0x70000010
119#define	DT_MIPS_SYMTABNO	0x70000011	/* number of .dynsym entries */
120#define DT_MIPS_UNREFEXTNO	0x70000012
121#define	DT_MIPS_GOTSYM		0x70000013	/* first dynamic sym in got */
122#define DT_MIPS_HIPAGENO	0x70000014
123#define	DT_MIPS_RLD_MAP		0x70000016	/* address of loader map */
124#define DT_MIPS_RLD_MAP_REL	0x70000035	/* offset of loader map, used for PIE */
125
126/*
127 * ELF Flags
128 */
129#define	EF_MIPS_PIC		0x00000002	/* Contains PIC code */
130#define	EF_MIPS_CPIC		0x00000004	/* STD PIC calling sequence */
131#define	EF_MIPS_ABI2		0x00000020	/* N32 */
132
133#define	EF_MIPS_ARCH_ASE	0x0f000000	/* Architectural extensions */
134#define	EF_MIPS_ARCH_MDMX	0x08000000	/* MDMX multimedia extension */
135#define	EF_MIPS_ARCH_M16	0x04000000	/* MIPS-16 ISA extensions */
136
137#define	EF_MIPS_ARCH		0xf0000000	/* Architecture field */
138#define	EF_MIPS_ARCH_1		0x00000000	/* -mips1 code */
139#define	EF_MIPS_ARCH_2		0x10000000	/* -mips2 code */
140#define	EF_MIPS_ARCH_3		0x20000000	/* -mips3 code */
141#define	EF_MIPS_ARCH_4		0x30000000	/* -mips4 code */
142#define	EF_MIPS_ARCH_5		0x40000000	/* -mips5 code */
143#define	EF_MIPS_ARCH_32		0x50000000	/* -mips32 code */
144#define	EF_MIPS_ARCH_64		0x60000000	/* -mips64 code */
145#define	EF_MIPS_ARCH_32R2	0x70000000	/* -mips32r2 code */
146#define	EF_MIPS_ARCH_64R2	0x80000000	/* -mips64r2 code */
147
148#define	EF_MIPS_ABI		0x0000f000
149#define	EF_MIPS_ABI_O32		0x00001000
150#define	EF_MIPS_ABI_O64		0x00002000
151#define	EF_MIPS_ABI_EABI32	0x00003000
152#define	EF_MIPS_ABI_EABI64	0x00004000
153
154#define	ELF32_MACHDEP_ENDIANNESS	ELFDATA2LSB
155#define	ELF64_MACHDEP_ENDIANNESS	ELFDATA2LSB
156
157#endif /* _MIPS_ELF_MACHDEP_H_ */
158