xref: /freebsd/sys/arm64/include/elf.h (revision 9dcf90f8ad1ae245976e995c10f1b3051e9f1405)
1412042e2SAndrew Turner /*-
2412042e2SAndrew Turner  * Copyright (c) 1996-1997 John D. Polstra.
3412042e2SAndrew Turner  * All rights reserved.
4412042e2SAndrew Turner  *
5412042e2SAndrew Turner  * Redistribution and use in source and binary forms, with or without
6412042e2SAndrew Turner  * modification, are permitted provided that the following conditions
7412042e2SAndrew Turner  * are met:
8412042e2SAndrew Turner  * 1. Redistributions of source code must retain the above copyright
9412042e2SAndrew Turner  *    notice, this list of conditions and the following disclaimer.
10412042e2SAndrew Turner  * 2. Redistributions in binary form must reproduce the above copyright
11412042e2SAndrew Turner  *    notice, this list of conditions and the following disclaimer in the
12412042e2SAndrew Turner  *    documentation and/or other materials provided with the distribution.
13412042e2SAndrew Turner  *
14412042e2SAndrew Turner  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15412042e2SAndrew Turner  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16412042e2SAndrew Turner  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17412042e2SAndrew Turner  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18412042e2SAndrew Turner  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19412042e2SAndrew Turner  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20412042e2SAndrew Turner  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21412042e2SAndrew Turner  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22412042e2SAndrew Turner  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23412042e2SAndrew Turner  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24412042e2SAndrew Turner  * SUCH DAMAGE.
25412042e2SAndrew Turner  *
26412042e2SAndrew Turner  * $FreeBSD$
27412042e2SAndrew Turner  */
28412042e2SAndrew Turner 
29412042e2SAndrew Turner #ifndef	_MACHINE_ELF_H_
30412042e2SAndrew Turner #define	_MACHINE_ELF_H_
31412042e2SAndrew Turner 
32412042e2SAndrew Turner /*
33412042e2SAndrew Turner  * ELF definitions for the AArch64 architecture.
34412042e2SAndrew Turner  */
35412042e2SAndrew Turner 
36412042e2SAndrew Turner #include <sys/elf32.h>	/* Definitions common to all 32 bit architectures. */
37412042e2SAndrew Turner #include <sys/elf64.h>	/* Definitions common to all 64 bit architectures. */
38412042e2SAndrew Turner 
39*9dcf90f8SEd Schouten #ifndef __ELF_WORD_SIZE
40412042e2SAndrew Turner #define	__ELF_WORD_SIZE	64	/* Used by <sys/elf_generic.h> */
41*9dcf90f8SEd Schouten #endif
42*9dcf90f8SEd Schouten 
43412042e2SAndrew Turner #include <sys/elf_generic.h>
44412042e2SAndrew Turner 
45412042e2SAndrew Turner /*
46412042e2SAndrew Turner  * Auxiliary vector entries for passing information to the interpreter.
47412042e2SAndrew Turner  */
48412042e2SAndrew Turner 
49412042e2SAndrew Turner typedef struct {	/* Auxiliary vector entry on initial stack */
50412042e2SAndrew Turner 	int	a_type;			/* Entry type. */
51412042e2SAndrew Turner 	union {
52412042e2SAndrew Turner 		int	a_val;		/* Integer value. */
53412042e2SAndrew Turner 	} a_un;
54412042e2SAndrew Turner } Elf32_Auxinfo;
55412042e2SAndrew Turner 
56412042e2SAndrew Turner typedef struct {	/* Auxiliary vector entry on initial stack */
57412042e2SAndrew Turner 	long	a_type;			/* Entry type. */
58412042e2SAndrew Turner 	union {
59412042e2SAndrew Turner 		long	a_val;		/* Integer value. */
60412042e2SAndrew Turner 		void	*a_ptr;		/* Address. */
61412042e2SAndrew Turner 		void	(*a_fcn)(void);	/* Function pointer (not used). */
62412042e2SAndrew Turner 	} a_un;
63412042e2SAndrew Turner } Elf64_Auxinfo;
64412042e2SAndrew Turner 
65412042e2SAndrew Turner __ElfType(Auxinfo);
66412042e2SAndrew Turner 
67412042e2SAndrew Turner #define	ELF_ARCH	EM_AARCH64
68412042e2SAndrew Turner 
69412042e2SAndrew Turner #define	ELF_MACHINE_OK(x) ((x) == (ELF_ARCH))
70412042e2SAndrew Turner 
71412042e2SAndrew Turner /* Values for a_type. */
72412042e2SAndrew Turner #define	AT_NULL		0	/* Terminates the vector. */
73412042e2SAndrew Turner #define	AT_IGNORE	1	/* Ignored entry. */
74412042e2SAndrew Turner #define	AT_EXECFD	2	/* File descriptor of program to load. */
75412042e2SAndrew Turner #define	AT_PHDR		3	/* Program header of program already loaded. */
76412042e2SAndrew Turner #define	AT_PHENT	4	/* Size of each program header entry. */
77412042e2SAndrew Turner #define	AT_PHNUM	5	/* Number of program header entries. */
78412042e2SAndrew Turner #define	AT_PAGESZ	6	/* Page size in bytes. */
79412042e2SAndrew Turner #define	AT_BASE		7	/* Interpreter's base address. */
80412042e2SAndrew Turner #define	AT_FLAGS	8	/* Flags (unused). */
81412042e2SAndrew Turner #define	AT_ENTRY	9	/* Where interpreter should transfer control. */
82412042e2SAndrew Turner #define	AT_NOTELF	10	/* Program is not ELF ?? */
83412042e2SAndrew Turner #define	AT_UID		11	/* Real uid. */
84412042e2SAndrew Turner #define	AT_EUID		12	/* Effective uid. */
85412042e2SAndrew Turner #define	AT_GID		13	/* Real gid. */
86412042e2SAndrew Turner #define	AT_EGID		14	/* Effective gid. */
87412042e2SAndrew Turner #define	AT_EXECPATH	15	/* Path to the executable. */
88412042e2SAndrew Turner #define	AT_CANARY	16	/* Canary for SSP */
89412042e2SAndrew Turner #define	AT_CANARYLEN	17	/* Length of the canary. */
90412042e2SAndrew Turner #define	AT_OSRELDATE	18	/* OSRELDATE. */
91412042e2SAndrew Turner #define	AT_NCPUS	19	/* Number of CPUs. */
92412042e2SAndrew Turner #define	AT_PAGESIZES	20	/* Pagesizes. */
93412042e2SAndrew Turner #define	AT_PAGESIZESLEN	21	/* Number of pagesizes. */
94412042e2SAndrew Turner #define	AT_TIMEKEEP	22	/* Pointer to timehands. */
95412042e2SAndrew Turner #define	AT_STACKPROT	23	/* Initial stack protection. */
96c2f37b92SJohn Baldwin #define	AT_EHDRFLAGS	24	/* e_flags field from elf hdr */
97c2f37b92SJohn Baldwin #define	AT_HWCAP	25	/* CPU feature flags. */
98904d8c49SMichal Meloun #define	AT_HWCAP2	26	/* CPU feature flags 2. */
99412042e2SAndrew Turner 
100904d8c49SMichal Meloun #define	AT_COUNT	27	/* Count of defined aux entry types. */
101412042e2SAndrew Turner 
102412042e2SAndrew Turner /* Define "machine" characteristics */
103*9dcf90f8SEd Schouten #if __ELF_WORD_SIZE == 64
104412042e2SAndrew Turner #define	ELF_TARG_CLASS	ELFCLASS64
105412042e2SAndrew Turner #define	ELF_TARG_DATA	ELFDATA2LSB
106412042e2SAndrew Turner #define	ELF_TARG_MACH	EM_AARCH64
107412042e2SAndrew Turner #define	ELF_TARG_VER	1
108*9dcf90f8SEd Schouten #else
109*9dcf90f8SEd Schouten #define	ELF_TARG_CLASS	ELFCLASS32
110*9dcf90f8SEd Schouten #define	ELF_TARG_DATA	ELFDATA2LSB
111*9dcf90f8SEd Schouten #define	ELF_TARG_MACH	EM_ARM
112*9dcf90f8SEd Schouten #define	ELF_TARG_VER	1
113*9dcf90f8SEd Schouten #endif
114412042e2SAndrew Turner 
115412042e2SAndrew Turner #define	ET_DYN_LOAD_ADDR 0x100000
116412042e2SAndrew Turner 
117412042e2SAndrew Turner #endif /* !_MACHINE_ELF_H_ */
118