Rizin
unix-like reverse engineering framework and cli tools
external.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 1991, 1992, 1993, 1995, 1997, 1998, 1999, 2001, 2003, 2005 Free Software Foundation, Inc.
2 // SPDX-License-Identifier: GPL-2.0-or-later
3 
4 /* ELF support for BFD.
5  Copyright 1991, 1992, 1993, 1995, 1997, 1998, 1999, 2001, 2003, 2005
6  Free Software Foundation, Inc.
7 
8  Written by Fred Fish @ Cygnus Support, from information published
9  in "UNIX System V Release 4, Programmers Guide: ANSI C and
10  Programming Support Tools".
11 
12 This file is part of BFD, the Binary File Descriptor library.
13 
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18 
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23 
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
27 
28 /* This file is part of ELF support for BFD, and contains the portions
29  that describe how ELF is represented externally by the BFD library.
30  I.E. it describes the in-file representation of ELF. It requires
31  the elf/common.h file which contains the portions that are common to
32  both the internal and external representations. */
33 
34 /* The 64-bit stuff is kind of random. Perhaps someone will publish a
35  spec someday. */
36 
37 #ifndef _ELF_EXTERNAL_H
38 #define _ELF_EXTERNAL_H
39 
40 /* ELF Header (32-bit implementations) */
41 
42 typedef struct {
43  unsigned char e_ident[16]; /* ELF "magic number" */
44  unsigned char e_type[2]; /* Identifies object file type */
45  unsigned char e_machine[2]; /* Specifies required architecture */
46  unsigned char e_version[4]; /* Identifies object file version */
47  unsigned char e_entry[4]; /* Entry point virtual address */
48  unsigned char e_phoff[4]; /* Program header table file offset */
49  unsigned char e_shoff[4]; /* Section header table file offset */
50  unsigned char e_flags[4]; /* Processor-specific flags */
51  unsigned char e_ehsize[2]; /* ELF header size in bytes */
52  unsigned char e_phentsize[2]; /* Program header table entry size */
53  unsigned char e_phnum[2]; /* Program header table entry count */
54  unsigned char e_shentsize[2]; /* Section header table entry size */
55  unsigned char e_shnum[2]; /* Section header table entry count */
56  unsigned char e_shstrndx[2]; /* Section header string table index */
58 
59 typedef struct {
60  unsigned char e_ident[16]; /* ELF "magic number" */
61  unsigned char e_type[2]; /* Identifies object file type */
62  unsigned char e_machine[2]; /* Specifies required architecture */
63  unsigned char e_version[4]; /* Identifies object file version */
64  unsigned char e_entry[8]; /* Entry point virtual address */
65  unsigned char e_phoff[8]; /* Program header table file offset */
66  unsigned char e_shoff[8]; /* Section header table file offset */
67  unsigned char e_flags[4]; /* Processor-specific flags */
68  unsigned char e_ehsize[2]; /* ELF header size in bytes */
69  unsigned char e_phentsize[2]; /* Program header table entry size */
70  unsigned char e_phnum[2]; /* Program header table entry count */
71  unsigned char e_shentsize[2]; /* Section header table entry size */
72  unsigned char e_shnum[2]; /* Section header table entry count */
73  unsigned char e_shstrndx[2]; /* Section header string table index */
75 
76 /* Program header */
77 
78 typedef struct {
79  unsigned char p_type[4]; /* Identifies program segment type */
80  unsigned char p_offset[4]; /* Segment file offset */
81  unsigned char p_vaddr[4]; /* Segment virtual address */
82  unsigned char p_paddr[4]; /* Segment physical address */
83  unsigned char p_filesz[4]; /* Segment size in file */
84  unsigned char p_memsz[4]; /* Segment size in memory */
85  unsigned char p_flags[4]; /* Segment flags */
86  unsigned char p_align[4]; /* Segment alignment, file & memory */
88 
89 typedef struct {
90  unsigned char p_type[4]; /* Identifies program segment type */
91  unsigned char p_flags[4]; /* Segment flags */
92  unsigned char p_offset[8]; /* Segment file offset */
93  unsigned char p_vaddr[8]; /* Segment virtual address */
94  unsigned char p_paddr[8]; /* Segment physical address */
95  unsigned char p_filesz[8]; /* Segment size in file */
96  unsigned char p_memsz[8]; /* Segment size in memory */
97  unsigned char p_align[8]; /* Segment alignment, file & memory */
99 
100 /* Section header */
101 
102 typedef struct {
103  unsigned char sh_name[4]; /* Section name, index in string tbl */
104  unsigned char sh_type[4]; /* Type of section */
105  unsigned char sh_flags[4]; /* Miscellaneous section attributes */
106  unsigned char sh_addr[4]; /* Section virtual addr at execution */
107  unsigned char sh_offset[4]; /* Section file offset */
108  unsigned char sh_size[4]; /* Size of section in bytes */
109  unsigned char sh_link[4]; /* Index of another section */
110  unsigned char sh_info[4]; /* Additional section information */
111  unsigned char sh_addralign[4]; /* Section alignment */
112  unsigned char sh_entsize[4]; /* Entry size if section holds table */
114 
115 typedef struct {
116  unsigned char sh_name[4]; /* Section name, index in string tbl */
117  unsigned char sh_type[4]; /* Type of section */
118  unsigned char sh_flags[8]; /* Miscellaneous section attributes */
119  unsigned char sh_addr[8]; /* Section virtual addr at execution */
120  unsigned char sh_offset[8]; /* Section file offset */
121  unsigned char sh_size[8]; /* Size of section in bytes */
122  unsigned char sh_link[4]; /* Index of another section */
123  unsigned char sh_info[4]; /* Additional section information */
124  unsigned char sh_addralign[8]; /* Section alignment */
125  unsigned char sh_entsize[8]; /* Entry size if section holds table */
127 
128 /* Symbol table entry */
129 
130 typedef struct {
131  unsigned char st_name[4]; /* Symbol name, index in string tbl */
132  unsigned char st_value[4]; /* Value of the symbol */
133  unsigned char st_size[4]; /* Associated symbol size */
134  unsigned char st_info[1]; /* Type and binding attributes */
135  unsigned char st_other[1]; /* No defined meaning, 0 */
136  unsigned char st_shndx[2]; /* Associated section index */
138 
139 typedef struct {
140  unsigned char st_name[4]; /* Symbol name, index in string tbl */
141  unsigned char st_info[1]; /* Type and binding attributes */
142  unsigned char st_other[1]; /* No defined meaning, 0 */
143  unsigned char st_shndx[2]; /* Associated section index */
144  unsigned char st_value[8]; /* Value of the symbol */
145  unsigned char st_size[8]; /* Associated symbol size */
147 
148 typedef struct {
149  unsigned char est_shndx[4]; /* Section index */
151 
152 /* Note segments */
153 
154 typedef struct {
155  unsigned char namesz[4]; /* Size of entry's owner string */
156  unsigned char descsz[4]; /* Size of the note descriptor */
157  unsigned char type[4]; /* Interpretation of the descriptor */
158  char name[1]; /* Start of the name+desc data */
160 
161 /* Relocation Entries */
162 typedef struct {
163  unsigned char rz_offset[4]; /* Location at which to apply the action */
164  unsigned char rz_info[4]; /* index and type of relocation */
166 
167 typedef struct {
168  unsigned char rz_offset[4]; /* Location at which to apply the action */
169  unsigned char rz_info[4]; /* index and type of relocation */
170  unsigned char rz_addend[4]; /* Constant addend used to compute value */
172 
173 typedef struct {
174  unsigned char rz_offset[8]; /* Location at which to apply the action */
175  unsigned char rz_info[8]; /* index and type of relocation */
177 
178 typedef struct {
179  unsigned char rz_offset[8]; /* Location at which to apply the action */
180  unsigned char rz_info[8]; /* index and type of relocation */
181  unsigned char rz_addend[8]; /* Constant addend used to compute value */
183 
184 /* dynamic section structure */
185 
186 typedef struct {
187  unsigned char d_tag[4]; /* entry tag value */
188  union {
189  unsigned char d_val[4];
190  unsigned char d_ptr[4];
191  } d_un;
193 
194 typedef struct {
195  unsigned char d_tag[8]; /* entry tag value */
196  union {
197  unsigned char d_val[8];
198  unsigned char d_ptr[8];
199  } d_un;
201 
202 /* The version structures are currently size independent. They are
203  named without a 32 or 64. If that ever changes, these structures
204  will need to be renamed. */
205 
206 /* This structure appears in a SHT_GNU_verdef section. */
207 
208 typedef struct {
209  unsigned char vd_version[2];
210  unsigned char vd_flags[2];
211  unsigned char vd_ndx[2];
212  unsigned char vd_cnt[2];
213  unsigned char vd_hash[4];
214  unsigned char vd_aux[4];
215  unsigned char vd_next[4];
217 
218 /* This structure appears in a SHT_GNU_verdef section. */
219 
220 typedef struct {
221  unsigned char vda_name[4];
222  unsigned char vda_next[4];
224 
225 /* This structure appears in a SHT_GNU_verneed section. */
226 
227 typedef struct {
228  unsigned char vn_version[2];
229  unsigned char vn_cnt[2];
230  unsigned char vn_file[4];
231  unsigned char vn_aux[4];
232  unsigned char vn_next[4];
234 
235 /* This structure appears in a SHT_GNU_verneed section. */
236 
237 typedef struct {
238  unsigned char vna_hash[4];
239  unsigned char vna_flags[2];
240  unsigned char vna_other[2];
241  unsigned char vna_name[4];
242  unsigned char vna_next[4];
244 
245 /* This structure appears in a SHT_GNU_versym section. This is not a
246  standard ELF structure; ELF just uses Elf32_Half. */
247 
248 typedef struct {
249  unsigned char vs_vers[2];
250 } ATTRIBUTE_PACKED Elf_External_Versym;
251 
252 /* Structure for syminfo section. */
253 typedef struct
254 {
255  unsigned char si_boundto[2];
256  unsigned char si_flags[2];
258 
259 /* This structure appears on the stack and in NT_AUXV core file notes. */
260 typedef struct
261 {
262  unsigned char a_type[4];
263  unsigned char a_val[4];
265 
266 typedef struct
267 {
268  unsigned char a_type[8];
269  unsigned char a_val[8];
271 
272 /* Size of SHT_GROUP section entry. */
273 
274 #define GRP_ENTRY_SIZE 4
275 
276 #endif /* _ELF_EXTERNAL_H */
int type
Definition: mipsasm.c:17
Definition: z80asm.h:102