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