xref: /freebsd/sys/arm/include/elf.h (revision ce4210d673a2afd61732fb58a9df4b037b157f1a)
1d4cfb421SDavid E. O'Brien /*-
2d4cfb421SDavid E. O'Brien  * Copyright (c) 2001 David E. O'Brien
3d4cfb421SDavid E. O'Brien  * Copyright (c) 1996-1997 John D. Polstra.
4d4cfb421SDavid E. O'Brien  * All rights reserved.
5d4cfb421SDavid E. O'Brien  *
6d4cfb421SDavid E. O'Brien  * Redistribution and use in source and binary forms, with or without
7d4cfb421SDavid E. O'Brien  * modification, are permitted provided that the following conditions
8d4cfb421SDavid E. O'Brien  * are met:
9d4cfb421SDavid E. O'Brien  * 1. Redistributions of source code must retain the above copyright
10d4cfb421SDavid E. O'Brien  *    notice, this list of conditions and the following disclaimer.
11d4cfb421SDavid E. O'Brien  * 2. Redistributions in binary form must reproduce the above copyright
12d4cfb421SDavid E. O'Brien  *    notice, this list of conditions and the following disclaimer in the
13d4cfb421SDavid E. O'Brien  *    documentation and/or other materials provided with the distribution.
14d4cfb421SDavid E. O'Brien  *
15d4cfb421SDavid E. O'Brien  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16d4cfb421SDavid E. O'Brien  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17d4cfb421SDavid E. O'Brien  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18d4cfb421SDavid E. O'Brien  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19d4cfb421SDavid E. O'Brien  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20d4cfb421SDavid E. O'Brien  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21d4cfb421SDavid E. O'Brien  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22d4cfb421SDavid E. O'Brien  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23d4cfb421SDavid E. O'Brien  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24d4cfb421SDavid E. O'Brien  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25d4cfb421SDavid E. O'Brien  * SUCH DAMAGE.
26d4cfb421SDavid E. O'Brien  *
27d4cfb421SDavid E. O'Brien  * $FreeBSD$
28d4cfb421SDavid E. O'Brien  */
29d4cfb421SDavid E. O'Brien 
30d4cfb421SDavid E. O'Brien #ifndef _MACHINE_ELF_H_
31d4cfb421SDavid E. O'Brien #define	_MACHINE_ELF_H_ 1
32d4cfb421SDavid E. O'Brien 
33d4cfb421SDavid E. O'Brien /*
34d4cfb421SDavid E. O'Brien  * EABI ELF definitions for the StrongARM architecture.
35d4cfb421SDavid E. O'Brien  * See "ARM ELF", document no. `SWS ESPC 0003 A-08' for details.
36d4cfb421SDavid E. O'Brien  */
37d4cfb421SDavid E. O'Brien 
38d4cfb421SDavid E. O'Brien #include <sys/elf32.h>	/* Definitions common to all 32 bit architectures. */
39d4cfb421SDavid E. O'Brien 
40d4cfb421SDavid E. O'Brien #define	__ELF_WORD_SIZE	32	/* Used by <sys/elf_generic.h> */
41d4cfb421SDavid E. O'Brien #include <sys/elf_generic.h>
42d4cfb421SDavid E. O'Brien 
436e695cecSOlivier Houchard typedef struct {        /* Auxiliary vector entry on initial stack */
446e695cecSOlivier Houchard 	int     a_type;                 /* Entry type. */
456e695cecSOlivier Houchard 	union {
466e695cecSOlivier Houchard 		long    a_val;          /* Integer value. */
476e695cecSOlivier Houchard 		void    *a_ptr;         /* Address. */
486e695cecSOlivier Houchard 		void    (*a_fcn)(void); /* Function pointer (not used). */
496e695cecSOlivier Houchard 	} a_un;
506e695cecSOlivier Houchard } Elf32_Auxinfo;
516e695cecSOlivier Houchard 
526e695cecSOlivier Houchard __ElfType(Auxinfo);
536e695cecSOlivier Houchard 
54d4cfb421SDavid E. O'Brien #define	ELF_ARCH	EM_ARM
55d4cfb421SDavid E. O'Brien 
56d4cfb421SDavid E. O'Brien #define	ELF_MACHINE_OK(x) ((x) == EM_ARM)
57d4cfb421SDavid E. O'Brien 
58d4cfb421SDavid E. O'Brien /*
59d4cfb421SDavid E. O'Brien  * Relocation types.
60d4cfb421SDavid E. O'Brien  */
61d4cfb421SDavid E. O'Brien 
626e695cecSOlivier Houchard /* Values for a_type. */
636e695cecSOlivier Houchard #define AT_NULL         0       /* Terminates the vector. */
646e695cecSOlivier Houchard #define AT_IGNORE       1       /* Ignored entry. */
656e695cecSOlivier Houchard #define AT_EXECFD       2       /* File descriptor of program to load. */
666e695cecSOlivier Houchard #define AT_PHDR         3       /* Program header of program already loaded. */
676e695cecSOlivier Houchard #define AT_PHENT        4       /* Size of each program header entry. */
686e695cecSOlivier Houchard #define AT_PHNUM        5       /* Number of program header entries. */
696e695cecSOlivier Houchard #define AT_PAGESZ       6       /* Page size in bytes. */
706e695cecSOlivier Houchard #define AT_BASE         7       /* Interpreter's base address. */
716e695cecSOlivier Houchard #define AT_FLAGS        8       /* Flags (unused). */
726e695cecSOlivier Houchard #define AT_ENTRY        9       /* Where interpreter should transfer control. */
736e695cecSOlivier Houchard 
746e695cecSOlivier Houchard #define AT_BRK          10      /* Starting point for sbrk and brk. */
756e695cecSOlivier Houchard #define AT_DEBUG        11      /* Debugging level. */
766e695cecSOlivier Houchard 
776e695cecSOlivier Houchard #define AT_NOTELF       10      /* Program is not ELF ?? */
786e695cecSOlivier Houchard #define AT_UID          11      /* Real uid. */
796e695cecSOlivier Houchard #define AT_EUID         12      /* Effective uid. */
806e695cecSOlivier Houchard #define AT_GID          13      /* Real gid. */
816e695cecSOlivier Houchard #define AT_EGID         14      /* Effective gid. */
826e695cecSOlivier Houchard 
836e695cecSOlivier Houchard #define AT_COUNT        15      /* Count of defined aux entry types. */
846e695cecSOlivier Houchard 
85d4cfb421SDavid E. O'Brien #define	R_ARM_NONE		0	/* No relocation. */
86d4cfb421SDavid E. O'Brien #define	R_ARM_PC24		1
87d4cfb421SDavid E. O'Brien #define	R_ARM_ABS32		2
88d4cfb421SDavid E. O'Brien #define	R_ARM_REL32		3
89d4cfb421SDavid E. O'Brien #define	R_ARM_PC13		4
90d4cfb421SDavid E. O'Brien #define	R_ARM_ABS16		5
91d4cfb421SDavid E. O'Brien #define	R_ARM_ABS12		6
92d4cfb421SDavid E. O'Brien #define	R_ARM_THM_ABS5		7
93d4cfb421SDavid E. O'Brien #define	R_ARM_ABS8		8
94d4cfb421SDavid E. O'Brien #define	R_ARM_SBREL32		9
95d4cfb421SDavid E. O'Brien #define	R_ARM_THM_PC22		10
96d4cfb421SDavid E. O'Brien #define	R_ARM_THM_PC8		11
97d4cfb421SDavid E. O'Brien #define	R_ARM_AMP_VCALL9	12
98d4cfb421SDavid E. O'Brien #define	R_ARM_SWI24		13
99d4cfb421SDavid E. O'Brien #define	R_ARM_THM_SWI8		14
100d4cfb421SDavid E. O'Brien #define	R_ARM_XPC25		15
101d4cfb421SDavid E. O'Brien #define	R_ARM_THM_XPC22		16
102d4cfb421SDavid E. O'Brien #define	R_ARM_COPY		20	/* Copy data from shared object. */
103d4cfb421SDavid E. O'Brien #define	R_ARM_GLOB_DAT		21	/* Set GOT entry to data address. */
104d4cfb421SDavid E. O'Brien #define	R_ARM_JUMP_SLOT		22	/* Set GOT entry to code address. */
105d4cfb421SDavid E. O'Brien #define	R_ARM_RELATIVE		23	/* Add load address of shared object. */
1066e695cecSOlivier Houchard #define	R_ARM_GOTOFF		24	/* Add GOT-relative symbol address. */
107d4cfb421SDavid E. O'Brien #define	R_ARM_GOTPC		25	/* Add PC-relative GOT table address. */
108d4cfb421SDavid E. O'Brien #define	R_ARM_GOT32		26	/* Add PC-relative GOT offset. */
109d4cfb421SDavid E. O'Brien #define	R_ARM_PLT32		27	/* Add PC-relative PLT offset. */
110d4cfb421SDavid E. O'Brien #define	R_ARM_GNU_VTENTRY	100
111d4cfb421SDavid E. O'Brien #define	R_ARM_GNU_VTINHERIT	101
112d4cfb421SDavid E. O'Brien #define	R_ARM_RSBREL32		250
113d4cfb421SDavid E. O'Brien #define	R_ARM_THM_RPC22		251
114d4cfb421SDavid E. O'Brien #define	R_ARM_RREL32		252
115d4cfb421SDavid E. O'Brien #define	R_ARM_RABS32		253
116d4cfb421SDavid E. O'Brien #define	R_ARM_RPC24		254
117d4cfb421SDavid E. O'Brien #define	R_ARM_RBASE		255
118d4cfb421SDavid E. O'Brien 
119d4cfb421SDavid E. O'Brien #define	R_ARM_COUNT		33	/* Count of defined relocation types. */
120d4cfb421SDavid E. O'Brien 
121d4cfb421SDavid E. O'Brien 
122d4cfb421SDavid E. O'Brien /* Define "machine" characteristics */
123d4cfb421SDavid E. O'Brien #define	ELF_TARG_CLASS	ELFCLASS32
124d4cfb421SDavid E. O'Brien #define	ELF_TARG_DATA	ELFDATA2LSB
125d4cfb421SDavid E. O'Brien #define	ELF_TARG_MACH	EM_ARM
126d4cfb421SDavid E. O'Brien #define	ELF_TARG_VER	1
127d4cfb421SDavid E. O'Brien 
128ce4210d6SOlivier Houchard /*
129ce4210d6SOlivier Houchard  * Magic number for the elf trampoline, chosen wisely to be an immediate
130ce4210d6SOlivier Houchard  * value.
131ce4210d6SOlivier Houchard  */
132ce4210d6SOlivier Houchard #define MAGIC_TRAMP_NUMBER	0x5c000003
133d4cfb421SDavid E. O'Brien #endif /* !_MACHINE_ELF_H_ */
134