bfd/
[deliverable/binutils-gdb.git] / include / mach-o / external.h
CommitLineData
46d1c23b 1/* Mach-O support for BFD.
fc55a902 2 Copyright 2011, 2012
46d1c23b
TG
3 Free Software Foundation, Inc.
4
5 This file is part of BFD, the Binary File Descriptor library.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
21
22#ifndef _MACH_O_EXTERNAL_H
23#define _MACH_O_EXTERNAL_H
24
25struct mach_o_header_external
26{
27 unsigned char magic[4]; /* Magic number. */
28 unsigned char cputype[4]; /* CPU that this object is for. */
29 unsigned char cpusubtype[4]; /* CPU subtype. */
30 unsigned char filetype[4]; /* Type of file. */
31 unsigned char ncmds[4]; /* Number of load commands. */
32 unsigned char sizeofcmds[4]; /* Total size of load commands. */
33 unsigned char flags[4]; /* Flags. */
34 unsigned char reserved[4]; /* Reserved (on 64-bit version only). */
35};
36
37#define BFD_MACH_O_HEADER_SIZE 28
38#define BFD_MACH_O_HEADER_64_SIZE 32
39
40/* 32-bit section header. */
41
42struct mach_o_section_32_external
43{
44 unsigned char sectname[16]; /* Section name. */
45 unsigned char segname[16]; /* Segment that the section belongs to. */
46 unsigned char addr[4]; /* Address of this section in memory. */
47 unsigned char size[4]; /* Size in bytes of this section. */
48 unsigned char offset[4]; /* File offset of this section. */
49 unsigned char align[4]; /* log2 of this section's alignment. */
50 unsigned char reloff[4]; /* File offset of this section's relocs. */
51 unsigned char nreloc[4]; /* Number of relocs for this section. */
52 unsigned char flags[4]; /* Section flags/attributes. */
53 unsigned char reserved1[4];
54 unsigned char reserved2[4];
55};
56#define BFD_MACH_O_SECTION_SIZE 68
57
58/* 64-bit section header. */
59
60struct mach_o_section_64_external
61{
62 unsigned char sectname[16]; /* Section name. */
63 unsigned char segname[16]; /* Segment that the section belongs to. */
64 unsigned char addr[8]; /* Address of this section in memory. */
65 unsigned char size[8]; /* Size in bytes of this section. */
66 unsigned char offset[4]; /* File offset of this section. */
67 unsigned char align[4]; /* log2 of this section's alignment. */
68 unsigned char reloff[4]; /* File offset of this section's relocs. */
69 unsigned char nreloc[4]; /* Number of relocs for this section. */
70 unsigned char flags[4]; /* Section flags/attributes. */
71 unsigned char reserved1[4];
72 unsigned char reserved2[4];
73 unsigned char reserved3[4];
74};
75#define BFD_MACH_O_SECTION_64_SIZE 80
76
77struct mach_o_load_command_external
78{
79 unsigned char cmd[4]; /* The type of load command. */
80 unsigned char cmdsize[4]; /* Size in bytes of entire command. */
81};
82#define BFD_MACH_O_LC_SIZE 8
83
84struct mach_o_segment_command_32_external
85{
86 unsigned char segname[16]; /* Name of this segment. */
87 unsigned char vmaddr[4]; /* Virtual memory address of this segment. */
88 unsigned char vmsize[4]; /* Size there, in bytes. */
89 unsigned char fileoff[4]; /* Offset in bytes of the data to be mapped. */
90 unsigned char filesize[4]; /* Size in bytes on disk. */
91 unsigned char maxprot[4]; /* Maximum permitted vm protection. */
92 unsigned char initprot[4]; /* Initial vm protection. */
93 unsigned char nsects[4]; /* Number of sections in this segment. */
94 unsigned char flags[4]; /* Flags that affect the loading. */
95};
96#define BFD_MACH_O_LC_SEGMENT_SIZE 56 /* Include the header. */
97
98struct mach_o_segment_command_64_external
99{
100 unsigned char segname[16]; /* Name of this segment. */
101 unsigned char vmaddr[8]; /* Virtual memory address of this segment. */
102 unsigned char vmsize[8]; /* Size there, in bytes. */
103 unsigned char fileoff[8]; /* Offset in bytes of the data to be mapped. */
104 unsigned char filesize[8]; /* Size in bytes on disk. */
105 unsigned char maxprot[4]; /* Maximum permitted vm protection. */
106 unsigned char initprot[4]; /* Initial vm protection. */
107 unsigned char nsects[4]; /* Number of sections in this segment. */
108 unsigned char flags[4]; /* Flags that affect the loading. */
109};
110#define BFD_MACH_O_LC_SEGMENT_64_SIZE 72 /* Include the header. */
111
112struct mach_o_reloc_info_external
113{
114 unsigned char r_address[4];
115 unsigned char r_symbolnum[4];
116};
117#define BFD_MACH_O_RELENT_SIZE 8
118
119struct mach_o_symtab_command_external
120{
fc55a902
TG
121 unsigned char symoff[4]; /* File offset of the symbol table. */
122 unsigned char nsyms[4]; /* Number of symbols. */
123 unsigned char stroff[4]; /* File offset of the string table. */
124 unsigned char strsize[4]; /* String table size. */
46d1c23b
TG
125};
126
127struct mach_o_nlist_external
128{
129 unsigned char n_strx[4];
130 unsigned char n_type[1];
131 unsigned char n_sect[1];
132 unsigned char n_desc[2];
133 unsigned char n_value[4];
134};
135#define BFD_MACH_O_NLIST_SIZE 12
136
137struct mach_o_nlist_64_external
138{
139 unsigned char n_strx[4];
140 unsigned char n_type[1];
141 unsigned char n_sect[1];
142 unsigned char n_desc[2];
143 unsigned char n_value[8];
144};
145#define BFD_MACH_O_NLIST_64_SIZE 16
146
147struct mach_o_thread_command_external
148{
149 unsigned char flavour[4];
150 unsigned char count[4];
151};
152
153/* For commands that just have a string or a path. */
154struct mach_o_str_command_external
155{
156 unsigned char str[4];
157};
158
159struct mach_o_dylib_command_external
160{
161 unsigned char name[4];
162 unsigned char timestamp[4];
163 unsigned char current_version[4];
164 unsigned char compatibility_version[4];
165};
166
167struct mach_o_dysymtab_command_external
168{
169 unsigned char ilocalsym[4]; /* Index of. */
170 unsigned char nlocalsym[4]; /* Number of. */
171 unsigned char iextdefsym[4];
172 unsigned char nextdefsym[4];
173 unsigned char iundefsym[4];
174 unsigned char nundefsym[4];
175 unsigned char tocoff[4];
176 unsigned char ntoc[4];
177 unsigned char modtaboff[4];
178 unsigned char nmodtab[4];
179 unsigned char extrefsymoff[4];
180 unsigned char nextrefsyms[4];
181 unsigned char indirectsymoff[4];
182 unsigned char nindirectsyms[4];
183 unsigned char extreloff[4];
184 unsigned char nextrel[4];
185 unsigned char locreloff[4];
186 unsigned char nlocrel[4];
187};
188
189struct mach_o_dylib_module_external
190{
191 unsigned char module_name[4];
192 unsigned char iextdefsym[4];
193 unsigned char nextdefsym[4];
194 unsigned char irefsym[4];
195 unsigned char nrefsym[4];
196 unsigned char ilocalsym[4];
197 unsigned char nlocalsym[4];
198 unsigned char iextrel[4];
199 unsigned char nextrel[4];
200 unsigned char iinit_iterm[4];
201 unsigned char ninit_nterm[4];
202 unsigned char objc_module_info_addr[4];
203 unsigned char objc_module_info_size[4];
204};
205#define BFD_MACH_O_DYLIB_MODULE_SIZE 52
206
207struct mach_o_dylib_module_64_external
208{
209 unsigned char module_name[4];
210 unsigned char iextdefsym[4];
211 unsigned char nextdefsym[4];
212 unsigned char irefsym[4];
213 unsigned char nrefsym[4];
214 unsigned char ilocalsym[4];
215 unsigned char nlocalsym[4];
216 unsigned char iextrel[4];
217 unsigned char nextrel[4];
218 unsigned char iinit_iterm[4];
219 unsigned char ninit_nterm[4];
220 unsigned char objc_module_info_size[4];
221 unsigned char objc_module_info_addr[8];
222};
223#define BFD_MACH_O_DYLIB_MODULE_64_SIZE 56
224
225struct mach_o_dylib_table_of_contents_external
226{
227 unsigned char symbol_index[4];
228 unsigned char module_index[4];
229};
230#define BFD_MACH_O_TABLE_OF_CONTENT_SIZE 8
231
232struct mach_o_linkedit_data_command_external
233{
234 unsigned char dataoff[4];
235 unsigned char datasize[4];
236};
237
238struct mach_o_dyld_info_command_external
239{
240 unsigned char rebase_off[4];
241 unsigned char rebase_size[4];
242 unsigned char bind_off[4];
243 unsigned char bind_size[4];
244 unsigned char weak_bind_off[4];
245 unsigned char weak_bind_size[4];
246 unsigned char lazy_bind_off[4];
247 unsigned char lazy_bind_size[4];
248 unsigned char export_off[4];
249 unsigned char export_size[4];
250};
251
edbdea0e
TG
252struct mach_o_version_min_command_external
253{
254 unsigned char version[4];
255 unsigned char reserved[4];
256};
257
fc55a902
TG
258struct mach_o_encryption_info_command_external
259{
260 unsigned char cryptoff[4]; /* File offset of the encrypted area. */
261 unsigned char cryptsize[4]; /* Size of the encrypted area. */
262 unsigned char cryptid[4]; /* Encryption method. */
263};
264
46d1c23b
TG
265struct mach_o_fat_header_external
266{
267 unsigned char magic[4];
268 unsigned char nfat_arch[4]; /* Number of components. */
269};
270
271struct mach_o_fat_arch_external
272{
273 unsigned char cputype[4];
274 unsigned char cpusubtype[4];
275 unsigned char offset[4]; /* File offset of the member. */
276 unsigned char size[4]; /* Size of the member. */
277 unsigned char align[4]; /* Power of 2. */
278};
279
280#endif /* _MACH_O_EXTERNAL_H */
This page took 0.046139 seconds and 4 git commands to generate.