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