xref: /freebsd/sys/arm/include/elf.h (revision 580744621f33383027108364dcadad718df46ffe)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2001 David E. O'Brien
5  * Copyright (c) 1996-1997 John D. Polstra.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * $FreeBSD$
30  */
31 
32 #ifndef _MACHINE_ELF_H_
33 #define	_MACHINE_ELF_H_ 1
34 
35 /*
36  * EABI ELF definitions for the StrongARM architecture.
37  * See "ARM ELF", document no. `SWS ESPC 0003 A-08' for details.
38  */
39 
40 #include <sys/elf32.h>	/* Definitions common to all 32 bit architectures. */
41 
42 #define	__ELF_WORD_SIZE	32	/* Used by <sys/elf_generic.h> */
43 #include <sys/elf_generic.h>
44 
45 typedef struct {        /* Auxiliary vector entry on initial stack */
46 	int     a_type;                 /* Entry type. */
47 	union {
48 		long    a_val;          /* Integer value. */
49 		void    *a_ptr;         /* Address. */
50 		void    (*a_fcn)(void); /* Function pointer (not used). */
51 	} a_un;
52 } Elf32_Auxinfo;
53 
54 __ElfType(Auxinfo);
55 
56 #define	ELF_ARCH	EM_ARM
57 
58 #define	ELF_MACHINE_OK(x) ((x) == EM_ARM)
59 
60 /*
61  * Relocation types.
62  */
63 
64 #define	R_ARM_COUNT	33	/* Count of defined relocation types. */
65 
66 /* Define "machine" characteristics */
67 #define	ELF_TARG_CLASS	ELFCLASS32
68 #ifdef __ARMEB__
69 #define	ELF_TARG_DATA	ELFDATA2MSB
70 #else
71 #define	ELF_TARG_DATA	ELFDATA2LSB
72 #endif
73 #define	ELF_TARG_MACH	EM_ARM
74 #define	ELF_TARG_VER	1
75 
76 /* Defines specific for arm headers */
77 #define	EF_ARM_EABI_VERSION(x) (((x) & EF_ARM_EABIMASK) >> 24)
78 #define	EF_ARM_EABI_VERSION_UNKNOWN 0
79 #define	EF_ARM_EABI_FREEBSD_MIN 4
80 
81 /*
82  * Magic number for the elf trampoline, chosen wisely to be an immediate
83  * value.
84  */
85 #define	MAGIC_TRAMP_NUMBER	0x5c000003
86 
87 #define	ET_DYN_LOAD_ADDR	0x500000
88 
89 /* Flags passed in AT_HWCAP. */
90 #define	HWCAP_SWP		0x00000001	/* Unsupported, never set.    */
91 #define	HWCAP_HALF		0x00000002	/* Always set.                */
92 #define	HWCAP_THUMB		0x00000004
93 #define	HWCAP_26BIT		0x00000008	/* Unsupported, never set.    */
94 #define	HWCAP_FAST_MULT		0x00000010	/* Always set.                */
95 #define	HWCAP_FPA		0x00000020	/* Unsupported, never set.    */
96 #define	HWCAP_VFP		0x00000040
97 #define	HWCAP_EDSP		0x00000080	/* Always set for ARMv6+.     */
98 #define	HWCAP_JAVA		0x00000100	/* Unsupported, never set.    */
99 #define	HWCAP_IWMMXT		0x00000200	/* Unsupported, never set.    */
100 #define	HWCAP_CRUNCH		0x00000400	/* Unsupported, never set.    */
101 #define	HWCAP_THUMBEE		0x00000800
102 #define	HWCAP_NEON		0x00001000
103 #define	HWCAP_VFPv3		0x00002000
104 #define	HWCAP_VFPv3D16		0x00004000
105 #define	HWCAP_TLS		0x00008000	/* Always set for ARMv6+.     */
106 #define	HWCAP_VFPv4		0x00010000
107 #define	HWCAP_IDIVA		0x00020000
108 #define	HWCAP_IDIVT		0x00040000
109 #define	HWCAP_VFPD32		0x00080000
110 #define	HWCAP_IDIV		(HWCAP_IDIVA | HWCAP_IDIVT)
111 #define	HWCAP_LPAE		0x00100000
112 #define	HWCAP_EVTSTRM		0x00200000	/* Not implemented yet.       */
113 
114 
115 /* Flags passed in AT_HWCAP2. */
116 #define	HWCAP2_AES		0x00000001
117 #define	HWCAP2_PMULL		0x00000002
118 #define	HWCAP2_SHA1		0x00000004
119 #define	HWCAP2_SHA2		0x00000008
120 #define	HWCAP2_CRC32		0x00000010
121 
122 #endif /* !_MACHINE_ELF_H_ */
123