]>
Commit | Line | Data |
---|---|---|
3af9a47b | 1 | /* Mach-O support for BFD. |
154a1ee5 | 2 | Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009 |
3af9a47b NC |
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 | |
cd123cb7 | 9 | the Free Software Foundation; either version 3 of the License, or |
3af9a47b NC |
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 | |
e84d6fca | 18 | along with this program; if not, write to the Free Software |
cd123cb7 NC |
19 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
20 | MA 02110-1301, USA. */ | |
3af9a47b NC |
21 | |
22 | #ifndef _BFD_MACH_O_H_ | |
23 | #define _BFD_MACH_O_H_ | |
24 | ||
25 | #include "bfd.h" | |
74f26653 | 26 | #include "mach-o/loader.h" |
15e1c58a | 27 | |
3af9a47b NC |
28 | typedef struct bfd_mach_o_header |
29 | { | |
30 | unsigned long magic; | |
31 | unsigned long cputype; | |
32 | unsigned long cpusubtype; | |
33 | unsigned long filetype; | |
34 | unsigned long ncmds; | |
35 | unsigned long sizeofcmds; | |
36 | unsigned long flags; | |
1e8a024a TG |
37 | unsigned int reserved; |
38 | /* Version 1: 32 bits, version 2: 64 bits. */ | |
39 | unsigned int version; | |
3af9a47b NC |
40 | enum bfd_endian byteorder; |
41 | } | |
42 | bfd_mach_o_header; | |
43 | ||
f1bde64c TG |
44 | #define BFD_MACH_O_SEGNAME_SIZE 16 |
45 | #define BFD_MACH_O_SECTNAME_SIZE 16 | |
46 | ||
3af9a47b NC |
47 | typedef struct bfd_mach_o_section |
48 | { | |
53d58d96 | 49 | /* Fields present in the file. */ |
f1bde64c TG |
50 | char sectname[BFD_MACH_O_SECTNAME_SIZE + 1]; /* Always NUL padded. */ |
51 | char segname[BFD_MACH_O_SEGNAME_SIZE + 1]; | |
3af9a47b NC |
52 | bfd_vma addr; |
53 | bfd_vma size; | |
54 | bfd_vma offset; | |
55 | unsigned long align; | |
56 | bfd_vma reloff; | |
57 | unsigned long nreloc; | |
58 | unsigned long flags; | |
59 | unsigned long reserved1; | |
60 | unsigned long reserved2; | |
1e8a024a | 61 | unsigned long reserved3; |
53d58d96 TG |
62 | |
63 | /* Corresponding bfd section. */ | |
64 | asection *bfdsection; | |
f1bde64c TG |
65 | |
66 | /* Simply linked list. */ | |
67 | struct bfd_mach_o_section *next; | |
3af9a47b NC |
68 | } |
69 | bfd_mach_o_section; | |
70 | ||
71 | typedef struct bfd_mach_o_segment_command | |
72 | { | |
15e1c58a | 73 | char segname[16 + 1]; |
3af9a47b NC |
74 | bfd_vma vmaddr; |
75 | bfd_vma vmsize; | |
76 | bfd_vma fileoff; | |
77 | unsigned long filesize; | |
15e1c58a TG |
78 | unsigned long maxprot; /* Maximum permitted protection. */ |
79 | unsigned long initprot; /* Initial protection. */ | |
3af9a47b NC |
80 | unsigned long nsects; |
81 | unsigned long flags; | |
f1bde64c TG |
82 | |
83 | /* Linked list of sections. */ | |
84 | bfd_mach_o_section *sect_head; | |
85 | bfd_mach_o_section *sect_tail; | |
3af9a47b NC |
86 | } |
87 | bfd_mach_o_segment_command; | |
88 | ||
15e1c58a TG |
89 | /* Protection flags. */ |
90 | #define BFD_MACH_O_PROT_READ 0x01 | |
91 | #define BFD_MACH_O_PROT_WRITE 0x02 | |
92 | #define BFD_MACH_O_PROT_EXECUTE 0x04 | |
93 | ||
92bc0e80 TG |
94 | /* Expanded internal representation of a relocation entry. */ |
95 | typedef struct bfd_mach_o_reloc_info | |
96 | { | |
97 | bfd_vma r_address; | |
98 | bfd_vma r_value; | |
99 | unsigned int r_scattered : 1; | |
100 | unsigned int r_type : 4; | |
101 | unsigned int r_pcrel : 1; | |
102 | unsigned int r_length : 2; | |
103 | unsigned int r_extern : 1; | |
104 | } | |
105 | bfd_mach_o_reloc_info; | |
106 | ||
107 | typedef struct bfd_mach_o_asymbol | |
108 | { | |
109 | /* The actual symbol which the rest of BFD works with. */ | |
110 | asymbol symbol; | |
111 | ||
112 | /* Fields from Mach-O symbol. */ | |
113 | unsigned char n_type; | |
114 | unsigned char n_sect; | |
115 | unsigned short n_desc; | |
116 | } | |
117 | bfd_mach_o_asymbol; | |
118 | ||
3af9a47b NC |
119 | typedef struct bfd_mach_o_symtab_command |
120 | { | |
92bc0e80 TG |
121 | unsigned int symoff; |
122 | unsigned int nsyms; | |
123 | unsigned int stroff; | |
124 | unsigned int strsize; | |
125 | bfd_mach_o_asymbol *symbols; | |
3af9a47b | 126 | char *strtab; |
3af9a47b NC |
127 | } |
128 | bfd_mach_o_symtab_command; | |
129 | ||
130 | /* This is the second set of the symbolic information which is used to support | |
7dee875e | 131 | the data structures for the dynamically link editor. |
e84d6fca | 132 | |
3af9a47b NC |
133 | The original set of symbolic information in the symtab_command which contains |
134 | the symbol and string tables must also be present when this load command is | |
135 | present. When this load command is present the symbol table is organized | |
136 | into three groups of symbols: | |
137 | local symbols (static and debugging symbols) - grouped by module | |
138 | defined external symbols - grouped by module (sorted by name if not lib) | |
139 | undefined external symbols (sorted by name) | |
140 | In this load command there are offsets and counts to each of the three groups | |
141 | of symbols. | |
e84d6fca | 142 | |
3af9a47b NC |
143 | This load command contains a the offsets and sizes of the following new |
144 | symbolic information tables: | |
145 | table of contents | |
146 | module table | |
147 | reference symbol table | |
148 | indirect symbol table | |
149 | The first three tables above (the table of contents, module table and | |
7dee875e | 150 | reference symbol table) are only present if the file is a dynamically linked |
3af9a47b NC |
151 | shared library. For executable and object modules, which are files |
152 | containing only one module, the information that would be in these three | |
153 | tables is determined as follows: | |
154 | table of contents - the defined external symbols are sorted by name | |
155 | module table - the file contains only one module so everything in the | |
156 | file is part of the module. | |
157 | reference symbol table - is the defined and undefined external symbols | |
e84d6fca | 158 | |
7dee875e | 159 | For dynamically linked shared library files this load command also contains |
3af9a47b NC |
160 | offsets and sizes to the pool of relocation entries for all sections |
161 | separated into two groups: | |
162 | external relocation entries | |
163 | local relocation entries | |
164 | For executable and object modules the relocation entries continue to hang | |
165 | off the section structures. */ | |
166 | ||
046b007d TG |
167 | typedef struct bfd_mach_o_dylib_module |
168 | { | |
169 | /* Index into the string table indicating the name of the module. */ | |
170 | unsigned long module_name_idx; | |
171 | char *module_name; | |
172 | ||
173 | /* Index into the symbol table of the first defined external symbol provided | |
174 | by the module. */ | |
175 | unsigned long iextdefsym; | |
176 | ||
177 | /* Number of external symbols provided by this module. */ | |
178 | unsigned long nextdefsym; | |
179 | ||
180 | /* Index into the external reference table of the first entry | |
181 | provided by this module. */ | |
182 | unsigned long irefsym; | |
183 | ||
184 | /* Number of external reference entries provided by this module. */ | |
185 | unsigned long nrefsym; | |
186 | ||
187 | /* Index into the symbol table of the first local symbol provided by this | |
188 | module. */ | |
189 | unsigned long ilocalsym; | |
190 | ||
191 | /* Number of local symbols provided by this module. */ | |
192 | unsigned long nlocalsym; | |
193 | ||
194 | /* Index into the external relocation table of the first entry provided | |
195 | by this module. */ | |
196 | unsigned long iextrel; | |
197 | ||
198 | /* Number of external relocation entries provided by this module. */ | |
199 | unsigned long nextrel; | |
200 | ||
201 | /* Index in the module initialization section to the pointers for this | |
202 | module. */ | |
203 | unsigned short iinit; | |
204 | ||
205 | /* Index in the module termination section to the pointers for this | |
206 | module. */ | |
207 | unsigned short iterm; | |
208 | ||
209 | /* Number of pointers in the module initialization for this module. */ | |
210 | unsigned short ninit; | |
211 | ||
212 | /* Number of pointers in the module termination for this module. */ | |
213 | unsigned short nterm; | |
214 | ||
215 | /* Number of data byte for this module that are used in the __module_info | |
216 | section of the __OBJC segment. */ | |
217 | unsigned long objc_module_info_size; | |
218 | ||
219 | /* Statically linked address of the start of the data for this module | |
220 | in the __module_info section of the __OBJC_segment. */ | |
221 | bfd_vma objc_module_info_addr; | |
222 | } | |
223 | bfd_mach_o_dylib_module; | |
046b007d TG |
224 | |
225 | typedef struct bfd_mach_o_dylib_table_of_content | |
226 | { | |
227 | /* Index into the symbol table to the defined external symbol. */ | |
228 | unsigned long symbol_index; | |
229 | ||
230 | /* Index into the module table to the module for this entry. */ | |
231 | unsigned long module_index; | |
232 | } | |
233 | bfd_mach_o_dylib_table_of_content; | |
046b007d TG |
234 | |
235 | typedef struct bfd_mach_o_dylib_reference | |
236 | { | |
237 | /* Index into the symbol table for the symbol being referenced. */ | |
238 | unsigned long isym; | |
239 | ||
240 | /* Type of the reference being made (use REFERENCE_FLAGS constants). */ | |
241 | unsigned long flags; | |
242 | } | |
243 | bfd_mach_o_dylib_reference; | |
244 | #define BFD_MACH_O_REFERENCE_SIZE 4 | |
245 | ||
3af9a47b NC |
246 | typedef struct bfd_mach_o_dysymtab_command |
247 | { | |
248 | /* The symbols indicated by symoff and nsyms of the LC_SYMTAB load command | |
249 | are grouped into the following three groups: | |
250 | local symbols (further grouped by the module they are from) | |
251 | defined external symbols (further grouped by the module they are from) | |
252 | undefined symbols | |
e84d6fca | 253 | |
3af9a47b NC |
254 | The local symbols are used only for debugging. The dynamic binding |
255 | process may have to use them to indicate to the debugger the local | |
256 | symbols for a module that is being bound. | |
e84d6fca | 257 | |
3af9a47b NC |
258 | The last two groups are used by the dynamic binding process to do the |
259 | binding (indirectly through the module table and the reference symbol | |
7dee875e | 260 | table when this is a dynamically linked shared library file). */ |
3af9a47b NC |
261 | |
262 | unsigned long ilocalsym; /* Index to local symbols. */ | |
263 | unsigned long nlocalsym; /* Number of local symbols. */ | |
264 | unsigned long iextdefsym; /* Index to externally defined symbols. */ | |
265 | unsigned long nextdefsym; /* Number of externally defined symbols. */ | |
266 | unsigned long iundefsym; /* Index to undefined symbols. */ | |
267 | unsigned long nundefsym; /* Number of undefined symbols. */ | |
268 | ||
269 | /* For the for the dynamic binding process to find which module a symbol | |
270 | is defined in the table of contents is used (analogous to the ranlib | |
271 | structure in an archive) which maps defined external symbols to modules | |
7dee875e | 272 | they are defined in. This exists only in a dynamically linked shared |
3af9a47b NC |
273 | library file. For executable and object modules the defined external |
274 | symbols are sorted by name and is use as the table of contents. */ | |
275 | ||
276 | unsigned long tocoff; /* File offset to table of contents. */ | |
277 | unsigned long ntoc; /* Number of entries in table of contents. */ | |
278 | ||
279 | /* To support dynamic binding of "modules" (whole object files) the symbol | |
280 | table must reflect the modules that the file was created from. This is | |
281 | done by having a module table that has indexes and counts into the merged | |
282 | tables for each module. The module structure that these two entries | |
7dee875e | 283 | refer to is described below. This exists only in a dynamically linked |
3af9a47b NC |
284 | shared library file. For executable and object modules the file only |
285 | contains one module so everything in the file belongs to the module. */ | |
286 | ||
287 | unsigned long modtaboff; /* File offset to module table. */ | |
288 | unsigned long nmodtab; /* Number of module table entries. */ | |
289 | ||
290 | /* To support dynamic module binding the module structure for each module | |
291 | indicates the external references (defined and undefined) each module | |
292 | makes. For each module there is an offset and a count into the | |
293 | reference symbol table for the symbols that the module references. | |
7dee875e | 294 | This exists only in a dynamically linked shared library file. For |
3af9a47b NC |
295 | executable and object modules the defined external symbols and the |
296 | undefined external symbols indicates the external references. */ | |
297 | ||
298 | unsigned long extrefsymoff; /* Offset to referenced symbol table. */ | |
299 | unsigned long nextrefsyms; /* Number of referenced symbol table entries. */ | |
300 | ||
301 | /* The sections that contain "symbol pointers" and "routine stubs" have | |
302 | indexes and (implied counts based on the size of the section and fixed | |
303 | size of the entry) into the "indirect symbol" table for each pointer | |
304 | and stub. For every section of these two types the index into the | |
305 | indirect symbol table is stored in the section header in the field | |
306 | reserved1. An indirect symbol table entry is simply a 32bit index into | |
307 | the symbol table to the symbol that the pointer or stub is referring to. | |
308 | The indirect symbol table is ordered to match the entries in the section. */ | |
309 | ||
310 | unsigned long indirectsymoff; /* File offset to the indirect symbol table. */ | |
311 | unsigned long nindirectsyms; /* Number of indirect symbol table entries. */ | |
312 | ||
313 | /* To support relocating an individual module in a library file quickly the | |
314 | external relocation entries for each module in the library need to be | |
315 | accessed efficiently. Since the relocation entries can't be accessed | |
316 | through the section headers for a library file they are separated into | |
317 | groups of local and external entries further grouped by module. In this | |
318 | case the presents of this load command who's extreloff, nextrel, | |
319 | locreloff and nlocrel fields are non-zero indicates that the relocation | |
320 | entries of non-merged sections are not referenced through the section | |
321 | structures (and the reloff and nreloc fields in the section headers are | |
322 | set to zero). | |
323 | ||
324 | Since the relocation entries are not accessed through the section headers | |
325 | this requires the r_address field to be something other than a section | |
326 | offset to identify the item to be relocated. In this case r_address is | |
327 | set to the offset from the vmaddr of the first LC_SEGMENT command. | |
328 | ||
329 | The relocation entries are grouped by module and the module table | |
330 | entries have indexes and counts into them for the group of external | |
331 | relocation entries for that the module. | |
332 | ||
333 | For sections that are merged across modules there must not be any | |
334 | remaining external relocation entries for them (for merged sections | |
335 | remaining relocation entries must be local). */ | |
336 | ||
337 | unsigned long extreloff; /* Offset to external relocation entries. */ | |
338 | unsigned long nextrel; /* Number of external relocation entries. */ | |
339 | ||
340 | /* All the local relocation entries are grouped together (they are not | |
341 | grouped by their module since they are only used if the object is moved | |
7dee875e | 342 | from it statically link edited address). */ |
3af9a47b NC |
343 | |
344 | unsigned long locreloff; /* Offset to local relocation entries. */ | |
345 | unsigned long nlocrel; /* Number of local relocation entries. */ | |
046b007d TG |
346 | |
347 | bfd_mach_o_dylib_module *dylib_module; | |
348 | bfd_mach_o_dylib_table_of_content *dylib_toc; | |
349 | unsigned int *indirect_syms; | |
350 | bfd_mach_o_dylib_reference *ext_refs; | |
3af9a47b | 351 | } |
e84d6fca | 352 | bfd_mach_o_dysymtab_command; |
3af9a47b | 353 | |
e84d6fca | 354 | /* An indirect symbol table entry is simply a 32bit index into the symbol table |
3af9a47b | 355 | to the symbol that the pointer or stub is refering to. Unless it is for a |
046b007d | 356 | non-lazy symbol pointer section for a defined symbol which strip(1) has |
3af9a47b NC |
357 | removed. In which case it has the value INDIRECT_SYMBOL_LOCAL. If the |
358 | symbol was also absolute INDIRECT_SYMBOL_ABS is or'ed with that. */ | |
359 | ||
15e1c58a TG |
360 | #define BFD_MACH_O_INDIRECT_SYMBOL_LOCAL 0x80000000 |
361 | #define BFD_MACH_O_INDIRECT_SYMBOL_ABS 0x40000000 | |
046b007d | 362 | #define BFD_MACH_O_INDIRECT_SYMBOL_SIZE 4 |
3af9a47b | 363 | |
b32e07d7 TG |
364 | /* For LC_THREAD or LC_UNIXTHREAD. */ |
365 | ||
3af9a47b NC |
366 | typedef struct bfd_mach_o_thread_flavour |
367 | { | |
368 | unsigned long flavour; | |
b32e07d7 | 369 | unsigned long offset; |
3af9a47b NC |
370 | unsigned long size; |
371 | } | |
372 | bfd_mach_o_thread_flavour; | |
373 | ||
374 | typedef struct bfd_mach_o_thread_command | |
375 | { | |
376 | unsigned long nflavours; | |
e84d6fca | 377 | bfd_mach_o_thread_flavour *flavours; |
3af9a47b NC |
378 | asection *section; |
379 | } | |
380 | bfd_mach_o_thread_command; | |
381 | ||
046b007d TG |
382 | /* For LC_LOAD_DYLINKER and LC_ID_DYLINKER. */ |
383 | ||
3af9a47b NC |
384 | typedef struct bfd_mach_o_dylinker_command |
385 | { | |
846b9259 TG |
386 | unsigned long name_offset; /* Offset to library's path name. */ |
387 | unsigned long name_len; /* Offset to library's path name. */ | |
b32e07d7 | 388 | char *name_str; |
3af9a47b NC |
389 | } |
390 | bfd_mach_o_dylinker_command; | |
391 | ||
046b007d TG |
392 | /* For LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB, LC_ID_DYLIB |
393 | or LC_REEXPORT_DYLIB. */ | |
394 | ||
3af9a47b NC |
395 | typedef struct bfd_mach_o_dylib_command |
396 | { | |
3af9a47b NC |
397 | unsigned long name_offset; /* Offset to library's path name. */ |
398 | unsigned long name_len; /* Offset to library's path name. */ | |
399 | unsigned long timestamp; /* Library's build time stamp. */ | |
400 | unsigned long current_version; /* Library's current version number. */ | |
401 | unsigned long compatibility_version; /* Library's compatibility vers number. */ | |
b32e07d7 | 402 | char *name_str; |
3af9a47b NC |
403 | } |
404 | bfd_mach_o_dylib_command; | |
405 | ||
046b007d TG |
406 | /* For LC_PREBOUND_DYLIB. */ |
407 | ||
3af9a47b NC |
408 | typedef struct bfd_mach_o_prebound_dylib_command |
409 | { | |
3af9a47b NC |
410 | unsigned long name; /* Library's path name. */ |
411 | unsigned long nmodules; /* Number of modules in library. */ | |
412 | unsigned long linked_modules; /* Bit vector of linked modules. */ | |
3af9a47b NC |
413 | } |
414 | bfd_mach_o_prebound_dylib_command; | |
415 | ||
046b007d TG |
416 | /* For LC_UUID. */ |
417 | ||
15e1c58a TG |
418 | typedef struct bfd_mach_o_uuid_command |
419 | { | |
046b007d | 420 | unsigned char uuid[16]; |
15e1c58a TG |
421 | } |
422 | bfd_mach_o_uuid_command; | |
423 | ||
046b007d TG |
424 | /* For LC_CODE_SIGNATURE or LC_SEGMENT_SPLIT_INFO. */ |
425 | ||
426 | typedef struct bfd_mach_o_linkedit_command | |
427 | { | |
428 | unsigned long dataoff; | |
429 | unsigned long datasize; | |
430 | } | |
431 | bfd_mach_o_linkedit_command; | |
432 | ||
433 | typedef struct bfd_mach_o_str_command | |
434 | { | |
435 | unsigned long stroff; | |
436 | unsigned long str_len; | |
437 | char *str; | |
438 | } | |
439 | bfd_mach_o_str_command; | |
440 | ||
ad86f1fb TG |
441 | typedef struct bfd_mach_o_dyld_info_command |
442 | { | |
443 | /* File offset and size to rebase info. */ | |
444 | unsigned int rebase_off; | |
445 | unsigned int rebase_size; | |
446 | ||
447 | /* File offset and size of binding info. */ | |
448 | unsigned int bind_off; | |
449 | unsigned int bind_size; | |
450 | ||
451 | /* File offset and size of weak binding info. */ | |
452 | unsigned int weak_bind_off; | |
453 | unsigned int weak_bind_size; | |
454 | ||
455 | /* File offset and size of lazy binding info. */ | |
456 | unsigned int lazy_bind_off; | |
457 | unsigned int lazy_bind_size; | |
458 | ||
459 | /* File offset and size of export info. */ | |
460 | unsigned int export_off; | |
461 | unsigned int export_size; | |
462 | } | |
463 | bfd_mach_o_dyld_info_command; | |
464 | ||
edbdea0e TG |
465 | typedef struct bfd_mach_o_version_min_command |
466 | { | |
467 | unsigned char rel; | |
468 | unsigned char maj; | |
469 | unsigned char min; | |
470 | unsigned int reserved; | |
471 | } | |
472 | bfd_mach_o_version_min_command; | |
473 | ||
3af9a47b NC |
474 | typedef struct bfd_mach_o_load_command |
475 | { | |
476 | bfd_mach_o_load_command_type type; | |
154a1ee5 | 477 | bfd_boolean type_required; |
92bc0e80 TG |
478 | unsigned int offset; |
479 | unsigned int len; | |
3af9a47b NC |
480 | union |
481 | { | |
482 | bfd_mach_o_segment_command segment; | |
483 | bfd_mach_o_symtab_command symtab; | |
484 | bfd_mach_o_dysymtab_command dysymtab; | |
485 | bfd_mach_o_thread_command thread; | |
486 | bfd_mach_o_dylib_command dylib; | |
487 | bfd_mach_o_dylinker_command dylinker; | |
488 | bfd_mach_o_prebound_dylib_command prebound_dylib; | |
15e1c58a | 489 | bfd_mach_o_uuid_command uuid; |
046b007d TG |
490 | bfd_mach_o_linkedit_command linkedit; |
491 | bfd_mach_o_str_command str; | |
ad86f1fb | 492 | bfd_mach_o_dyld_info_command dyld_info; |
edbdea0e | 493 | bfd_mach_o_version_min_command version_min; |
3af9a47b NC |
494 | } |
495 | command; | |
496 | } | |
497 | bfd_mach_o_load_command; | |
498 | ||
499 | typedef struct mach_o_data_struct | |
500 | { | |
92bc0e80 | 501 | /* Mach-O header. */ |
3af9a47b | 502 | bfd_mach_o_header header; |
92bc0e80 | 503 | /* Array of load commands (length is given by header.ncmds). */ |
3af9a47b | 504 | bfd_mach_o_load_command *commands; |
92bc0e80 TG |
505 | |
506 | /* Flatten array of sections. The array is 0-based. */ | |
3af9a47b NC |
507 | unsigned long nsects; |
508 | bfd_mach_o_section **sections; | |
92bc0e80 TG |
509 | |
510 | /* Used while writting: current length of the output file. This is used | |
511 | to allocate space in the file. */ | |
512 | ufile_ptr filelen; | |
046b007d TG |
513 | |
514 | /* As symtab is referenced by other load command, it is handy to have | |
edbdea0e | 515 | a direct access to it. Although it is not clearly stated, only one symtab |
046b007d TG |
516 | is expected. */ |
517 | bfd_mach_o_symtab_command *symtab; | |
b32e07d7 | 518 | bfd_mach_o_dysymtab_command *dysymtab; |
3af9a47b | 519 | } |
046b007d | 520 | bfd_mach_o_data_struct; |
3af9a47b | 521 | |
92bc0e80 TG |
522 | /* Target specific routines. */ |
523 | typedef struct bfd_mach_o_backend_data | |
524 | { | |
42fa0891 | 525 | enum bfd_architecture arch; |
92bc0e80 TG |
526 | bfd_boolean (*_bfd_mach_o_swap_reloc_in)(arelent *, bfd_mach_o_reloc_info *); |
527 | bfd_boolean (*_bfd_mach_o_swap_reloc_out)(arelent *, bfd_mach_o_reloc_info *); | |
b32e07d7 TG |
528 | bfd_boolean (*_bfd_mach_o_print_thread)(bfd *, bfd_mach_o_thread_flavour *, |
529 | void *, char *); | |
92bc0e80 TG |
530 | } |
531 | bfd_mach_o_backend_data; | |
15e1c58a | 532 | |
046b007d | 533 | #define bfd_mach_o_get_data(abfd) ((abfd)->tdata.mach_o_data) |
92bc0e80 TG |
534 | #define bfd_mach_o_get_backend_data(abfd) \ |
535 | ((bfd_mach_o_backend_data*)(abfd)->xvec->backend_data) | |
3af9a47b | 536 | |
f1bde64c TG |
537 | /* Get the Mach-O header for section SEC. */ |
538 | #define bfd_mach_o_get_mach_o_section(sec) \ | |
539 | ((bfd_mach_o_section *)(sec)->used_by_bfd) | |
540 | ||
154a1ee5 | 541 | bfd_boolean bfd_mach_o_valid (bfd *); |
ab273af8 | 542 | int bfd_mach_o_read_dysymtab_symbol (bfd *, bfd_mach_o_dysymtab_command *, bfd_mach_o_symtab_command *, bfd_mach_o_asymbol *, unsigned long); |
154a1ee5 TG |
543 | int bfd_mach_o_scan_start_address (bfd *); |
544 | int bfd_mach_o_scan (bfd *, bfd_mach_o_header *, bfd_mach_o_data_struct *); | |
545 | bfd_boolean bfd_mach_o_mkobject_init (bfd *); | |
546 | const bfd_target *bfd_mach_o_object_p (bfd *); | |
547 | const bfd_target *bfd_mach_o_core_p (bfd *); | |
548 | const bfd_target *bfd_mach_o_archive_p (bfd *); | |
549 | bfd *bfd_mach_o_openr_next_archived_file (bfd *, bfd *); | |
42fa0891 TG |
550 | bfd_boolean bfd_mach_o_set_arch_mach (bfd *, enum bfd_architecture, |
551 | unsigned long); | |
154a1ee5 | 552 | int bfd_mach_o_lookup_command (bfd *, bfd_mach_o_load_command_type, bfd_mach_o_load_command **); |
f1bde64c | 553 | bfd_boolean bfd_mach_o_new_section_hook (bfd *, asection *); |
154a1ee5 TG |
554 | bfd_boolean bfd_mach_o_write_contents (bfd *); |
555 | bfd_boolean bfd_mach_o_bfd_copy_private_symbol_data (bfd *, asymbol *, | |
556 | bfd *, asymbol *); | |
557 | bfd_boolean bfd_mach_o_bfd_copy_private_section_data (bfd *, asection *, | |
558 | bfd *, asection *); | |
559 | bfd_boolean bfd_mach_o_bfd_copy_private_bfd_data (bfd *, bfd *); | |
560 | long bfd_mach_o_get_symtab_upper_bound (bfd *); | |
561 | long bfd_mach_o_canonicalize_symtab (bfd *, asymbol **); | |
b2b62060 TG |
562 | long bfd_mach_o_get_synthetic_symtab (bfd *, long, asymbol **, long, |
563 | asymbol **, asymbol **ret); | |
b32e07d7 TG |
564 | long bfd_mach_o_get_reloc_upper_bound (bfd *, asection *); |
565 | long bfd_mach_o_canonicalize_reloc (bfd *, asection *, arelent **, asymbol **); | |
566 | long bfd_mach_o_get_dynamic_reloc_upper_bound (bfd *); | |
567 | long bfd_mach_o_canonicalize_dynamic_reloc (bfd *, arelent **, asymbol **); | |
154a1ee5 TG |
568 | asymbol *bfd_mach_o_make_empty_symbol (bfd *); |
569 | void bfd_mach_o_get_symbol_info (bfd *, asymbol *, symbol_info *); | |
570 | void bfd_mach_o_print_symbol (bfd *, PTR, asymbol *, bfd_print_symbol_type); | |
571 | bfd_boolean bfd_mach_o_bfd_print_private_bfd_data (bfd *, PTR); | |
572 | int bfd_mach_o_sizeof_headers (bfd *, struct bfd_link_info *); | |
573 | unsigned long bfd_mach_o_stack_addr (enum bfd_mach_o_cpu_type); | |
574 | int bfd_mach_o_core_fetch_environment (bfd *, unsigned char **, unsigned int *); | |
575 | char *bfd_mach_o_core_file_failing_command (bfd *); | |
576 | int bfd_mach_o_core_file_failing_signal (bfd *); | |
577 | bfd_boolean bfd_mach_o_core_file_matches_executable_p (bfd *, bfd *); | |
846b9259 | 578 | bfd *bfd_mach_o_fat_extract (bfd *, bfd_format , const bfd_arch_info_type *); |
154a1ee5 TG |
579 | const bfd_target *bfd_mach_o_header_p (bfd *, bfd_mach_o_filetype, |
580 | bfd_mach_o_cpu_type); | |
b32e07d7 | 581 | bfd_boolean bfd_mach_o_build_commands (bfd *); |
154a1ee5 TG |
582 | bfd_boolean bfd_mach_o_set_section_contents (bfd *, asection *, const void *, |
583 | file_ptr, bfd_size_type); | |
c2f09c75 | 584 | unsigned int bfd_mach_o_version (bfd *); |
3af9a47b | 585 | |
53d58d96 TG |
586 | unsigned int bfd_mach_o_get_section_type_from_name (const char *); |
587 | unsigned int bfd_mach_o_get_section_attribute_from_name (const char *); | |
588 | void bfd_mach_o_normalize_section_name (const char *, const char *, | |
589 | const char **, flagword *); | |
590 | ||
3af9a47b NC |
591 | extern const bfd_target mach_o_fat_vec; |
592 | ||
593 | #endif /* _BFD_MACH_O_H_ */ |