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