]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/file/readelf.h
This commit was generated by cvs2svn to compensate for changes in r94536,
[FreeBSD/FreeBSD.git] / contrib / file / readelf.h
1 /*
2  * readelf.h 
3  * @(#)$Id: readelf.h,v 1.7 1999/02/14 17:16:11 christos Exp $
4  *
5  * Provide elf data structures for non-elf machines, allowing file
6  * non-elf hosts to determine if an elf binary is stripped.
7  * Note: cobbled from the linux header file, with modifications
8  */
9 #ifndef __fake_elf_h__
10 #define __fake_elf_h__
11
12 typedef uint32_t        Elf32_Addr;
13 typedef uint32_t        Elf32_Off;
14 typedef uint16_t        Elf32_Half;
15 typedef uint32_t        Elf32_Word;
16 typedef uint8_t         Elf32_Char;
17
18 #if SIZEOF_UINT64_T != 8
19 #define USE_ARRAY_FOR_64BIT_TYPES
20 typedef uint32_t        Elf64_Addr[2];
21 typedef uint32_t        Elf64_Off[2];
22 typedef uint32_t        Elf64_Xword[2];
23 #else
24 typedef uint64_t        Elf64_Addr;
25 typedef uint64_t        Elf64_Off;
26 typedef uint64_t        Elf64_Xword;
27 #endif
28 typedef uint16_t        Elf64_Half;
29 typedef uint32_t        Elf64_Word;
30 typedef uint8_t         Elf64_Char;
31
32 #define EI_NIDENT       16
33
34 typedef struct {
35     Elf32_Char  e_ident[EI_NIDENT];
36     Elf32_Half  e_type;
37     Elf32_Half  e_machine;
38     Elf32_Word  e_version;
39     Elf32_Addr  e_entry;  /* Entry point */
40     Elf32_Off   e_phoff;
41     Elf32_Off   e_shoff;
42     Elf32_Word  e_flags;
43     Elf32_Half  e_ehsize;
44     Elf32_Half  e_phentsize;
45     Elf32_Half  e_phnum;
46     Elf32_Half  e_shentsize;
47     Elf32_Half  e_shnum;
48     Elf32_Half  e_shstrndx;
49 } Elf32_Ehdr;
50
51 typedef struct {
52     Elf64_Char  e_ident[EI_NIDENT];
53     Elf64_Half  e_type;
54     Elf64_Half  e_machine;
55     Elf64_Word  e_version;
56     Elf64_Addr  e_entry;  /* Entry point */
57     Elf64_Off   e_phoff;
58     Elf64_Off   e_shoff;
59     Elf64_Word  e_flags;
60     Elf64_Half  e_ehsize;
61     Elf64_Half  e_phentsize;
62     Elf64_Half  e_phnum;
63     Elf64_Half  e_shentsize;
64     Elf64_Half  e_shnum;
65     Elf64_Half  e_shstrndx;
66 } Elf64_Ehdr;
67
68 /* e_type */
69 #define ET_EXEC         2
70 #define ET_CORE         4
71
72 /* sh_type */
73 #define SHT_SYMTAB      2
74 #define SHT_NOTE        7
75 #define SHT_DYNSYM      11
76
77 /* elf type */
78 #define ELFDATANONE     0               /* e_ident[EI_DATA] */
79 #define ELFDATA2LSB     1
80 #define ELFDATA2MSB     2
81
82 /* elf class */
83 #define ELFCLASSNONE    0
84 #define ELFCLASS32      1
85 #define ELFCLASS64      2
86
87 /* magic number */
88 #define EI_MAG0         0               /* e_ident[] indexes */
89 #define EI_MAG1         1
90 #define EI_MAG2         2
91 #define EI_MAG3         3
92 #define EI_CLASS        4
93 #define EI_DATA         5
94 #define EI_VERSION      6
95 #define EI_PAD          7
96
97 #define ELFMAG0         0x7f            /* EI_MAG */
98 #define ELFMAG1         'E'
99 #define ELFMAG2         'L'
100 #define ELFMAG3         'F'
101 #define ELFMAG          "\177ELF"
102
103 #define OLFMAG1         'O'
104 #define OLFMAG          "\177OLF"
105
106 typedef struct {
107     Elf32_Word  p_type;
108     Elf32_Off   p_offset;
109     Elf32_Addr  p_vaddr;
110     Elf32_Addr  p_paddr;
111     Elf32_Word  p_filesz;
112     Elf32_Word  p_memsz;
113     Elf32_Word  p_flags;
114     Elf32_Word  p_align;
115 } Elf32_Phdr;
116
117 typedef struct {
118     Elf64_Word  p_type;
119     Elf64_Word  p_flags;
120     Elf64_Off   p_offset;
121     Elf64_Addr  p_vaddr;
122     Elf64_Addr  p_paddr;
123     Elf64_Xword p_filesz;
124     Elf64_Xword p_memsz;
125     Elf64_Xword p_align;
126 } Elf64_Phdr;
127
128 #define PT_NULL         0               /* p_type */
129 #define PT_LOAD         1
130 #define PT_DYNAMIC      2
131 #define PT_INTERP       3
132 #define PT_NOTE         4
133 #define PT_SHLIB        5
134 #define PT_PHDR         6
135 #define PT_NUM          7
136
137 typedef struct {
138     Elf32_Word  sh_name;
139     Elf32_Word  sh_type;
140     Elf32_Word  sh_flags;
141     Elf32_Addr  sh_addr;
142     Elf32_Off   sh_offset;
143     Elf32_Word  sh_size;
144     Elf32_Word  sh_link;
145     Elf32_Word  sh_info;
146     Elf32_Word  sh_addralign;
147     Elf32_Word  sh_entsize;
148 } Elf32_Shdr;
149
150 typedef struct {
151     Elf64_Word  sh_name;
152     Elf64_Word  sh_type;
153     Elf64_Off   sh_flags;
154     Elf64_Addr  sh_addr;
155     Elf64_Off   sh_offset;
156     Elf64_Off   sh_size;
157     Elf64_Word  sh_link;
158     Elf64_Word  sh_info;
159     Elf64_Off   sh_addralign;
160     Elf64_Off   sh_entsize;
161 } Elf64_Shdr;
162
163 /* Notes used in ET_CORE */
164 #define NT_PRSTATUS     1
165 #define NT_PRFPREG      2
166 #define NT_PRPSINFO     3
167 #define NT_TASKSTRUCT   4
168
169 /* Note header in a PT_NOTE section */
170 typedef struct elf_note {
171     Elf32_Word  n_namesz;       /* Name size */
172     Elf32_Word  n_descsz;       /* Content size */
173     Elf32_Word  n_type;         /* Content type */
174 } Elf32_Nhdr;
175
176 typedef struct {
177     Elf64_Word  n_namesz;
178     Elf64_Word  n_descsz;
179     Elf64_Word  n_type;
180 } Elf64_Nhdr;
181
182 #define NT_PRSTATUS     1
183 #define NT_PRFPREG      2
184 #define NT_PRPSINFO     3
185 #define NT_PRXREG       4
186 #define NT_PLATFORM     5
187 #define NT_AUXV         6
188
189 #endif