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