]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/powerpc/include/elf.h
MFV r337161: 9512 zfs remap poolname@snapname coredumps
[FreeBSD/FreeBSD.git] / sys / powerpc / include / elf.h
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 PowerPC architecture.
37  * See "PowerPC Embedded Application Binary Interface, 32-Bit Impliementation"
38  * [ppc-eabi-1995-01.pdf] for details.
39  */
40
41 #ifndef __ELF_WORD_SIZE
42 #ifdef __powerpc64__
43 #define __ELF_WORD_SIZE 64      /* Used by <sys/elf_generic.h> */
44 #else
45 #define __ELF_WORD_SIZE 32      /* Used by <sys/elf_generic.h> */
46 #endif
47 #endif
48
49 #include <sys/elf32.h>  /* Definitions common to all 32 bit architectures. */
50 #include <sys/elf64.h>  /* Definitions common to all 64 bit architectures. */
51 #include <sys/elf_generic.h>
52
53 #if __ELF_WORD_SIZE == 64
54 #define ELF_ARCH        EM_PPC64
55 #define ELF_MACHINE_OK(x) ((x) == EM_PPC64)
56 #else
57 #define ELF_ARCH        EM_PPC
58 #define ELF_ARCH32      EM_PPC
59 #define ELF_MACHINE_OK(x) ((x) == EM_PPC)
60 #endif
61
62 /*
63  * Auxiliary vector entries for passing information to the interpreter.
64  *
65  * The PowerPC supplement to the SVR4 ABI specification names this "auxv_t",
66  * but POSIX lays claim to all symbols ending with "_t".
67  */
68
69 typedef struct {        /* Auxiliary vector entry on initial stack */
70         int     a_type;                 /* Entry type. */
71         union {
72 #ifdef __powerpc64__
73                 int     a_val;          /* Integer value */
74 #else
75                 long    a_val;          /* Integer value. */
76                 void    *a_ptr;         /* Address. */
77                 void    (*a_fcn)(void); /* Function pointer (not used). */
78 #endif
79         } a_un;
80 } Elf32_Auxinfo;
81
82 typedef struct {        /* Auxiliary vector entry on initial stack */
83         long    a_type;                 /* Entry type. */
84         union {
85                 long    a_val;          /* Integer value. */
86                 void    *a_ptr;         /* Address. */
87                 void    (*a_fcn)(void); /* Function pointer (not used). */
88         } a_un;
89 } Elf64_Auxinfo;
90
91 __ElfType(Auxinfo);
92
93 /* Values for a_type. */
94 #define AT_NULL         0       /* Terminates the vector. */
95 #define AT_IGNORE       1       /* Ignored entry. */
96 #define AT_EXECFD       2       /* File descriptor of program to load. */
97 #define AT_PHDR         3       /* Program header of program already loaded. */
98 #define AT_PHENT        4       /* Size of each program header entry. */
99 #define AT_PHNUM        5       /* Number of program header entries. */
100 #define AT_PAGESZ       6       /* Page size in bytes. */
101 #define AT_BASE         7       /* Interpreter's base address. */
102 #define AT_FLAGS        8       /* Flags (unused for PowerPC). */
103 #define AT_ENTRY        9       /* Where interpreter should transfer control. */
104 #define AT_DCACHEBSIZE  10      /* Data cache block size for the processor. */
105 #define AT_ICACHEBSIZE  11      /* Instruction cache block size for the uP. */
106 #define AT_UCACHEBSIZE  12      /* Cache block size, or `0' if cache not unified. */
107 #define AT_EXECPATH     13      /* Path to the executable. */
108 #define AT_CANARY       14      /* Canary for SSP */
109 #define AT_CANARYLEN    15      /* Length of the canary. */
110 #define AT_OSRELDATE    16      /* OSRELDATE. */
111 #define AT_NCPUS        17      /* Number of CPUs. */
112 #define AT_PAGESIZES    18      /* Pagesizes. */
113 #define AT_PAGESIZESLEN 19      /* Number of pagesizes. */
114 #define AT_STACKPROT    21      /* Initial stack protection. */
115 #define AT_TIMEKEEP     22      /* Pointer to timehands. */
116 #define AT_EHDRFLAGS    24      /* e_flags field from elf hdr */
117 #define AT_HWCAP        25      /* CPU feature flags. */
118 #define AT_HWCAP2       26      /* CPU feature flags 2. */
119
120 #define AT_COUNT        27      /* Count of defined aux entry types. */
121
122 /*
123  * Relocation types.
124  */
125
126 #define R_PPC_COUNT             37      /* Count of defined relocation types. */
127
128                                         /* Count of defined relocation types. */
129 #define R_PPC_EMB_COUNT         (R_PPC_EMB_RELSDA - R_PPC_EMB_NADDR32 + 1)
130
131 /* Define "machine" characteristics */
132 #if __ELF_WORD_SIZE == 64
133 #define ELF_TARG_CLASS  ELFCLASS64
134 #define ELF_TARG_DATA   ELFDATA2MSB
135 #define ELF_TARG_MACH   EM_PPC64
136 #define ELF_TARG_VER    1
137 #else
138 #define ELF_TARG_CLASS  ELFCLASS32
139 #define ELF_TARG_DATA   ELFDATA2MSB
140 #define ELF_TARG_MACH   EM_PPC
141 #define ELF_TARG_VER    1
142 #endif
143
144 #define ET_DYN_LOAD_ADDR 0x01010000
145
146 #endif /* !_MACHINE_ELF_H_ */