OSDN Git Service

bfd/
[pf3gnuchains/pf3gnuchains4x.git] / bfd / mach-o.h
1 /* Mach-O support for BFD.
2    Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009, 2011,
3    2012
4    Free Software Foundation, Inc.
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
10    the Free Software Foundation; either version 3 of the License, or
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
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21    MA 02110-1301, USA.  */
22
23 #ifndef _BFD_MACH_O_H_
24 #define _BFD_MACH_O_H_
25
26 #include "bfd.h"
27 #include "mach-o/loader.h"
28
29 typedef 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;
38   unsigned int reserved;
39   /* Version 1: 32 bits, version 2: 64 bits.  */
40   unsigned int version;
41   enum bfd_endian byteorder;
42 }
43 bfd_mach_o_header;
44
45 #define BFD_MACH_O_SEGNAME_SIZE 16
46 #define BFD_MACH_O_SECTNAME_SIZE 16
47
48 typedef struct bfd_mach_o_section
49 {
50   /* Fields present in the file.  */
51   char sectname[BFD_MACH_O_SECTNAME_SIZE + 1];  /* Always NUL padded.  */
52   char segname[BFD_MACH_O_SEGNAME_SIZE + 1];
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;
62   unsigned long reserved3;
63
64   /* Corresponding bfd section.  */
65   asection *bfdsection;
66
67   /* Simply linked list.  */
68   struct bfd_mach_o_section *next;
69 }
70 bfd_mach_o_section;
71
72 typedef struct bfd_mach_o_segment_command
73 {
74   char segname[BFD_MACH_O_SEGNAME_SIZE + 1];
75   bfd_vma vmaddr;
76   bfd_vma vmsize;
77   bfd_vma fileoff;
78   unsigned long filesize;
79   unsigned long maxprot;        /* Maximum permitted protection.  */
80   unsigned long initprot;       /* Initial protection.  */
81   unsigned long nsects;
82   unsigned long flags;
83
84   /* Linked list of sections.  */
85   bfd_mach_o_section *sect_head;
86   bfd_mach_o_section *sect_tail;
87 }
88 bfd_mach_o_segment_command;
89
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
95 /* Expanded internal representation of a relocation entry.  */
96 typedef 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 }
106 bfd_mach_o_reloc_info;
107
108 typedef struct bfd_mach_o_asymbol
109 {
110   /* The actual symbol which the rest of BFD works with.  */
111   asymbol symbol;
112
113   /* Mach-O symbol fields.  */
114   unsigned char n_type;
115   unsigned char n_sect;
116   unsigned short n_desc;
117 }
118 bfd_mach_o_asymbol;
119
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
131 typedef struct bfd_mach_o_symtab_command
132 {
133   unsigned int symoff;
134   unsigned int nsyms;
135   unsigned int stroff;
136   unsigned int strsize;
137   bfd_mach_o_asymbol *symbols;
138   char *strtab;
139 }
140 bfd_mach_o_symtab_command;
141
142 /* This is the second set of the symbolic information which is used to support
143    the data structures for the dynamically link editor.
144
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.
154
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
162    reference symbol table) are only present if the file is a dynamically linked
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
170
171    For dynamically linked shared library files this load command also contains
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
179 typedef 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 }
235 bfd_mach_o_dylib_module;
236
237 typedef 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 }
245 bfd_mach_o_dylib_table_of_content;
246
247 typedef 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 }
255 bfd_mach_o_dylib_reference;
256 #define BFD_MACH_O_REFERENCE_SIZE 4
257
258 typedef 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
265
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.
269
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
272      table when this is a dynamically linked shared library file).  */
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
284      they are defined in.  This exists only in a dynamically linked shared
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
295      refer to is described below.  This exists only in a dynamically linked
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.
306      This exists only in a dynamically linked shared library file.  For
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
354      from it statically link edited address).  */
355
356   unsigned long locreloff;    /* Offset to local relocation entries.  */
357   unsigned long nlocrel;      /* Number of local relocation entries.  */
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;
363 }
364 bfd_mach_o_dysymtab_command;
365
366 /* An indirect symbol table entry is simply a 32bit index into the symbol table
367    to the symbol that the pointer or stub is refering to.  Unless it is for a
368    non-lazy symbol pointer section for a defined symbol which strip(1) has
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
372 #define BFD_MACH_O_INDIRECT_SYMBOL_LOCAL 0x80000000
373 #define BFD_MACH_O_INDIRECT_SYMBOL_ABS   0x40000000
374 #define BFD_MACH_O_INDIRECT_SYMBOL_SIZE  4
375
376 /* For LC_THREAD or LC_UNIXTHREAD.  */
377
378 typedef struct bfd_mach_o_thread_flavour
379 {
380   unsigned long flavour;
381   unsigned long offset;
382   unsigned long size;
383 }
384 bfd_mach_o_thread_flavour;
385
386 typedef struct bfd_mach_o_thread_command
387 {
388   unsigned long nflavours;
389   bfd_mach_o_thread_flavour *flavours;
390   asection *section;
391 }
392 bfd_mach_o_thread_command;
393
394 /* For LC_LOAD_DYLINKER and LC_ID_DYLINKER.  */
395
396 typedef struct bfd_mach_o_dylinker_command
397 {
398   unsigned long name_offset;         /* Offset to library's path name.  */
399   unsigned long name_len;            /* Offset to library's path name.  */
400   char *name_str;
401 }
402 bfd_mach_o_dylinker_command;
403
404 /* For LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB, LC_ID_DYLIB
405    or LC_REEXPORT_DYLIB.  */
406
407 typedef struct bfd_mach_o_dylib_command
408 {
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.  */
414   char *name_str;
415 }
416 bfd_mach_o_dylib_command;
417
418 /* For LC_PREBOUND_DYLIB.  */
419
420 typedef struct bfd_mach_o_prebound_dylib_command
421 {
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.  */
425 }
426 bfd_mach_o_prebound_dylib_command;
427
428 /* For LC_UUID.  */
429
430 typedef struct bfd_mach_o_uuid_command
431 {
432   unsigned char uuid[16];
433 }
434 bfd_mach_o_uuid_command;
435
436 /* For LC_CODE_SIGNATURE or LC_SEGMENT_SPLIT_INFO.  */
437
438 typedef struct bfd_mach_o_linkedit_command
439 {
440   unsigned long dataoff;
441   unsigned long datasize;
442 }
443 bfd_mach_o_linkedit_command;
444
445 typedef struct bfd_mach_o_str_command
446 {
447   unsigned long stroff;
448   unsigned long str_len;
449   char *str;
450 }
451 bfd_mach_o_str_command;
452
453 typedef struct bfd_mach_o_fvmlib_command
454 {
455   unsigned int name_offset;
456   unsigned int name_len;
457   char *name_str;
458   unsigned int minor_version;
459   unsigned int header_addr;
460 }
461 bfd_mach_o_fvmlib_command;
462
463 typedef struct bfd_mach_o_dyld_info_command
464 {
465   /* File offset and size to rebase info.  */
466   unsigned int rebase_off; 
467   unsigned int rebase_size;
468
469   /* File offset and size of binding info.  */
470   unsigned int bind_off;
471   unsigned int bind_size;
472
473   /* File offset and size of weak binding info.  */
474   unsigned int weak_bind_off;
475   unsigned int weak_bind_size;
476
477   /* File offset and size of lazy binding info.  */
478   unsigned int lazy_bind_off;
479   unsigned int lazy_bind_size;
480
481   /* File offset and size of export info.  */
482   unsigned int export_off;
483   unsigned int export_size;
484 }
485 bfd_mach_o_dyld_info_command;
486
487 typedef struct bfd_mach_o_version_min_command
488 {
489   unsigned char rel;
490   unsigned char maj;
491   unsigned char min;
492   unsigned int reserved;
493 }
494 bfd_mach_o_version_min_command;
495
496 typedef struct bfd_mach_o_encryption_info_command
497 {
498   unsigned int cryptoff;
499   unsigned int cryptsize;
500   unsigned int cryptid;
501 }
502 bfd_mach_o_encryption_info_command;
503
504 typedef struct bfd_mach_o_load_command
505 {
506   bfd_mach_o_load_command_type type;
507   bfd_boolean type_required;
508   unsigned int offset;
509   unsigned int len;
510   union
511   {
512     bfd_mach_o_segment_command segment;
513     bfd_mach_o_symtab_command symtab;
514     bfd_mach_o_dysymtab_command dysymtab;
515     bfd_mach_o_thread_command thread;
516     bfd_mach_o_dylib_command dylib;
517     bfd_mach_o_dylinker_command dylinker;
518     bfd_mach_o_prebound_dylib_command prebound_dylib;
519     bfd_mach_o_uuid_command uuid;
520     bfd_mach_o_linkedit_command linkedit;
521     bfd_mach_o_str_command str;
522     bfd_mach_o_dyld_info_command dyld_info;
523     bfd_mach_o_version_min_command version_min;
524     bfd_mach_o_encryption_info_command encryption_info;
525     bfd_mach_o_fvmlib_command fvmlib;
526   }
527   command;
528 }
529 bfd_mach_o_load_command;
530
531 typedef struct mach_o_data_struct
532 {
533   /* Mach-O header.  */
534   bfd_mach_o_header header;
535   /* Array of load commands (length is given by header.ncmds).  */
536   bfd_mach_o_load_command *commands;
537
538   /* Flatten array of sections.  The array is 0-based.  */
539   unsigned long nsects;
540   bfd_mach_o_section **sections;
541
542   /* Used while writing: current length of the output file.  This is used
543      to allocate space in the file.  */
544   ufile_ptr filelen;
545
546   /* As symtab is referenced by other load command, it is handy to have
547      a direct access to it.  Although it is not clearly stated, only one symtab
548      is expected.  */
549   bfd_mach_o_symtab_command *symtab;
550   bfd_mach_o_dysymtab_command *dysymtab;
551
552   /* A place to stash dwarf2 info for this bfd.  */
553   void *dwarf2_find_line_info;
554
555   /* BFD of .dSYM file. */
556   bfd *dsym_bfd;
557
558   /* Cache of dynamic relocs. */
559   arelent *dyn_reloc_cache;
560 }
561 bfd_mach_o_data_struct;
562
563 typedef struct bfd_mach_o_xlat_name
564 {
565   const char *name;
566   unsigned long val;
567 }
568 bfd_mach_o_xlat_name;
569
570 /* Target specific routines.  */
571
572 #define bfd_mach_o_get_data(abfd) ((abfd)->tdata.mach_o_data)
573 #define bfd_mach_o_get_backend_data(abfd) \
574   ((bfd_mach_o_backend_data*)(abfd)->xvec->backend_data)
575
576 /* Get the Mach-O header for section SEC.  */
577 #define bfd_mach_o_get_mach_o_section(sec) \
578   ((bfd_mach_o_section *)(sec)->used_by_bfd)
579
580 bfd_boolean bfd_mach_o_valid (bfd *);
581 bfd_boolean bfd_mach_o_mkobject_init (bfd *);
582 const bfd_target *bfd_mach_o_object_p (bfd *);
583 const bfd_target *bfd_mach_o_core_p (bfd *);
584 const bfd_target *bfd_mach_o_archive_p (bfd *);
585 bfd *bfd_mach_o_openr_next_archived_file (bfd *, bfd *);
586 bfd_boolean bfd_mach_o_set_arch_mach (bfd *, enum bfd_architecture,
587                                       unsigned long);
588 int bfd_mach_o_lookup_command (bfd *, bfd_mach_o_load_command_type, bfd_mach_o_load_command **);
589 bfd_boolean bfd_mach_o_new_section_hook (bfd *, asection *);
590 bfd_boolean bfd_mach_o_write_contents (bfd *);
591 bfd_boolean bfd_mach_o_bfd_copy_private_symbol_data (bfd *, asymbol *,
592                                                      bfd *, asymbol *);
593 bfd_boolean bfd_mach_o_bfd_copy_private_section_data (bfd *, asection *,
594                                                       bfd *, asection *);
595 bfd_boolean bfd_mach_o_bfd_copy_private_bfd_data (bfd *, bfd *);
596 bfd_boolean bfd_mach_o_bfd_set_private_flags (bfd *, flagword);
597 long bfd_mach_o_get_symtab_upper_bound (bfd *);
598 long bfd_mach_o_canonicalize_symtab (bfd *, asymbol **);
599 long bfd_mach_o_get_synthetic_symtab (bfd *, long, asymbol **, long, 
600                                       asymbol **, asymbol **ret);
601 long bfd_mach_o_get_reloc_upper_bound (bfd *, asection *);
602 long bfd_mach_o_canonicalize_reloc (bfd *, asection *, arelent **, asymbol **);
603 long bfd_mach_o_get_dynamic_reloc_upper_bound (bfd *);
604 long bfd_mach_o_canonicalize_dynamic_reloc (bfd *, arelent **, asymbol **);
605 asymbol *bfd_mach_o_make_empty_symbol (bfd *);
606 void bfd_mach_o_get_symbol_info (bfd *, asymbol *, symbol_info *);
607 void bfd_mach_o_print_symbol (bfd *, PTR, asymbol *, bfd_print_symbol_type);
608 int bfd_mach_o_sizeof_headers (bfd *, struct bfd_link_info *);
609 unsigned long bfd_mach_o_stack_addr (enum bfd_mach_o_cpu_type);
610 int bfd_mach_o_core_fetch_environment (bfd *, unsigned char **, unsigned int *);
611 char *bfd_mach_o_core_file_failing_command (bfd *);
612 int bfd_mach_o_core_file_failing_signal (bfd *);
613 bfd_boolean bfd_mach_o_core_file_matches_executable_p (bfd *, bfd *);
614 bfd *bfd_mach_o_fat_extract (bfd *, bfd_format , const bfd_arch_info_type *);
615 const bfd_target *bfd_mach_o_header_p (bfd *, bfd_mach_o_filetype,
616                                        bfd_mach_o_cpu_type);
617 bfd_boolean bfd_mach_o_build_commands (bfd *);
618 bfd_boolean bfd_mach_o_set_section_contents (bfd *, asection *, const void *,
619                                              file_ptr, bfd_size_type);
620 unsigned int bfd_mach_o_version (bfd *);
621
622 unsigned int bfd_mach_o_get_section_type_from_name (bfd *, const char *);
623 unsigned int bfd_mach_o_get_section_attribute_from_name (const char *);
624
625 void bfd_mach_o_convert_section_name_to_bfd (bfd *, const char *, const char *,
626                                              const char **, flagword *);
627 bfd_boolean bfd_mach_o_find_nearest_line (bfd *, asection *, asymbol **,
628                                           bfd_vma, const char **,
629                                           const char **, unsigned int *);
630 bfd_boolean bfd_mach_o_close_and_cleanup (bfd *);
631 bfd_boolean bfd_mach_o_free_cached_info (bfd *);
632
633 unsigned int bfd_mach_o_section_get_nbr_indirect (bfd *, bfd_mach_o_section *);
634 unsigned int bfd_mach_o_section_get_entry_size (bfd *, bfd_mach_o_section *);
635 bfd_boolean bfd_mach_o_read_symtab_symbols (bfd *);
636 bfd_boolean bfd_mach_o_read_symtab_strtab (bfd *abfd);
637
638 /* A placeholder in case we need to suppress emitting the dysymtab for some
639    reason (e.g. compatibility with older system versions).  */
640 #define bfd_mach_o_should_emit_dysymtab(x) TRUE
641
642 extern const bfd_mach_o_xlat_name bfd_mach_o_section_attribute_name[];
643 extern const bfd_mach_o_xlat_name bfd_mach_o_section_type_name[];
644
645 extern const bfd_target mach_o_fat_vec;
646
647 /* Interfaces between BFD names and Mach-O names.  */
648
649 typedef struct mach_o_section_name_xlat
650 {
651   const char *bfd_name;
652   const char *mach_o_name;
653   flagword bfd_flags;
654   unsigned int macho_sectype;
655   unsigned int macho_secattr;
656   unsigned int sectalign;
657 } mach_o_section_name_xlat;
658
659 typedef struct mach_o_segment_name_xlat
660 {
661   const char *segname;
662   const mach_o_section_name_xlat *sections;
663 } mach_o_segment_name_xlat;
664
665 const mach_o_section_name_xlat *
666 bfd_mach_o_section_data_for_mach_sect (bfd *, const char *, const char *);
667 const mach_o_section_name_xlat *
668 bfd_mach_o_section_data_for_bfd_name (bfd *, const char *, const char **);
669
670 typedef struct bfd_mach_o_backend_data
671 {
672   enum bfd_architecture arch;
673   bfd_boolean (*_bfd_mach_o_swap_reloc_in)(arelent *, bfd_mach_o_reloc_info *);
674   bfd_boolean (*_bfd_mach_o_swap_reloc_out)(arelent *, bfd_mach_o_reloc_info *);
675   bfd_boolean (*_bfd_mach_o_print_thread)(bfd *, bfd_mach_o_thread_flavour *,
676                                           void *, char *);
677   const mach_o_segment_name_xlat *segsec_names_xlat;
678   bfd_boolean (*bfd_mach_o_section_type_valid_for_target) (unsigned long);
679 }
680 bfd_mach_o_backend_data;
681
682 /* Values used in symbol.udata.i, to signal that the mach-o-specific data in the
683    symbol are not yet set, or need validation (where this is possible).  */
684
685 #define SYM_MACHO_FIELDS_UNSET ((bfd_vma) -1)
686 #define SYM_MACHO_FIELDS_NOT_VALIDATED ((bfd_vma) -2)
687
688 #endif /* _BFD_MACH_O_H_ */