master
  1/*	$NetBSD: elf_machdep.h,v 1.19 2017/11/06 03:47:45 christos Exp $	*/
  2
  3#ifndef _ARM_ELF_MACHDEP_H_
  4#define _ARM_ELF_MACHDEP_H_
  5
  6#if defined(__ARMEB__)
  7#define ELF32_MACHDEP_ENDIANNESS	ELFDATA2MSB
  8#else
  9#define ELF32_MACHDEP_ENDIANNESS	ELFDATA2LSB
 10#endif
 11
 12#define ELF64_MACHDEP_ENDIANNESS	XXX	/* break compilation */
 13#define ELF64_MACHDEP_ID_CASES                                          \
 14		/* no 64-bit ELF machine types supported */
 15
 16/* Processor specific flags for the ELF header e_flags field.  */
 17#define EF_ARM_RELEXEC		0x00000001
 18#define EF_ARM_HASENTRY		0x00000002
 19#define EF_ARM_INTERWORK	0x00000004 /* GNU binutils 000413 */
 20#define EF_ARM_SYMSARESORTED	0x00000004 /* ARM ELF A08 */
 21#define EF_ARM_APCS_26		0x00000008 /* GNU binutils 000413 */
 22#define EF_ARM_DYNSYMSUSESEGIDX	0x00000008 /* ARM ELF B01 */
 23#define EF_ARM_APCS_FLOAT	0x00000010 /* GNU binutils 000413 */
 24#define EF_ARM_MAPSYMSFIRST	0x00000010 /* ARM ELF B01 */
 25#define EF_ARM_PIC		0x00000020
 26#define EF_ARM_ALIGN8		0x00000040 /* 8-bit structure alignment.  */
 27#define EF_ARM_NEW_ABI		0x00000080
 28#define EF_ARM_OLD_ABI		0x00000100
 29#define EF_ARM_SOFT_FLOAT	0x00000200
 30#define EF_ARM_BE8		0x00800000
 31#define EF_ARM_EABIMASK		0xff000000
 32#define	EF_ARM_EABI_VER1	0x01000000
 33#define	EF_ARM_EABI_VER2	0x02000000
 34#define	EF_ARM_EABI_VER3	0x03000000
 35#define	EF_ARM_EABI_VER4	0x04000000
 36#define	EF_ARM_EABI_VER5	0x05000000
 37
 38#define	ELF32_MACHDEP_ID_CASES						\
 39		case EM_ARM:						\
 40			break;
 41
 42#define	ELF32_MACHDEP_ID	EM_ARM
 43
 44#define	KERN_ELFSIZE		32
 45#define ARCH_ELFSIZE		32	/* MD native binary size */
 46
 47/* Processor specific relocation types */
 48
 49#define R_ARM_NONE		0
 50#define R_ARM_PC24		1
 51#define R_ARM_ABS32		2
 52#define R_ARM_REL32		3
 53#define R_ARM_PC13		4
 54#define R_ARM_ABS16		5
 55#define R_ARM_ABS12		6
 56#define R_ARM_THM_ABS5		7
 57#define R_ARM_ABS8		8
 58#define R_ARM_SBREL32		9
 59#define R_ARM_THM_PC22		10
 60#define R_ARM_THM_PC8		11
 61#define R_ARM_AMP_VCALL9	12
 62#define R_ARM_SWI24		13
 63#define R_ARM_THM_SWI8		14
 64#define R_ARM_XPC25		15
 65#define R_ARM_THM_XPC22		16
 66
 67/* TLS relocations */
 68#define R_ARM_TLS_DTPMOD32	17	/* ID of module containing symbol */
 69#define R_ARM_TLS_DTPOFF32	18	/* Offset in TLS block */
 70#define R_ARM_TLS_TPOFF32	19	/* Offset in static TLS block */
 71
 72/* 20-31 are reserved for ARM Linux. */
 73#define R_ARM_COPY		20
 74#define R_ARM_GLOB_DAT		21
 75#define	R_ARM_JUMP_SLOT		22
 76#define R_ARM_RELATIVE		23
 77#define	R_ARM_GOTOFF		24
 78#define R_ARM_GOTPC		25
 79#define R_ARM_GOT32		26
 80#define R_ARM_PLT32		27
 81#define R_ARM_CALL		28
 82#define R_ARM_JUMP24		29
 83#define R_ARM_THM_JUMP24	30
 84#define R_ARM_BASE_ABS		31
 85#define R_ARM_ALU_PCREL_7_0	32
 86#define R_ARM_ALU_PCREL_15_8	33
 87#define R_ARM_ALU_PCREL_23_15	34
 88#define R_ARM_ALU_SBREL_11_0	35
 89#define R_ARM_ALU_SBREL_19_12	36
 90#define R_ARM_ALU_SBREL_27_20	37	// depcreated
 91#define R_ARM_TARGET1		38
 92#define R_ARM_SBREL31		39	// deprecated
 93#define R_ARM_V4BX		40
 94#define R_ARM_TARGET2		41
 95#define R_ARM_PREL31		42
 96#define R_ARM_MOVW_ABS_NC	43
 97#define R_ARM_MOVT_ABS		44
 98#define R_ARM_MOVW_PREL_NC	45
 99#define R_ARM_MOVT_PREL		46
