kernel debug: priv can be NULL early on
[minix.git] / lib / libelf / _libelf_config.h
blobd375868c9d061f0091145f0a1aa6ca266492bd16
1 /*-
2 * Copyright (c) 2008 Joseph Koshy
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
27 #ifdef __FreeBSD__
29 #define LIBELF_VCSID(ID) __FBSDID(ID)
32 * Define LIBELF_{ARCH,BYTEORDER,CLASS} based on the machine architecture.
33 * See also: <machine/elf.h>.
36 #if defined(__amd64__)
38 #define LIBELF_ARCH EM_X86_64
39 #define LIBELF_BYTEORDER ELFDATA2LSB
40 #define LIBELF_CLASS ELFCLASS64
42 #elif defined(__arm__)
44 #define LIBELF_ARCH EM_ARM
45 #if defined(__ARMEB__) /* Big-endian ARM. */
46 #define LIBELF_BYTEORDER ELFDATA2MSB
47 #else
48 #define LIBELF_BYTEORDER ELFDATA2LSB
49 #endif
50 #define LIBELF_CLASS ELFCLASS32
52 #elif defined(__i386__)
54 #define LIBELF_ARCH EM_386
55 #define LIBELF_BYTEORDER ELFDATA2LSB
56 #define LIBELF_CLASS ELFCLASS32
58 #elif defined(__ia64__)
60 #define LIBELF_ARCH EM_IA_64
61 #define LIBELF_BYTEORDER ELFDATA2LSB
62 #define LIBELF_CLASS ELFCLASS64
64 #elif defined(__mips__)
66 #define LIBELF_ARCH EM_MIPS
67 #if defined(__MIPSEB__)
68 #define LIBELF_BYTEORDER ELFDATA2MSB
69 #else
70 #define LIBELF_BYTEORDER ELFDATA2LSB
71 #endif
72 #define LIBELF_CLASS ELFCLASS32
74 #elif defined(__powerpc__)
76 #define LIBELF_ARCH EM_PPC
77 #define LIBELF_BYTEORDER ELFDATA2MSB
78 #define LIBELF_CLASS ELFCLASS32
80 #elif defined(__sparc__)
82 #define LIBELF_ARCH EM_SPARCV9
83 #define LIBELF_BYTEORDER ELFDATA2MSB
84 #define LIBELF_CLASS ELFCLASS64
86 #else
87 #error Unknown FreeBSD architecture.
88 #endif
89 #endif /* __FreeBSD__ */
92 #ifdef __NetBSD__
94 #include <machine/elf_machdep.h>
96 #define LIBELF_VCSID(ID) __RCSID(ID)
98 #if !defined(ARCH_ELFSIZE)
99 #error ARCH_ELFSIZE is not defined.
100 #endif
102 #if ARCH_ELFSIZE == 32
103 #define LIBELF_ARCH ELF32_MACHDEP_ID
104 #define LIBELF_BYTEORDER ELF32_MACHDEP_ENDIANNESS
105 #define LIBELF_CLASS ELFCLASS32
106 #define Elf_Note Elf32_Nhdr
107 #else
108 #define LIBELF_ARCH ELF64_MACHDEP_ID
109 #define LIBELF_BYTEORDER ELF64_MACHDEP_ENDIANNESS
110 #define LIBELF_CLASS ELFCLASS64
111 #define Elf_Note Elf64_Nhdr
112 #endif
114 #endif /* __NetBSD__ */
117 * GNU & Linux compatibility.
119 * `__linux__' is defined in an environment runs the Linux kernel and glibc.
120 * `__GNU__' is defined in an environment runs a GNU kernel (Hurd) and glibc.
121 * `__GLIBC__' is defined for an environment that runs glibc over a non-GNU
122 * kernel such as GNU/kFreeBSD.
125 #if defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)
127 #if defined(__linux__)
129 #include "native-elf-format.h"
131 #define LIBELF_CLASS ELFTC_CLASS
132 #define LIBELF_ARCH ELFTC_ARCH
133 #define LIBELF_BYTEORDER ELFTC_BYTEORDER
135 #endif /* defined(__linux__) */
137 #define LIBELF_VCSID(ID)
139 #if LIBELF_CLASS == ELFCLASS32
140 #define Elf_Note Elf32_Nhdr
141 #elif LIBELF_CLASS == ELFCLASS64
142 #define Elf_Note Elf64_Nhdr
143 #else
144 #error LIBELF_CLASS needs to be one of ELFCLASS32 or ELFCLASS64
145 #endif
147 #define roundup2 roundup
149 #endif /* defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) */
151 #ifdef __minix
153 #define LIBELF_VCSID(ID)
156 * Define LIBELF_{ARCH,BYTEORDER,CLASS} based on the machine architecture.
157 * See also: <machine/elf.h>.
160 #if defined(__amd64__)
162 #define LIBELF_ARCH EM_X86_64
163 #define LIBELF_BYTEORDER ELFDATA2LSB
164 #define LIBELF_CLASS ELFCLASS64
166 #elif defined(__arm__)
168 #define LIBELF_ARCH EM_ARM
169 #if defined(__ARMEB__) /* Big-endian ARM. */
170 #define LIBELF_BYTEORDER ELFDATA2MSB
171 #else
172 #define LIBELF_BYTEORDER ELFDATA2LSB
173 #endif
174 #define LIBELF_CLASS ELFCLASS32
176 #elif defined(__i386__)
178 #define LIBELF_ARCH EM_386
179 #define LIBELF_BYTEORDER ELFDATA2LSB
180 #define LIBELF_CLASS ELFCLASS32
182 #elif defined(__ia64__)
184 #define LIBELF_ARCH EM_IA_64
185 #define LIBELF_BYTEORDER ELFDATA2LSB
186 #define LIBELF_CLASS ELFCLASS64
188 #elif defined(__mips__)
190 #define LIBELF_ARCH EM_MIPS
191 #if defined(__MIPSEB__)
192 #define LIBELF_BYTEORDER ELFDATA2MSB
193 #else
194 #define LIBELF_BYTEORDER ELFDATA2LSB
195 #endif
196 #define LIBELF_CLASS ELFCLASS32
198 #elif defined(__powerpc__)
200 #define LIBELF_ARCH EM_PPC
201 #define LIBELF_BYTEORDER ELFDATA2MSB
202 #define LIBELF_CLASS ELFCLASS32
204 #elif defined(__sparc__)
206 #define LIBELF_ARCH EM_SPARCV9
207 #define LIBELF_BYTEORDER ELFDATA2MSB
208 #define LIBELF_CLASS ELFCLASS64
210 #else
211 #error Unknown MINIX architecture.
212 #endif
213 #endif /* __minix */