Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / bsd / file / dist / src / readelf.h
blobd1fdce594b618310b68a8b78d8a44c74439346cc
1 /* $NetBSD$ */
3 /*
4 * Copyright (c) Christos Zoulas 2003.
5 * All Rights Reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice immediately at the beginning of the file, without modification,
12 * 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.
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 FOR
21 * 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.
30 * @(#)Id: readelf.h,v 1.9 2002/05/16 18:45:56 christos Exp
32 * Provide elf data structures for non-elf machines, allowing file
33 * non-elf hosts to determine if an elf binary is stripped.
34 * Note: cobbled from the linux header file, with modifications
36 #ifndef __fake_elf_h__
37 #define __fake_elf_h__
39 #if HAVE_STDINT_H
40 #include <stdint.h>
41 #endif
43 typedef uint32_t Elf32_Addr;
44 typedef uint32_t Elf32_Off;
45 typedef uint16_t Elf32_Half;
46 typedef uint32_t Elf32_Word;
47 typedef uint8_t Elf32_Char;
49 #if SIZEOF_LONG_LONG != 8
50 #define USE_ARRAY_FOR_64BIT_TYPES
51 typedef uint32_t Elf64_Addr[2];
52 typedef uint32_t Elf64_Off[2];
53 typedef uint32_t Elf64_Xword[2];
54 #else
55 #undef USE_ARRAY_FOR_64BIT_TYPES
56 typedef uint64_t Elf64_Addr;
57 typedef uint64_t Elf64_Off;
58 typedef uint64_t Elf64_Xword;
59 #endif
60 typedef uint16_t Elf64_Half;
61 typedef uint32_t Elf64_Word;
62 typedef uint8_t Elf64_Char;
64 #define EI_NIDENT 16
66 typedef struct {
67 Elf32_Char e_ident[EI_NIDENT];
68 Elf32_Half e_type;
69 Elf32_Half e_machine;
70 Elf32_Word e_version;
71 Elf32_Addr e_entry; /* Entry point */
72 Elf32_Off e_phoff;
73 Elf32_Off e_shoff;
74 Elf32_Word e_flags;
75 Elf32_Half e_ehsize;
76 Elf32_Half e_phentsize;
77 Elf32_Half e_phnum;
78 Elf32_Half e_shentsize;
79 Elf32_Half e_shnum;
80 Elf32_Half e_shstrndx;
81 } Elf32_Ehdr;
83 typedef struct {
84 Elf64_Char e_ident[EI_NIDENT];
85 Elf64_Half e_type;
86 Elf64_Half e_machine;
87 Elf64_Word e_version;
88 Elf64_Addr e_entry; /* Entry point */
89 Elf64_Off e_phoff;
90 Elf64_Off e_shoff;
91 Elf64_Word e_flags;
92 Elf64_Half e_ehsize;
93 Elf64_Half e_phentsize;
94 Elf64_Half e_phnum;
95 Elf64_Half e_shentsize;
96 Elf64_Half e_shnum;
97 Elf64_Half e_shstrndx;
98 } Elf64_Ehdr;
100 /* e_type */
101 #define ET_REL 1
102 #define ET_EXEC 2
103 #define ET_DYN 3
104 #define ET_CORE 4
106 /* e_machine (used only for SunOS 5.x hardware capabilities) */
107 #define EM_SPARC 2
108 #define EM_386 3
109 #define EM_SPARC32PLUS 18
110 #define EM_SPARCV9 43
111 #define EM_IA_64 50
112 #define EM_AMD64 62
114 /* sh_type */
115 #define SHT_SYMTAB 2
116 #define SHT_NOTE 7
117 #define SHT_DYNSYM 11
118 #define SHT_SUNW_cap 0x6ffffff5 /* SunOS 5.x hw/sw capabilites */
120 /* elf type */
121 #define ELFDATANONE 0 /* e_ident[EI_DATA] */
122 #define ELFDATA2LSB 1
123 #define ELFDATA2MSB 2
125 /* elf class */
126 #define ELFCLASSNONE 0
127 #define ELFCLASS32 1
128 #define ELFCLASS64 2
130 /* magic number */
131 #define EI_MAG0 0 /* e_ident[] indexes */
132 #define EI_MAG1 1
133 #define EI_MAG2 2
134 #define EI_MAG3 3
135 #define EI_CLASS 4
136 #define EI_DATA 5
137 #define EI_VERSION 6
138 #define EI_PAD 7
140 #define ELFMAG0 0x7f /* EI_MAG */
141 #define ELFMAG1 'E'
142 #define ELFMAG2 'L'
143 #define ELFMAG3 'F'
144 #define ELFMAG "\177ELF"
146 #define OLFMAG1 'O'
147 #define OLFMAG "\177OLF"
149 typedef struct {
150 Elf32_Word p_type;
151 Elf32_Off p_offset;
152 Elf32_Addr p_vaddr;
153 Elf32_Addr p_paddr;
154 Elf32_Word p_filesz;
155 Elf32_Word p_memsz;
156 Elf32_Word p_flags;
157 Elf32_Word p_align;
158 } Elf32_Phdr;
160 typedef struct {
161 Elf64_Word p_type;
162 Elf64_Word p_flags;
163 Elf64_Off p_offset;
164 Elf64_Addr p_vaddr;
165 Elf64_Addr p_paddr;
166 Elf64_Xword p_filesz;
167 Elf64_Xword p_memsz;
168 Elf64_Xword p_align;
169 } Elf64_Phdr;
171 #define PT_NULL 0 /* p_type */
172 #define PT_LOAD 1
173 #define PT_DYNAMIC 2
174 #define PT_INTERP 3
175 #define PT_NOTE 4
176 #define PT_SHLIB 5
177 #define PT_PHDR 6
178 #define PT_NUM 7
180 typedef struct {
181 Elf32_Word sh_name;
182 Elf32_Word sh_type;
183 Elf32_Word sh_flags;
184 Elf32_Addr sh_addr;
185 Elf32_Off sh_offset;
186 Elf32_Word sh_size;
187 Elf32_Word sh_link;
188 Elf32_Word sh_info;
189 Elf32_Word sh_addralign;
190 Elf32_Word sh_entsize;
191 } Elf32_Shdr;
193 typedef struct {
194 Elf64_Word sh_name;
195 Elf64_Word sh_type;
196 Elf64_Off sh_flags;
197 Elf64_Addr sh_addr;
198 Elf64_Off sh_offset;
199 Elf64_Off sh_size;
200 Elf64_Word sh_link;
201 Elf64_Word sh_info;
202 Elf64_Off sh_addralign;
203 Elf64_Off sh_entsize;
204 } Elf64_Shdr;
206 #define NT_NETBSD_CORE_PROCINFO 1
208 /* Note header in a PT_NOTE section */
209 typedef struct elf_note {
210 Elf32_Word n_namesz; /* Name size */
211 Elf32_Word n_descsz; /* Content size */
212 Elf32_Word n_type; /* Content type */
213 } Elf32_Nhdr;
215 typedef struct {
216 Elf64_Word n_namesz;
217 Elf64_Word n_descsz;
218 Elf64_Word n_type;
219 } Elf64_Nhdr;
221 /* Notes used in ET_CORE */
222 #define NT_PRSTATUS 1
223 #define NT_PRFPREG 2
224 #define NT_PRPSINFO 3
225 #define NT_PRXREG 4
226 #define NT_TASKSTRUCT 4
227 #define NT_PLATFORM 5
228 #define NT_AUXV 6
230 /* Note types used in executables */
231 /* NetBSD executables (name = "NetBSD") */
232 #define NT_NETBSD_VERSION 1
233 #define NT_NETBSD_EMULATION 2
234 #define NT_FREEBSD_VERSION 1
235 #define NT_OPENBSD_VERSION 1
236 #define NT_DRAGONFLY_VERSION 1
237 /* GNU executables (name = "GNU") */
238 #define NT_GNU_VERSION 1
240 /* GNU OS tags */
241 #define GNU_OS_LINUX 0
242 #define GNU_OS_HURD 1
243 #define GNU_OS_SOLARIS 2
244 #define GNU_OS_KFREEBSD 3
245 #define GNU_OS_KNETBSD 4
247 /* SunOS 5.x hardware/software capabilities */
248 typedef struct {
249 Elf32_Word c_tag;
250 union {
251 Elf32_Word c_val;
252 Elf32_Addr c_ptr;
253 } c_un;
254 } Elf32_Cap;
256 typedef struct {
257 Elf64_Xword c_tag;
258 union {
259 Elf64_Xword c_val;
260 Elf64_Addr c_ptr;
261 } c_un;
262 } Elf64_Cap;
264 /* SunOS 5.x hardware/software capability tags */
265 #define CA_SUNW_NULL 0
266 #define CA_SUNW_HW_1 1
267 #define CA_SUNW_SF_1 2
269 /* SunOS 5.x software capabilities */
270 #define SF1_SUNW_FPKNWN 0x01
271 #define SF1_SUNW_FPUSED 0x02
272 #define SF1_SUNW_MASK 0x03
274 /* SunOS 5.x hardware capabilities: sparc */
275 #define AV_SPARC_MUL32 0x0001
276 #define AV_SPARC_DIV32 0x0002
277 #define AV_SPARC_FSMULD 0x0004
278 #define AV_SPARC_V8PLUS 0x0008
279 #define AV_SPARC_POPC 0x0010
280 #define AV_SPARC_VIS 0x0020
281 #define AV_SPARC_VIS2 0x0040
282 #define AV_SPARC_ASI_BLK_INIT 0x0080
283 #define AV_SPARC_FMAF 0x0100
284 #define AV_SPARC_FJFMAU 0x4000
285 #define AV_SPARC_IMA 0x8000
287 /* SunOS 5.x hardware capabilities: 386 */
288 #define AV_386_FPU 0x00000001
289 #define AV_386_TSC 0x00000002
290 #define AV_386_CX8 0x00000004
291 #define AV_386_SEP 0x00000008
292 #define AV_386_AMD_SYSC 0x00000010
293 #define AV_386_CMOV 0x00000020
294 #define AV_386_MMX 0x00000040
295 #define AV_386_AMD_MMX 0x00000080
296 #define AV_386_AMD_3DNow 0x00000100
297 #define AV_386_AMD_3DNowx 0x00000200
298 #define AV_386_FXSR 0x00000400
299 #define AV_386_SSE 0x00000800
300 #define AV_386_SSE2 0x00001000
301 #define AV_386_PAUSE 0x00002000
302 #define AV_386_SSE3 0x00004000
303 #define AV_386_MON 0x00008000
304 #define AV_386_CX16 0x00010000
305 #define AV_386_AHF 0x00020000
306 #define AV_386_TSCP 0x00040000
307 #define AV_386_AMD_SSE4A 0x00080000
308 #define AV_386_POPCNT 0x00100000
309 #define AV_386_AMD_LZCNT 0x00200000
310 #define AV_386_SSSE3 0x00400000
311 #define AV_386_SSE4_1 0x00800000
312 #define AV_386_SSE4_2 0x01000000
314 #endif