100#define R_ARM_THM_MOVW_ABS_NC	47
101#define R_ARM_THM_MOVT_ABS	48
102#define R_ARM_THM_MOVW_PREL_NC	49
103#define R_ARM_THM_MOVT_PREL	50
104
105/* 96-111 are reserved to G++. */
106#define R_ARM_GNU_VTENTRY	100
107#define R_ARM_GNU_VTINHERIT	101
108#define R_ARM_THM_PC11		102
109#define R_ARM_THM_PC9		103
110
111/* More TLS relocations */
112#define R_ARM_TLS_GD32		104	/* PC-rel 32 bit for global dynamic */
113#define R_ARM_TLS_LDM32		105	/* PC-rel 32 bit for local dynamic */
114#define R_ARM_TLS_LDO32		106	/* 32 bit offset relative to TLS */
115#define R_ARM_TLS_IE32		107	/* PC-rel 32 bit for GOT entry of */
116#define R_ARM_TLS_LE32		108
117#define R_ARM_TLS_LDO12		109
118#define R_ARM_TLS_LE12		110
119#define R_ARM_TLS_IE12GP	111
120
121/* 112-127 are reserved for private experiments. */
122
123#define R_ARM_IRELATIVE		160
124
125#define R_ARM_RXPC25		249
126#define R_ARM_RSBREL32		250
127#define R_ARM_THM_RPC22		251
128#define R_ARM_RREL32		252
129#define R_ARM_RABS32		253
130#define R_ARM_RPC24		254
131#define R_ARM_RBASE		255
132
133#define R_TYPE(name)		__CONCAT(R_ARM_,name)
134
135/* Processor specific program header flags */
136#define PF_ARM_SB		0x10000000
137#define PF_ARM_PI		0x20000000
138#define PF_ARM_ENTRY		0x80000000
139
140/* Processor specific program header types */
141#define PT_ARM_EXIDX		(PT_LOPROC + 1)
142
143/* Processor specific section header flags */
144#define SHF_ENTRYSECT		0x10000000
145#define SHF_COMDEF		0x80000000
146
147/* Processor specific symbol types */
148#define STT_ARM_TFUNC		STT_LOPROC
149
150#ifdef _KERNEL
151#ifdef ELFSIZE
152#define	ELF_MD_PROBE_FUNC	ELFNAME2(arm_netbsd,probe)
153#define	ELF_MD_COREDUMP_SETUP	ELFNAME2(arm_netbsd,coredump_setup)
154#endif
155
156struct exec_package;
157
158int arm_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *,
159	vaddr_t *);
160void arm_netbsd_elf32_coredump_setup(struct lwp *, void *);
161#endif
162
163#endif /* _ARM_ELF_MACHDEP_H_ */