xref: /freebsd/sys/powerpc/include/elf.h (revision 640235e2c2ba32947f7c59d168437ffa1280f1e6)
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$
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 		long	a_val;		/* Integer value. */
71 		void	*a_ptr;		/* Address. */
72 		void	(*a_fcn)(void);	/* Function pointer (not used). */
73 	} a_un;
74 } Elf32_Auxinfo;
75 
76 typedef struct {	/* Auxiliary vector entry on initial stack */
77 	long	a_type;			/* Entry type. */
78 	union {
79 		long	a_val;		/* Integer value. */
80 		void	*a_ptr;		/* Address. */
81 		void	(*a_fcn)(void);	/* Function pointer (not used). */
82 	} a_un;
83 } Elf64_Auxinfo;
84 
85 __ElfType(Auxinfo);
86 
87 /* Values for a_type. */
88 #define	AT_NULL		0	/* Terminates the vector. */
89 #define	AT_IGNORE	1	/* Ignored entry. */
90 #define	AT_EXECFD	2	/* File descriptor of program to load. */
91 #define	AT_PHDR		3	/* Program header of program already loaded. */
92 #define	AT_PHENT	4	/* Size of each program header entry. */
93 #define	AT_PHNUM	5	/* Number of program header entries. */
94 #define	AT_PAGESZ	6	/* Page size in bytes. */
95 #define	AT_BASE		7	/* Interpreter's base address. */
96 #define	AT_FLAGS	8	/* Flags (unused for PowerPC). */
97 #define	AT_ENTRY	9	/* Where interpreter should transfer control. */
98 #define	AT_DCACHEBSIZE	10	/* Data cache block size for the processor. */
99 #define	AT_ICACHEBSIZE	11	/* Instruction cache block size for the uP. */
100 #define	AT_UCACHEBSIZE	12	/* Cache block size, or `0' if cache not unified. */
101 #define	AT_EXECPATH	13	/* Path to the executable. */
102 #define	AT_CANARY	14	/* Canary for SSP */
103 #define	AT_CANARYLEN	15	/* Length of the canary. */
104 #define	AT_OSRELDATE	16	/* OSRELDATE. */
105 #define	AT_NCPUS	17	/* Number of CPUs. */
106 #define	AT_PAGESIZES	18	/* Pagesizes. */
107 #define	AT_PAGESIZESLEN	19	/* Number of pagesizes. */
108 #define	AT_STACKPROT	21	/* Initial stack protection. */
109 #define	AT_TIMEKEEP	22	/* Pointer to timehands. */
110 
111 #define	AT_COUNT	23	/* Count of defined aux entry types. */
112 
113 /*
114  * Relocation types.
115  */
116 
117 #define	R_PPC_COUNT		37	/* Count of defined relocation types. */
118 
119 					/* Count of defined relocation types. */
120 #define	R_PPC_EMB_COUNT		(R_PPC_EMB_RELSDA - R_PPC_EMB_NADDR32 + 1)
121 
122 /* Define "machine" characteristics */
123 #if __ELF_WORD_SIZE == 64
124 #define	ELF_TARG_CLASS	ELFCLASS64
125 #define	ELF_TARG_DATA	ELFDATA2MSB
126 #define	ELF_TARG_MACH	EM_PPC64
127 #define	ELF_TARG_VER	1
128 #else
129 #define	ELF_TARG_CLASS	ELFCLASS32
130 #define	ELF_TARG_DATA	ELFDATA2MSB
131 #define	ELF_TARG_MACH	EM_PPC
132 #define	ELF_TARG_VER	1
133 #endif
134 
135 #define	ET_DYN_LOAD_ADDR 0x01010000
136 
137 #endif /* !_MACHINE_ELF_H_ */
138