OSDN Git Service

* bfdio.c (bfd_seek): Formatting. Ensure newly allocated memory
[pf3gnuchains/pf3gnuchains3x.git] / bfd / mach-o.h
1 /* Mach-O support for BFD.
2    Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008
3    Free Software Foundation, Inc.
4
5    This file is part of BFD, the Binary File Descriptor library.
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20    MA 02110-1301, USA.  */
21
22 #ifndef _BFD_MACH_O_H_
23 #define _BFD_MACH_O_H_
24
25 #include "bfd.h"
26
27 #define BFD_MACH_O_N_STAB  0xe0 /* If any of these bits set, a symbolic debugging entry.  */
28 #define BFD_MACH_O_N_PEXT  0x10 /* Private external symbol bit.  */
29 #define BFD_MACH_O_N_TYPE  0x0e /* Mask for the type bits.  */
30 #define BFD_MACH_O_N_EXT   0x01 /* External symbol bit, set for external symbols.  */
31 #define BFD_MACH_O_N_UNDF  0x00 /* Undefined, n_sect == NO_SECT.  */
32 #define BFD_MACH_O_N_ABS   0x02 /* Absolute, n_sect == NO_SECT.  */
33 #define BFD_MACH_O_N_INDR  0x0a /* Indirect.  */
34 #define BFD_MACH_O_N_PBUD  0x0c /* Prebound undefined (defined in a dylib).  */
35 #define BFD_MACH_O_N_SECT  0x0e /* Defined in section number n_sect.  */
36
37 #define BFD_MACH_O_NO_SECT 0
38
39 #define BFD_MACH_O_SYM_NTYPE(SYM) (((SYM)->udata.i >> 24) & 0xff)
40 #define BFD_MACH_O_SYM_NSECT(SYM) (((SYM)->udata.i >> 16) & 0xff)
41 #define BFD_MACH_O_SYM_NDESC(SYM) ((SYM)->udata.i & 0xffff)
42
43 typedef enum bfd_mach_o_ppc_thread_flavour
44 {
45   BFD_MACH_O_PPC_THREAD_STATE = 1,
46   BFD_MACH_O_PPC_FLOAT_STATE = 2,
47   BFD_MACH_O_PPC_EXCEPTION_STATE = 3,
48   BFD_MACH_O_PPC_VECTOR_STATE = 4,
49   BFD_MACH_O_PPC_THREAD_STATE_64 = 5
50 }
51 bfd_mach_o_ppc_thread_flavour;
52
53 /* Defined in <mach/i386/thread_status.h> */
54 typedef enum bfd_mach_o_i386_thread_flavour
55 {
56   BFD_MACH_O_x86_THREAD_STATE32 = 1,
57   BFD_MACH_O_x86_FLOAT_STATE32 = 2,
58   BFD_MACH_O_x86_EXCEPTION_STATE32 = 3,
59   BFD_MACH_O_x86_THREAD_STATE64 = 4,
60   BFD_MACH_O_x86_FLOAT_STATE64 = 5,
61   BFD_MACH_O_x86_EXCEPTION_STATE64 = 6,
62   BFD_MACH_O_x86_THREAD_STATE = 7,
63   BFD_MACH_O_x86_FLOAT_STATE = 8,
64   BFD_MACH_O_x86_EXCEPTION_STATE = 9,
65   BFD_MACH_O_x86_DEBUG_STATE32 = 10,
66   BFD_MACH_O_x86_DEBUG_STATE64 = 11,
67   BFD_MACH_O_x86_DEBUG_STATE = 12,
68   BFD_MACH_O_THREAD_STATE_NONE = 13
69 }
70 bfd_mach_o_i386_thread_flavour;
71
72 #define BFD_MACH_O_LC_REQ_DYLD 0x80000000
73
74 typedef enum bfd_mach_o_load_command_type
75 {
76   BFD_MACH_O_LC_SEGMENT = 0x1,          /* File segment to be mapped.  */
77   BFD_MACH_O_LC_SYMTAB = 0x2,           /* Link-edit stab symbol table info (obsolete).  */
78   BFD_MACH_O_LC_SYMSEG = 0x3,           /* Link-edit gdb symbol table info.  */
79   BFD_MACH_O_LC_THREAD = 0x4,           /* Thread.  */
80   BFD_MACH_O_LC_UNIXTHREAD = 0x5,       /* UNIX thread (includes a stack).  */
81   BFD_MACH_O_LC_LOADFVMLIB = 0x6,       /* Load a fixed VM shared library.  */
82   BFD_MACH_O_LC_IDFVMLIB = 0x7,         /* Fixed VM shared library id.  */
83   BFD_MACH_O_LC_IDENT = 0x8,            /* Object identification information (obsolete).  */
84   BFD_MACH_O_LC_FVMFILE = 0x9,          /* Fixed VM file inclusion.  */
85   BFD_MACH_O_LC_PREPAGE = 0xa,          /* Prepage command (internal use).  */
86   BFD_MACH_O_LC_DYSYMTAB = 0xb,         /* Dynamic link-edit symbol table info.  */
87   BFD_MACH_O_LC_LOAD_DYLIB = 0xc,       /* Load a dynamically linked shared library.  */
88   BFD_MACH_O_LC_ID_DYLIB = 0xd,         /* Dynamically linked shared lib identification.  */
89   BFD_MACH_O_LC_LOAD_DYLINKER = 0xe,    /* Load a dynamic linker.  */
90   BFD_MACH_O_LC_ID_DYLINKER = 0xf,      /* Dynamic linker identification.  */
91   BFD_MACH_O_LC_PREBOUND_DYLIB = 0x10,  /* Modules prebound for a dynamically.  */
92   BFD_MACH_O_LC_ROUTINES = 0x11,        /* Image routines.  */
93   BFD_MACH_O_LC_SUB_FRAMEWORK = 0x12,   /* Sub framework.  */
94   BFD_MACH_O_LC_SUB_UMBRELLA = 0x13,    /* Sub umbrella.  */
95   BFD_MACH_O_LC_SUB_CLIENT = 0x14,      /* Sub client.  */
96   BFD_MACH_O_LC_SUB_LIBRARY = 0x15,     /* Sub library.  */
97   BFD_MACH_O_LC_TWOLEVEL_HINTS = 0x16,  /* Two-level namespace lookup hints.  */
98   BFD_MACH_O_LC_PREBIND_CKSUM = 0x17,   /* Prebind checksum.  */
99   /* Load a dynamically linked shared library that is allowed to be
100        missing (weak).  */
101   BFD_MACH_O_LC_LOAD_WEAK_DYLIB = 0x18,
102   BFD_MACH_O_LC_SEGMENT_64 = 0x19,      /* 64-bit segment of this file to be 
103                                            mapped.  */
104   BFD_MACH_O_LC_ROUTINES_64 = 0x1a,     /* Address of the dyld init routine 
105                                            in a dylib.  */
106   BFD_MACH_O_LC_UUID = 0x1b,            /* 128-bit UUID of the executable.  */
107   BFD_MACH_O_LC_RPATH = 0x1c,           /* Run path addiions.  */
108   BFD_MACH_O_LC_CODE_SIGNATURE = 0x1d,  /* Local of code signature.  */
109   BFD_MACH_O_LC_SEGMENT_SPLIT_INFO = 0x1e, /* Local of info to split seg.  */
110   BFD_MACH_O_LC_REEXPORT_DYLIB = 0x1f,  /* Load and re-export lib.  */
111   BFD_MACH_O_LC_LAZY_LOAD_DYLIB = 0x20, /* Delay load of lib until use.  */
112   BFD_MACH_O_LC_ENCRYPTION_INFO = 0x21  /* Encrypted segment info.  */
113 }
114 bfd_mach_o_load_command_type;
115
116 #define BFD_MACH_O_CPU_IS64BIT 0x1000000
117
118 typedef enum bfd_mach_o_cpu_type
119 {
120   BFD_MACH_O_CPU_TYPE_VAX = 1,
121   BFD_MACH_O_CPU_TYPE_MC680x0 = 6,
122   BFD_MACH_O_CPU_TYPE_I386 = 7,
123   BFD_MACH_O_CPU_TYPE_MIPS = 8,
124   BFD_MACH_O_CPU_TYPE_MC98000 = 10,
125   BFD_MACH_O_CPU_TYPE_HPPA = 11,
126   BFD_MACH_O_CPU_TYPE_ARM = 12,
127   BFD_MACH_O_CPU_TYPE_MC88000 = 13,
128   BFD_MACH_O_CPU_TYPE_SPARC = 14,
129   BFD_MACH_O_CPU_TYPE_I860 = 15,
130   BFD_MACH_O_CPU_TYPE_ALPHA = 16,
131   BFD_MACH_O_CPU_TYPE_POWERPC = 18,
132   BFD_MACH_O_CPU_TYPE_POWERPC_64 = (BFD_MACH_O_CPU_TYPE_POWERPC | BFD_MACH_O_CPU_IS64BIT),
133   BFD_MACH_O_CPU_TYPE_X86_64 = (BFD_MACH_O_CPU_TYPE_I386 | BFD_MACH_O_CPU_IS64BIT)
134 }
135 bfd_mach_o_cpu_type;
136
137 typedef enum bfd_mach_o_filetype
138 {
139   BFD_MACH_O_MH_OBJECT = 1,
140   BFD_MACH_O_MH_EXECUTE = 2,
141   BFD_MACH_O_MH_FVMLIB = 3,
142   BFD_MACH_O_MH_CORE = 4,
143   BFD_MACH_O_MH_PRELOAD = 5,
144   BFD_MACH_O_MH_DYLIB = 6,
145   BFD_MACH_O_MH_DYLINKER = 7,
146   BFD_MACH_O_MH_BUNDLE = 8
147 }
148 bfd_mach_o_filetype;
149
150 /* Constants for the type of a section.  */
151
152 typedef enum bfd_mach_o_section_type
153 {
154   /* Regular section.  */
155   BFD_MACH_O_S_REGULAR = 0x0,
156
157   /* Zero fill on demand section.  */
158   BFD_MACH_O_S_ZEROFILL = 0x1,
159
160   /* Section with only literal C strings.  */
161   BFD_MACH_O_S_CSTRING_LITERALS = 0x2,
162
163   /* Section with only 4 byte literals.  */
164   BFD_MACH_O_S_4BYTE_LITERALS = 0x3,
165
166   /* Section with only 8 byte literals.  */
167   BFD_MACH_O_S_8BYTE_LITERALS = 0x4,
168
169   /* Section with only pointers to literals.  */
170   BFD_MACH_O_S_LITERAL_POINTERS = 0x5,
171
172   /* For the two types of symbol pointers sections and the symbol stubs
173      section they have indirect symbol table entries.  For each of the
174      entries in the section the indirect symbol table entries, in
175      corresponding order in the indirect symbol table, start at the index
176      stored in the reserved1 field of the section structure.  Since the
177      indirect symbol table entries correspond to the entries in the
178      section the number of indirect symbol table entries is inferred from
179      the size of the section divided by the size of the entries in the
180      section.  For symbol pointers sections the size of the entries in
181      the section is 4 bytes and for symbol stubs sections the byte size
182      of the stubs is stored in the reserved2 field of the section
183      structure.  */
184
185   /* Section with only non-lazy symbol pointers.  */
186   BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS = 0x6,
187
188   /* Section with only lazy symbol pointers.  */
189   BFD_MACH_O_S_LAZY_SYMBOL_POINTERS = 0x7,
190
191   /* Section with only symbol stubs, byte size of stub in the reserved2 field.  */
192   BFD_MACH_O_S_SYMBOL_STUBS = 0x8,
193
194   /* Section with only function pointers for initialization.  */
195   BFD_MACH_O_S_MOD_INIT_FUNC_POINTERS = 0x9
196 }
197 bfd_mach_o_section_type;
198
199 /* The flags field of a section structure is separated into two parts a section
200    type and section attributes.  The section types are mutually exclusive (it
201    can only have one type) but the section attributes are not (it may have more
202    than one attribute).  */
203
204 #define BFD_MACH_O_SECTION_TYPE_MASK        0x000000ff
205
206 /* Constants for the section attributes part of the flags field of a section
207    structure.  */
208 #define BFD_MACH_O_SECTION_ATTRIBUTES_MASK  0xffffff00
209 /* System setable attributes.  */
210 #define BFD_MACH_O_SECTION_ATTRIBUTES_SYS   0x00ffff00
211 /* User attributes.  */   
212 #define BFD_MACH_O_SECTION_ATTRIBUTES_USR   0xff000000
213
214 /* Section has local relocation entries.  */
215 #define BFD_MACH_O_S_ATTR_LOC_RELOC         0x00000100
216
217 /* Section has external relocation entries.  */  
218 #define BFD_MACH_O_S_ATTR_EXT_RELOC         0x00000200
219
220 /* Section contains some machine instructions.  */
221 #define BFD_MACH_O_S_ATTR_SOME_INSTRUCTIONS 0x00004000
222
223 #define BFD_MACH_O_S_ATTR_DEBUG             0x02000000
224
225 /* Section contains only true machine instructions.  */
226 #define BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS 0x80000000
227
228 typedef unsigned long bfd_mach_o_cpu_subtype;
229
230 typedef struct bfd_mach_o_header
231 {
232   unsigned long magic;
233   unsigned long cputype;
234   unsigned long cpusubtype;
235   unsigned long filetype;
236   unsigned long ncmds;
237   unsigned long sizeofcmds;
238   unsigned long flags;
239   unsigned int reserved;
240   /* Version 1: 32 bits, version 2: 64 bits.  */
241   unsigned int version;
242   enum bfd_endian byteorder;
243 }
244 bfd_mach_o_header;
245
246 typedef struct bfd_mach_o_section
247 {
248   asection *bfdsection;
249   char sectname[16 + 1];
250   char segname[16 + 1];
251   bfd_vma addr;
252   bfd_vma size;
253   bfd_vma offset;
254   unsigned long align;
255   bfd_vma reloff;
256   unsigned long nreloc;
257   unsigned long flags;
258   unsigned long reserved1;
259   unsigned long reserved2;
260   unsigned long reserved3;
261 }
262 bfd_mach_o_section;
263
264 typedef struct bfd_mach_o_segment_command
265 {
266   char segname[16 + 1];
267   bfd_vma vmaddr;
268   bfd_vma vmsize;
269   bfd_vma fileoff;
270   unsigned long filesize;
271   unsigned long maxprot;        /* Maximum permitted protection.  */
272   unsigned long initprot;       /* Initial protection.  */
273   unsigned long nsects;
274   unsigned long flags;
275   bfd_mach_o_section *sections;
276   asection *segment;
277 }
278 bfd_mach_o_segment_command;
279
280 /* Protection flags.  */
281 #define BFD_MACH_O_PROT_READ    0x01
282 #define BFD_MACH_O_PROT_WRITE   0x02
283 #define BFD_MACH_O_PROT_EXECUTE 0x04
284
285 typedef struct bfd_mach_o_symtab_command
286 {
287   unsigned long symoff;
288   unsigned long nsyms;
289   unsigned long stroff;
290   unsigned long strsize;
291   asymbol *symbols;
292   char *strtab;
293   asection *stabs_segment;
294   asection *stabstr_segment;
295 }
296 bfd_mach_o_symtab_command;
297
298 /* This is the second set of the symbolic information which is used to support
299    the data structures for the dynamically link editor.
300
301    The original set of symbolic information in the symtab_command which contains
302    the symbol and string tables must also be present when this load command is
303    present.  When this load command is present the symbol table is organized
304    into three groups of symbols:
305        local symbols (static and debugging symbols) - grouped by module
306        defined external symbols - grouped by module (sorted by name if not lib)
307        undefined external symbols (sorted by name)
308    In this load command there are offsets and counts to each of the three groups
309    of symbols.
310
311    This load command contains a the offsets and sizes of the following new
312    symbolic information tables:
313        table of contents
314        module table
315        reference symbol table
316        indirect symbol table
317    The first three tables above (the table of contents, module table and
318    reference symbol table) are only present if the file is a dynamically linked
319    shared library.  For executable and object modules, which are files
320    containing only one module, the information that would be in these three
321    tables is determined as follows:
322        table of contents - the defined external symbols are sorted by name
323        module table - the file contains only one module so everything in the
324                       file is part of the module.
325        reference symbol table - is the defined and undefined external symbols
326
327    For dynamically linked shared library files this load command also contains
328    offsets and sizes to the pool of relocation entries for all sections
329    separated into two groups:
330        external relocation entries
331        local relocation entries
332    For executable and object modules the relocation entries continue to hang
333    off the section structures.  */
334
335 typedef struct bfd_mach_o_dysymtab_command
336 {
337   /* The symbols indicated by symoff and nsyms of the LC_SYMTAB load command
338      are grouped into the following three groups:
339        local symbols (further grouped by the module they are from)
340        defined external symbols (further grouped by the module they are from)
341        undefined symbols
342
343      The local symbols are used only for debugging.  The dynamic binding
344      process may have to use them to indicate to the debugger the local
345      symbols for a module that is being bound.
346
347      The last two groups are used by the dynamic binding process to do the
348      binding (indirectly through the module table and the reference symbol
349      table when this is a dynamically linked shared library file).  */
350
351   unsigned long ilocalsym;    /* Index to local symbols.  */
352   unsigned long nlocalsym;    /* Number of local symbols.  */
353   unsigned long iextdefsym;   /* Index to externally defined symbols.  */
354   unsigned long nextdefsym;   /* Number of externally defined symbols.  */
355   unsigned long iundefsym;    /* Index to undefined symbols.  */
356   unsigned long nundefsym;    /* Number of undefined symbols.  */
357
358   /* For the for the dynamic binding process to find which module a symbol
359      is defined in the table of contents is used (analogous to the ranlib
360      structure in an archive) which maps defined external symbols to modules
361      they are defined in.  This exists only in a dynamically linked shared
362      library file.  For executable and object modules the defined external
363      symbols are sorted by name and is use as the table of contents.  */
364
365   unsigned long tocoff;       /* File offset to table of contents.  */
366   unsigned long ntoc;         /* Number of entries in table of contents.  */
367
368   /* To support dynamic binding of "modules" (whole object files) the symbol
369      table must reflect the modules that the file was created from.  This is
370      done by having a module table that has indexes and counts into the merged
371      tables for each module.  The module structure that these two entries
372      refer to is described below.  This exists only in a dynamically linked
373      shared library file.  For executable and object modules the file only
374      contains one module so everything in the file belongs to the module.  */
375
376   unsigned long modtaboff;    /* File offset to module table.  */
377   unsigned long nmodtab;      /* Number of module table entries.  */
378
379   /* To support dynamic module binding the module structure for each module
380      indicates the external references (defined and undefined) each module
381      makes.  For each module there is an offset and a count into the
382      reference symbol table for the symbols that the module references.
383      This exists only in a dynamically linked shared library file.  For
384      executable and object modules the defined external symbols and the
385      undefined external symbols indicates the external references.  */
386
387   unsigned long extrefsymoff;  /* Offset to referenced symbol table.  */
388   unsigned long nextrefsyms;   /* Number of referenced symbol table entries.  */
389
390   /* The sections that contain "symbol pointers" and "routine stubs" have
391      indexes and (implied counts based on the size of the section and fixed
392      size of the entry) into the "indirect symbol" table for each pointer
393      and stub.  For every section of these two types the index into the
394      indirect symbol table is stored in the section header in the field
395      reserved1.  An indirect symbol table entry is simply a 32bit index into
396      the symbol table to the symbol that the pointer or stub is referring to.
397      The indirect symbol table is ordered to match the entries in the section.  */
398
399   unsigned long indirectsymoff; /* File offset to the indirect symbol table.  */
400   unsigned long nindirectsyms;  /* Number of indirect symbol table entries.  */
401
402   /* To support relocating an individual module in a library file quickly the
403      external relocation entries for each module in the library need to be
404      accessed efficiently.  Since the relocation entries can't be accessed
405      through the section headers for a library file they are separated into
406      groups of local and external entries further grouped by module.  In this
407      case the presents of this load command who's extreloff, nextrel,
408      locreloff and nlocrel fields are non-zero indicates that the relocation
409      entries of non-merged sections are not referenced through the section
410      structures (and the reloff and nreloc fields in the section headers are
411      set to zero).
412
413      Since the relocation entries are not accessed through the section headers
414      this requires the r_address field to be something other than a section
415      offset to identify the item to be relocated.  In this case r_address is
416      set to the offset from the vmaddr of the first LC_SEGMENT command.
417
418      The relocation entries are grouped by module and the module table
419      entries have indexes and counts into them for the group of external
420      relocation entries for that the module.
421
422      For sections that are merged across modules there must not be any
423      remaining external relocation entries for them (for merged sections
424      remaining relocation entries must be local).  */
425
426   unsigned long extreloff;    /* Offset to external relocation entries.  */
427   unsigned long nextrel;      /* Number of external relocation entries.  */
428
429   /* All the local relocation entries are grouped together (they are not
430      grouped by their module since they are only used if the object is moved
431      from it statically link edited address).  */
432
433   unsigned long locreloff;    /* Offset to local relocation entries.  */
434   unsigned long nlocrel;      /* Number of local relocation entries.  */
435 }
436 bfd_mach_o_dysymtab_command;
437
438 /* An indirect symbol table entry is simply a 32bit index into the symbol table
439    to the symbol that the pointer or stub is refering to.  Unless it is for a
440    non-lazy symbol pointer section for a defined symbol which strip(1) as
441    removed.  In which case it has the value INDIRECT_SYMBOL_LOCAL.  If the
442    symbol was also absolute INDIRECT_SYMBOL_ABS is or'ed with that.  */
443
444 #define BFD_MACH_O_INDIRECT_SYMBOL_LOCAL 0x80000000
445 #define BFD_MACH_O_INDIRECT_SYMBOL_ABS   0x40000000
446
447 typedef struct bfd_mach_o_thread_flavour
448 {
449   unsigned long flavour;
450   bfd_vma offset;
451   unsigned long size;
452 }
453 bfd_mach_o_thread_flavour;
454
455 typedef struct bfd_mach_o_thread_command
456 {
457   unsigned long nflavours;
458   bfd_mach_o_thread_flavour *flavours;
459   asection *section;
460 }
461 bfd_mach_o_thread_command;
462
463 typedef struct bfd_mach_o_dylinker_command
464 {
465   unsigned long cmd;                 /* LC_ID_DYLINKER or LC_LOAD_DYLINKER.  */
466   unsigned long cmdsize;             /* Includes pathname string.  */
467   unsigned long name_offset;         /* Offset to library's path name.  */
468   unsigned long name_len;            /* Offset to library's path name.  */
469   asection *section;
470 }
471 bfd_mach_o_dylinker_command;
472
473 typedef struct bfd_mach_o_dylib_command
474 {
475   unsigned long cmd;                   /* LC_ID_DYLIB or LC_LOAD_DYLIB.  */
476   unsigned long cmdsize;               /* Includes pathname string.  */
477   unsigned long name_offset;           /* Offset to library's path name.  */
478   unsigned long name_len;              /* Offset to library's path name.  */
479   unsigned long timestamp;             /* Library's build time stamp.  */
480   unsigned long current_version;       /* Library's current version number.  */
481   unsigned long compatibility_version; /* Library's compatibility vers number.  */
482   asection *section;
483 }
484 bfd_mach_o_dylib_command;
485
486 typedef struct bfd_mach_o_prebound_dylib_command
487 {
488   unsigned long cmd;                 /* LC_PREBOUND_DYLIB.  */
489   unsigned long cmdsize;             /* Includes strings.  */
490   unsigned long name;                /* Library's path name.  */
491   unsigned long nmodules;            /* Number of modules in library.  */
492   unsigned long linked_modules;      /* Bit vector of linked modules.  */
493   asection *section;
494 }
495 bfd_mach_o_prebound_dylib_command;
496
497 typedef struct bfd_mach_o_uuid_command
498 {
499   unsigned long cmd;                 /* LC_PREBOUND_DYLIB.  */
500   unsigned long cmdsize;             /* Includes uuid.  */
501   unsigned char uuid[16];            /* Uuid.  */
502   asection *section;
503 }
504 bfd_mach_o_uuid_command;
505
506 typedef struct bfd_mach_o_load_command
507 {
508   bfd_mach_o_load_command_type type;
509   unsigned int type_required;
510   bfd_vma offset;
511   bfd_vma len;
512   union
513   {
514     bfd_mach_o_segment_command segment;
515     bfd_mach_o_symtab_command symtab;
516     bfd_mach_o_dysymtab_command dysymtab;
517     bfd_mach_o_thread_command thread;
518     bfd_mach_o_dylib_command dylib;
519     bfd_mach_o_dylinker_command dylinker;
520     bfd_mach_o_prebound_dylib_command prebound_dylib;
521     bfd_mach_o_uuid_command uuid;
522   }
523   command;
524 }
525 bfd_mach_o_load_command;
526
527 typedef struct mach_o_data_struct
528 {
529   bfd_mach_o_header header;
530   bfd_mach_o_load_command *commands;
531   unsigned long nsymbols;
532   asymbol *symbols;
533   unsigned long nsects;
534   bfd_mach_o_section **sections;
535   bfd *ibfd;
536 }
537 mach_o_data_struct;
538
539 #define bfd_get_mach_o_data(abfd) ((abfd)->tdata.mach_o_data)
540
541 typedef struct mach_o_data_struct bfd_mach_o_data_struct;
542
543 bfd_boolean        bfd_mach_o_valid  (bfd *);
544 int                bfd_mach_o_scan_read_symtab_symbol        (bfd *, bfd_mach_o_symtab_command *, asymbol *, unsigned long);
545 int                bfd_mach_o_scan_read_symtab_strtab        (bfd *, bfd_mach_o_symtab_command *);
546 int                bfd_mach_o_scan_read_symtab_symbols       (bfd *, bfd_mach_o_symtab_command *);
547 int                bfd_mach_o_scan_read_dysymtab_symbol      (bfd *, bfd_mach_o_dysymtab_command *, bfd_mach_o_symtab_command *, asymbol *, unsigned long);
548 int                bfd_mach_o_scan_start_address             (bfd *);
549 int                bfd_mach_o_scan                           (bfd *, bfd_mach_o_header *, bfd_mach_o_data_struct *);
550 bfd_boolean        bfd_mach_o_mkobject                       (bfd *);
551 const bfd_target * bfd_mach_o_object_p                       (bfd *);
552 const bfd_target * bfd_mach_o_core_p                         (bfd *);
553 const bfd_target * bfd_mach_o_archive_p                      (bfd *);
554 bfd *              bfd_mach_o_openr_next_archived_file       (bfd *, bfd *);
555 int                bfd_mach_o_lookup_section                 (bfd *, asection *, bfd_mach_o_load_command **, bfd_mach_o_section **);
556 int                bfd_mach_o_lookup_command                 (bfd *, bfd_mach_o_load_command_type, bfd_mach_o_load_command **);
557 unsigned long      bfd_mach_o_stack_addr                     (enum bfd_mach_o_cpu_type);
558 int                bfd_mach_o_core_fetch_environment         (bfd *, unsigned char **, unsigned int *);
559 char *             bfd_mach_o_core_file_failing_command      (bfd *);
560 int                bfd_mach_o_core_file_failing_signal       (bfd *);
561 bfd_boolean        bfd_mach_o_core_file_matches_executable_p (bfd *, bfd *);
562 bfd *bfd_mach_o_fat_extract (bfd *, bfd_format , const bfd_arch_info_type *);
563
564 extern const bfd_target mach_o_be_vec;
565 extern const bfd_target mach_o_le_vec;
566 extern const bfd_target mach_o_fat_vec;
567
568 #endif /* _BFD_MACH_O_H_ */