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