1/*-
2 * Copyright (c) 2001 David E. O'Brien
3 * Copyright (c) 1996-1997 John D. Polstra.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: stable/11/sys/arm/include/elf.h 340556 2018-11-18 09:58:36Z kib $
28 */
29
30#ifndef _MACHINE_ELF_H_
31#define	_MACHINE_ELF_H_ 1
32
33/*
34 * EABI ELF definitions for the StrongARM architecture.
35 * See "ARM ELF", document no. `SWS ESPC 0003 A-08' for details.
36 */
37
38#include <sys/elf32.h>	/* Definitions common to all 32 bit architectures. */
39
40#define	__ELF_WORD_SIZE	32	/* Used by <sys/elf_generic.h> */
41#include <sys/elf_generic.h>
42
43typedef struct {        /* Auxiliary vector entry on initial stack */
44	int     a_type;                 /* Entry type. */
45	union {
46		long    a_val;          /* Integer value. */
47		void    *a_ptr;         /* Address. */
48		void    (*a_fcn)(void); /* Function pointer (not used). */
49	} a_un;
50} Elf32_Auxinfo;
51
52__ElfType(Auxinfo);
53
54#define	ELF_ARCH	EM_ARM
55
56#define	ELF_MACHINE_OK(x) ((x) == EM_ARM)
57
58/*
59 * Relocation types.
60 */
61
62/* Values for a_type. */
63#define	AT_NULL		0	/* Terminates the vector. */
64#define	AT_IGNORE	1	/* Ignored entry. */
65#define	AT_EXECFD	2	/* File descriptor of program to load. */
66#define	AT_PHDR		3	/* Program header of program already loaded. */
67#define	AT_PHENT	4	/* Size of each program header entry. */
68#define	AT_PHNUM	5	/* Number of program header entries. */
69#define	AT_PAGESZ	6	/* Page size in bytes. */
70#define	AT_BASE		7	/* Interpreter's base address. */
71#define	AT_FLAGS	8	/* Flags (unused). */
72#define	AT_ENTRY	9	/* Where interpreter should transfer control. */
73#define	AT_NOTELF	10	/* Program is not ELF ?? */
74#define	AT_UID		11	/* Real uid. */
75#define	AT_EUID		12	/* Effective uid. */
76#define	AT_GID		13	/* Real gid. */
77#define	AT_EGID		14	/* Effective gid. */
78#define	AT_EXECPATH	15	/* Path to the executable. */
79#define	AT_CANARY	16	/* Canary for SSP */
80#define	AT_CANARYLEN	17	/* Length of the canary. */
81#define	AT_OSRELDATE	18	/* OSRELDATE. */
82#define	AT_NCPUS	19	/* Number of CPUs. */
83#define	AT_PAGESIZES	20	/* Pagesizes. */
84#define	AT_PAGESIZESLEN	21	/* Number of pagesizes. */
85#define	AT_TIMEKEEP	22	/* Pointer to timehands. */
86#define	AT_STACKPROT	23	/* Initial stack protection. */
87#define	AT_EHDRFLAGS	24	/* e_flags field from elf hdr */
88#define	AT_HWCAP	25	/* CPU feature flags. */
89#define	AT_HWCAP2	26	/* CPU feature flags 2. */
90
91#define	AT_COUNT	27	/* Count of defined aux entry types. */
92
93#define	R_ARM_COUNT	33	/* Count of defined relocation types. */
94
95
96/* Define "machine" characteristics */
97#define	ELF_TARG_CLASS	ELFCLASS32
98#ifdef __ARMEB__
99#define	ELF_TARG_DATA	ELFDATA2MSB
100#else
101#define	ELF_TARG_DATA	ELFDATA2LSB
102#endif
103#define	ELF_TARG_MACH	EM_ARM
104#define	ELF_TARG_VER	1
105
106/* Defines specific for arm headers */
107#define	EF_ARM_EABI_VERSION(x) (((x) & EF_ARM_EABIMASK) >> 24)
108#define	EF_ARM_EABI_VERSION_UNKNOWN 0
109#define	EF_ARM_EABI_FREEBSD_MIN 4
110
111/*
112 * Magic number for the elf trampoline, chosen wisely to be an immediate
113 * value.
114 */
115#define	MAGIC_TRAMP_NUMBER	0x5c000003
116
117#define	ET_DYN_LOAD_ADDR	0x500000
118
119/* Flags passed in AT_HWCAP. */
120#define	HWCAP_SWP		0x00000001	/* Unsupported, never set.    */
121#define	HWCAP_HALF		0x00000002	/* Always set.                */
122#define	HWCAP_THUMB		0x00000004
123#define	HWCAP_26BIT		0x00000008	/* Unsupported, never set.    */
124#define	HWCAP_FAST_MULT		0x00000010	/* Always set.                */
125#define	HWCAP_FPA		0x00000020	/* Unsupported, never set.    */
126#define	HWCAP_VFP		0x00000040
127#define	HWCAP_EDSP		0x00000080	/* Always set for ARMv6+.     */
128#define	HWCAP_JAVA		0x00000100	/* Unsupported, never set.    */
129#define	HWCAP_IWMMXT		0x00000200	/* Unsupported, never set.    */
130#define	HWCAP_CRUNCH		0x00000400	/* Unsupported, never set.    */
131#define	HWCAP_THUMBEE		0x00000800
132#define	HWCAP_NEON		0x00001000
133#define	HWCAP_VFPv3		0x00002000
134#define	HWCAP_VFPv3D16		0x00004000
135#define	HWCAP_TLS		0x00008000	/* Always set for ARMv6+.     */
136#define	HWCAP_VFPv4		0x00010000
137#define	HWCAP_IDIVA		0x00020000
138#define	HWCAP_IDIVT		0x00040000
139#define	HWCAP_VFPD32		0x00080000
140#define	HWCAP_IDIV		(HWCAP_IDIVA | HWCAP_IDIVT)
141#define	HWCAP_LPAE		0x00100000
142#define	HWCAP_EVTSTRM		0x00200000	/* Not implemented yet.       */
143
144
145/* Flags passed in AT_HWCAP2. */
146#define	HWCAP2_AES		0x00000001
147#define	HWCAP2_PMULL		0x00000002
148#define	HWCAP2_SHA1		0x00000004
149#define	HWCAP2_SHA2		0x00000008
150#define	HWCAP2_CRC32		0x00000010
151
152#endif /* !_MACHINE_ELF_H_ */
153