2 * Copyright (c) Christos Zoulas 2003.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
28 * @(#)Id: readelf.h,v 1.9 2002/05/16 18:45:56 christos Exp
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
34 #ifndef __fake_elf_h__
35 #define __fake_elf_h__
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;
47 #if SIZEOF_UINT64_T != 8
48 #define USE_ARRAY_FOR_64BIT_TYPES
49 typedef uint32_t Elf64_Addr[2];
50 typedef uint32_t Elf64_Off[2];
51 typedef uint32_t Elf64_Xword[2];
53 typedef uint64_t Elf64_Addr;
54 typedef uint64_t Elf64_Off;
55 typedef uint64_t Elf64_Xword;
57 typedef uint16_t Elf64_Half;
58 typedef uint32_t Elf64_Word;
59 typedef uint8_t Elf64_Char;
64 Elf32_Char e_ident[EI_NIDENT];
68 Elf32_Addr e_entry; /* Entry point */
73 Elf32_Half e_phentsize;
75 Elf32_Half e_shentsize;
77 Elf32_Half e_shstrndx;
81 Elf64_Char e_ident[EI_NIDENT];
85 Elf64_Addr e_entry; /* Entry point */
90 Elf64_Half e_phentsize;
92 Elf64_Half e_shentsize;
94 Elf64_Half e_shstrndx;
104 #define SHT_DYNSYM 11
107 #define ELFDATANONE 0 /* e_ident[EI_DATA] */
108 #define ELFDATA2LSB 1
109 #define ELFDATA2MSB 2
112 #define ELFCLASSNONE 0
117 #define EI_MAG0 0 /* e_ident[] indexes */
126 #define ELFMAG0 0x7f /* EI_MAG */
130 #define ELFMAG "\177ELF"
133 #define OLFMAG "\177OLF"
152 Elf64_Xword p_filesz;
157 #define PT_NULL 0 /* p_type */
175 Elf32_Word sh_addralign;
176 Elf32_Word sh_entsize;
188 Elf64_Off sh_addralign;
189 Elf64_Off sh_entsize;
192 /* Notes used in ET_CORE */
193 #define NT_PRSTATUS 1
195 #define NT_PRPSINFO 3
196 #define NT_TASKSTRUCT 4
198 #define NT_NETBSD_CORE_PROCINFO 1
200 /* Note header in a PT_NOTE section */
201 typedef struct elf_note {
202 Elf32_Word n_namesz; /* Name size */
203 Elf32_Word n_descsz; /* Content size */
204 Elf32_Word n_type; /* Content type */
213 #define NT_PRSTATUS 1
215 #define NT_PRPSINFO 3
217 #define NT_PLATFORM 5
220 /* Note types used in executables */
221 /* NetBSD executables (name = "NetBSD") */
222 #define NT_NETBSD_VERSION 1
223 #define NT_NETBSD_EMULATION 2
224 #define NT_FREEBSD_VERSION 1
225 #define NT_OPENBSD_VERSION 1
226 /* GNU executables (name = "GNU") */
227 #define NT_GNU_VERSION 1
230 #define GNU_OS_LINUX 0
231 #define GNU_OS_HURD 1
232 #define GNU_OS_SOLARIS 2