xref: /freebsd/sys/powerpc/include/elf.h (revision 5f4c09dd85bff675e0ca63c55ea3c517e0fddfcc)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
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 
30 #ifndef _MACHINE_ELF_H_
31 #define	_MACHINE_ELF_H_ 1
32 
33 /*
34  * EABI ELF definitions for the PowerPC architecture.
35  * See "PowerPC Embedded Application Binary Interface, 32-Bit Impliementation"
36  * [ppc-eabi-1995-01.pdf] for details.
37  */
38 
39 #ifndef __ELF_WORD_SIZE
40 #ifdef __powerpc64__
41 #define	__ELF_WORD_SIZE	64	/* Used by <sys/elf_generic.h> */
42 #else
43 #define	__ELF_WORD_SIZE	32	/* Used by <sys/elf_generic.h> */
44 #endif
45 #endif
46 
47 #include <sys/elf32.h>	/* Definitions common to all 32 bit architectures. */
48 #include <sys/elf64.h>	/* Definitions common to all 64 bit architectures. */
49 #include <sys/elf_generic.h>
50 
51 #if __ELF_WORD_SIZE == 64
52 #define	ELF_ARCH	EM_PPC64
53 #define	ELF_MACHINE_OK(x) ((x) == EM_PPC64)
54 #else
55 #define	ELF_ARCH	EM_PPC
56 #define	ELF_ARCH32	EM_PPC
57 #define	ELF_MACHINE_OK(x) ((x) == EM_PPC)
58 #endif
59 
60 /*
61  * Auxiliary vector entries for passing information to the interpreter.
62  *
63  * The PowerPC supplement to the SVR4 ABI specification names this "auxv_t",
64  * but POSIX lays claim to all symbols ending with "_t".
65  */
66 
67 typedef struct {	/* Auxiliary vector entry on initial stack */
68 	int	a_type;			/* Entry type. */
69 	union {
70 #ifdef __powerpc64__
71 		int	a_val;		/* Integer value */
72 #else
73 		long	a_val;		/* Integer value. */
74 		void	*a_ptr;		/* Address. */
75 		void	(*a_fcn)(void);	/* Function pointer (not used). */
76 #endif
77 	} a_un;
78 } Elf32_Auxinfo;
79 
80 typedef struct {	/* Auxiliary vector entry on initial stack */
81 	long	a_type;			/* Entry type. */
82 	union {
83 		long	a_val;		/* Integer value. */
84 		void	*a_ptr;		/* Address. */
85 		void	(*a_fcn)(void);	/* Function pointer (not used). */
86 	} a_un;
87 } Elf64_Auxinfo;
88 
89 __ElfType(Auxinfo);
90 
91 /*
92  * Relocation types.
93  */
94 
95 #define	R_PPC_COUNT		37	/* Count of defined relocation types. */
96 
97 					/* Count of defined relocation types. */
98 #define	R_PPC_EMB_COUNT		(R_PPC_EMB_RELSDA - R_PPC_EMB_NADDR32 + 1)
99 
100 /* Define "machine" characteristics */
101 #if BYTE_ORDER == LITTLE_ENDIAN
102 #define	ELF_TARG_DATA	ELFDATA2LSB
103 #else
104 #define	ELF_TARG_DATA	ELFDATA2MSB
105 #endif
106 #if __ELF_WORD_SIZE == 64
107 #define	ELF_TARG_CLASS	ELFCLASS64
108 #define	ELF_TARG_MACH	EM_PPC64
109 #define	ELF_TARG_VER	1
110 #else
111 #define	ELF_TARG_CLASS	ELFCLASS32
112 #define	ELF_TARG_MACH	EM_PPC
113 #define	ELF_TARG_VER	1
114 #endif
115 
116 #define	ET_DYN_LOAD_ADDR 0x01010000
117 
118 #define	AT_OLD_NULL		AT_NULL
119 #define	AT_OLD_IGNORE		AT_IGNORE
120 #define	AT_OLD_EXECFD		AT_EXECFD
121 #define	AT_OLD_PHDR		AT_PHDR
122 #define	AT_OLD_PHENT		AT_PHENT
123 #define	AT_OLD_PHNUM		AT_PHNUM
124 #define	AT_OLD_PAGESZ		AT_PAGESZ
125 #define	AT_OLD_BASE		AT_BASE
126 #define	AT_OLD_FLAGS		AT_FLAGS
127 #define	AT_OLD_ENTRY		AT_ENTRY
128 #define	AT_OLD_NOTELF		AT_NOTELF
129 #define	AT_OLD_UID		AT_UID
130 #define	AT_OLD_EUID		AT_EUID
131 #define	AT_OLD_EXECPATH		13
132 #define	AT_OLD_CANARY		14
133 #define	AT_OLD_CANARYLEN	15
134 #define	AT_OLD_OSRELDATE	16
135 #define	AT_OLD_NCPUS		17
136 #define	AT_OLD_PAGESIZES	18
137 #define	AT_OLD_PAGESIZESLEN	19
138 #define	AT_OLD_STACKPROT	21
139 #define	AT_OLD_TIMEKEEP		AT_TIMEKEEP
140 #define	AT_OLD_EHDRFLAGS	AT_EHDRFLAGS
141 #define	AT_OLD_HWCAP		AT_HWCAP
142 #define	AT_OLD_HWCAP2		AT_HWCAP2
143 
144 #define	AT_OLD_COUNT	27	/* Count of defined aux entry types. */
145 
146 #endif /* !_MACHINE_ELF_H_ */
147