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