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