2012-01-04 Shinichiro Hamaji <shinichiro.hamaji@gmail.com>
[deliverable/binutils-gdb.git] / bfd / mach-o.h
CommitLineData
3af9a47b 1/* Mach-O support for BFD.
7f307238
IS
2 Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009, 2011,
3 2012 Free Software Foundation, Inc.
3af9a47b
NC
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"
74f26653 26#include "mach-o/loader.h"
15e1c58a 27
3af9a47b
NC
28typedef 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;
1e8a024a
TG
37 unsigned int reserved;
38 /* Version 1: 32 bits, version 2: 64 bits. */
39 unsigned int version;
3af9a47b
NC
40 enum bfd_endian byteorder;
41}
42bfd_mach_o_header;
43
f1bde64c
TG
44#define BFD_MACH_O_SEGNAME_SIZE 16
45#define BFD_MACH_O_SECTNAME_SIZE 16
46
3af9a47b
NC
47typedef struct bfd_mach_o_section
48{
53d58d96 49 /* Fields present in the file. */
f1bde64c
TG
50 char sectname[BFD_MACH_O_SECTNAME_SIZE + 1]; /* Always NUL padded. */
51 char segname[BFD_MACH_O_SEGNAME_SIZE + 1];
3af9a47b
NC
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;
1e8a024a 61 unsigned long reserved3;
53d58d96
TG
62
63 /* Corresponding bfd section. */
64 asection *bfdsection;
f1bde64c
TG
65
66 /* Simply linked list. */
67 struct bfd_mach_o_section *next;
3af9a47b
NC
68}
69bfd_mach_o_section;
70
71typedef struct bfd_mach_o_segment_command
72{
a4551119 73 char segname[BFD_MACH_O_SEGNAME_SIZE + 1];
3af9a47b
NC
74 bfd_vma vmaddr;
75 bfd_vma vmsize;
76 bfd_vma fileoff;
77 unsigned long filesize;
15e1c58a
TG
78 unsigned long maxprot; /* Maximum permitted protection. */
79 unsigned long initprot; /* Initial protection. */
3af9a47b
NC
80 unsigned long nsects;
81 unsigned long flags;
f1bde64c
TG
82
83 /* Linked list of sections. */
84 bfd_mach_o_section *sect_head;
85 bfd_mach_o_section *sect_tail;
3af9a47b
NC
86}
87bfd_mach_o_segment_command;
88
15e1c58a
TG
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
92bc0e80
TG
94/* Expanded internal representation of a relocation entry. */
95typedef 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}
105bfd_mach_o_reloc_info;
106
107typedef struct bfd_mach_o_asymbol
108{
109 /* The actual symbol which the rest of BFD works with. */
110 asymbol symbol;
111
7f307238 112 /* Mach-O symbol fields. */
92bc0e80
TG
113 unsigned char n_type;
114 unsigned char n_sect;
115 unsigned short n_desc;
116}
117bfd_mach_o_asymbol;
118
7f307238
IS
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
3af9a47b
NC
130typedef struct bfd_mach_o_symtab_command
131{
92bc0e80
TG
132 unsigned int symoff;
133 unsigned int nsyms;
134 unsigned int stroff;
135 unsigned int strsize;
136 bfd_mach_o_asymbol *symbols;
3af9a47b 137 char *strtab;
3af9a47b
NC
138}
139bfd_mach_o_symtab_command;
140
141/* This is the second set of the symbolic information which is used to support
7dee875e 142 the data structures for the dynamically link editor.
e84d6fca 143
3af9a47b
NC
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.
e84d6fca 153
3af9a47b
NC
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
7dee875e 161 reference symbol table) are only present if the file is a dynamically linked
3af9a47b
NC
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
e84d6fca 169
7dee875e 170 For dynamically linked shared library files this load command also contains
3af9a47b
NC
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
046b007d
TG
178typedef 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}
234bfd_mach_o_dylib_module;
046b007d
TG
235
236typedef 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}
244bfd_mach_o_dylib_table_of_content;
046b007d
TG
245
246typedef 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}
254bfd_mach_o_dylib_reference;
255#define BFD_MACH_O_REFERENCE_SIZE 4
256
3af9a47b
NC
257typedef 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
e84d6fca 264
3af9a47b
NC
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.
e84d6fca 268
3af9a47b
NC
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
7dee875e 271 table when this is a dynamically linked shared library file). */
3af9a47b
NC
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
7dee875e 283 they are defined in. This exists only in a dynamically linked shared
3af9a47b
NC
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
7dee875e 294 refer to is described below. This exists only in a dynamically linked
3af9a47b
NC
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.
7dee875e 305 This exists only in a dynamically linked shared library file. For
3af9a47b
NC
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
7dee875e 353 from it statically link edited address). */
3af9a47b
NC
354
355 unsigned long locreloff; /* Offset to local relocation entries. */
356 unsigned long nlocrel; /* Number of local relocation entries. */
046b007d
TG
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;
3af9a47b 362}
e84d6fca 363bfd_mach_o_dysymtab_command;
3af9a47b 364
e84d6fca 365/* An indirect symbol table entry is simply a 32bit index into the symbol table
3af9a47b 366 to the symbol that the pointer or stub is refering to. Unless it is for a
046b007d 367 non-lazy symbol pointer section for a defined symbol which strip(1) has
3af9a47b
NC
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
15e1c58a
TG
371#define BFD_MACH_O_INDIRECT_SYMBOL_LOCAL 0x80000000
372#define BFD_MACH_O_INDIRECT_SYMBOL_ABS 0x40000000
046b007d 373#define BFD_MACH_O_INDIRECT_SYMBOL_SIZE 4
3af9a47b 374
b32e07d7
TG
375/* For LC_THREAD or LC_UNIXTHREAD. */
376
3af9a47b
NC
377typedef struct bfd_mach_o_thread_flavour
378{
379 unsigned long flavour;
b32e07d7 380 unsigned long offset;
3af9a47b
NC
381 unsigned long size;
382}
383bfd_mach_o_thread_flavour;
384
385typedef struct bfd_mach_o_thread_command
386{
387 unsigned long nflavours;
e84d6fca 388 bfd_mach_o_thread_flavour *flavours;
3af9a47b
NC
389 asection *section;
390}
391bfd_mach_o_thread_command;
392
046b007d
TG
393/* For LC_LOAD_DYLINKER and LC_ID_DYLINKER. */
394
3af9a47b
NC
395typedef struct bfd_mach_o_dylinker_command
396{
846b9259
TG
397 unsigned long name_offset; /* Offset to library's path name. */
398 unsigned long name_len; /* Offset to library's path name. */
b32e07d7 399 char *name_str;
3af9a47b
NC
400}
401bfd_mach_o_dylinker_command;
402
046b007d
TG
403/* For LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB, LC_ID_DYLIB
404 or LC_REEXPORT_DYLIB. */
405
3af9a47b
NC
406typedef struct bfd_mach_o_dylib_command
407{
3af9a47b
NC
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. */
b32e07d7 413 char *name_str;
3af9a47b
NC
414}
415bfd_mach_o_dylib_command;
416
046b007d
TG
417/* For LC_PREBOUND_DYLIB. */
418
3af9a47b
NC
419typedef struct bfd_mach_o_prebound_dylib_command
420{
3af9a47b
NC
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. */
3af9a47b
NC
424}
425bfd_mach_o_prebound_dylib_command;
426
046b007d
TG
427/* For LC_UUID. */
428
15e1c58a
TG
429typedef struct bfd_mach_o_uuid_command
430{
046b007d 431 unsigned char uuid[16];
15e1c58a
TG
432}
433bfd_mach_o_uuid_command;
434
046b007d
TG
435/* For LC_CODE_SIGNATURE or LC_SEGMENT_SPLIT_INFO. */
436
437typedef struct bfd_mach_o_linkedit_command
438{
439 unsigned long dataoff;
440 unsigned long datasize;
441}
442bfd_mach_o_linkedit_command;
443
444typedef struct bfd_mach_o_str_command
445{
446 unsigned long stroff;
447 unsigned long str_len;
448 char *str;
449}
450bfd_mach_o_str_command;
451
ad86f1fb
TG
452typedef 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}
474bfd_mach_o_dyld_info_command;
475
edbdea0e
TG
476typedef 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}
483bfd_mach_o_version_min_command;
484
3af9a47b
NC
485typedef struct bfd_mach_o_load_command
486{
487 bfd_mach_o_load_command_type type;
154a1ee5 488 bfd_boolean type_required;
92bc0e80
TG
489 unsigned int offset;
490 unsigned int len;
3af9a47b
NC
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;
15e1c58a 500 bfd_mach_o_uuid_command uuid;
046b007d
TG
501 bfd_mach_o_linkedit_command linkedit;
502 bfd_mach_o_str_command str;
ad86f1fb 503 bfd_mach_o_dyld_info_command dyld_info;
edbdea0e 504 bfd_mach_o_version_min_command version_min;
3af9a47b
NC
505 }
506 command;
507}
508bfd_mach_o_load_command;
509
510typedef struct mach_o_data_struct
511{
92bc0e80 512 /* Mach-O header. */
3af9a47b 513 bfd_mach_o_header header;
92bc0e80 514 /* Array of load commands (length is given by header.ncmds). */
3af9a47b 515 bfd_mach_o_load_command *commands;
92bc0e80
TG
516
517 /* Flatten array of sections. The array is 0-based. */
3af9a47b
NC
518 unsigned long nsects;
519 bfd_mach_o_section **sections;
92bc0e80 520
7f307238 521 /* Used while writing: current length of the output file. This is used
92bc0e80
TG
522 to allocate space in the file. */
523 ufile_ptr filelen;
046b007d
TG
524
525 /* As symtab is referenced by other load command, it is handy to have
edbdea0e 526 a direct access to it. Although it is not clearly stated, only one symtab
046b007d
TG
527 is expected. */
528 bfd_mach_o_symtab_command *symtab;
b32e07d7 529 bfd_mach_o_dysymtab_command *dysymtab;
d9071b0c 530
7f307238
IS
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
d9071b0c
TG
543 /* A place to stash dwarf2 info for this bfd. */
544 void *dwarf2_find_line_info;
dff55db0 545
2ca7691a
TG
546 /* BFD of .dSYM file. */
547 bfd *dsym_bfd;
548
dff55db0
TG
549 /* Cache of dynamic relocs. */
550 arelent *dyn_reloc_cache;
3af9a47b 551}
046b007d 552bfd_mach_o_data_struct;
3af9a47b 553
c5012cd8
TG
554typedef struct bfd_mach_o_xlat_name
555{
556 const char *name;
557 unsigned long val;
558}
559bfd_mach_o_xlat_name;
560
92bc0e80 561/* Target specific routines. */
15e1c58a 562
046b007d 563#define bfd_mach_o_get_data(abfd) ((abfd)->tdata.mach_o_data)
92bc0e80
TG
564#define bfd_mach_o_get_backend_data(abfd) \
565 ((bfd_mach_o_backend_data*)(abfd)->xvec->backend_data)
3af9a47b 566
f1bde64c
TG
567/* Get the Mach-O header for section SEC. */
568#define bfd_mach_o_get_mach_o_section(sec) \
569 ((bfd_mach_o_section *)(sec)->used_by_bfd)
570
154a1ee5 571bfd_boolean bfd_mach_o_valid (bfd *);
154a1ee5
TG
572bfd_boolean bfd_mach_o_mkobject_init (bfd *);
573const bfd_target *bfd_mach_o_object_p (bfd *);
574const bfd_target *bfd_mach_o_core_p (bfd *);
575const bfd_target *bfd_mach_o_archive_p (bfd *);
576bfd *bfd_mach_o_openr_next_archived_file (bfd *, bfd *);
42fa0891
TG
577bfd_boolean bfd_mach_o_set_arch_mach (bfd *, enum bfd_architecture,
578 unsigned long);
154a1ee5 579int bfd_mach_o_lookup_command (bfd *, bfd_mach_o_load_command_type, bfd_mach_o_load_command **);
f1bde64c 580bfd_boolean bfd_mach_o_new_section_hook (bfd *, asection *);
154a1ee5
TG
581bfd_boolean bfd_mach_o_write_contents (bfd *);
582bfd_boolean bfd_mach_o_bfd_copy_private_symbol_data (bfd *, asymbol *,
583 bfd *, asymbol *);
584bfd_boolean bfd_mach_o_bfd_copy_private_section_data (bfd *, asection *,
585 bfd *, asection *);
586bfd_boolean bfd_mach_o_bfd_copy_private_bfd_data (bfd *, bfd *);
0c9ef0f0 587bfd_boolean bfd_mach_o_bfd_set_private_flags (bfd *, flagword);
154a1ee5
TG
588long bfd_mach_o_get_symtab_upper_bound (bfd *);
589long bfd_mach_o_canonicalize_symtab (bfd *, asymbol **);
b2b62060
TG
590long bfd_mach_o_get_synthetic_symtab (bfd *, long, asymbol **, long,
591 asymbol **, asymbol **ret);
b32e07d7
TG
592long bfd_mach_o_get_reloc_upper_bound (bfd *, asection *);
593long bfd_mach_o_canonicalize_reloc (bfd *, asection *, arelent **, asymbol **);
594long bfd_mach_o_get_dynamic_reloc_upper_bound (bfd *);
595long bfd_mach_o_canonicalize_dynamic_reloc (bfd *, arelent **, asymbol **);
154a1ee5
TG
596asymbol *bfd_mach_o_make_empty_symbol (bfd *);
597void bfd_mach_o_get_symbol_info (bfd *, asymbol *, symbol_info *);
598void bfd_mach_o_print_symbol (bfd *, PTR, asymbol *, bfd_print_symbol_type);
154a1ee5
TG
599int bfd_mach_o_sizeof_headers (bfd *, struct bfd_link_info *);
600unsigned long bfd_mach_o_stack_addr (enum bfd_mach_o_cpu_type);
601int bfd_mach_o_core_fetch_environment (bfd *, unsigned char **, unsigned int *);
602char *bfd_mach_o_core_file_failing_command (bfd *);
603int bfd_mach_o_core_file_failing_signal (bfd *);
604bfd_boolean bfd_mach_o_core_file_matches_executable_p (bfd *, bfd *);
846b9259 605bfd *bfd_mach_o_fat_extract (bfd *, bfd_format , const bfd_arch_info_type *);
154a1ee5
TG
606const bfd_target *bfd_mach_o_header_p (bfd *, bfd_mach_o_filetype,
607 bfd_mach_o_cpu_type);
b32e07d7 608bfd_boolean bfd_mach_o_build_commands (bfd *);
154a1ee5
TG
609bfd_boolean bfd_mach_o_set_section_contents (bfd *, asection *, const void *,
610 file_ptr, bfd_size_type);
c2f09c75 611unsigned int bfd_mach_o_version (bfd *);
3af9a47b 612
ab76eeaf 613unsigned int bfd_mach_o_get_section_type_from_name (bfd *, const char *);
53d58d96 614unsigned int bfd_mach_o_get_section_attribute_from_name (const char *);
a4551119
TG
615
616void bfd_mach_o_convert_section_name_to_bfd (bfd *, const char *, const char *,
617 const char **, flagword *);
d9071b0c
TG
618bfd_boolean bfd_mach_o_find_nearest_line (bfd *, asection *, asymbol **,
619 bfd_vma, const char **,
620 const char **, unsigned int *);
621bfd_boolean bfd_mach_o_close_and_cleanup (bfd *);
dff55db0 622bfd_boolean bfd_mach_o_free_cached_info (bfd *);
53d58d96 623
c5012cd8
TG
624unsigned int bfd_mach_o_section_get_nbr_indirect (bfd *, bfd_mach_o_section *);
625unsigned int bfd_mach_o_section_get_entry_size (bfd *, bfd_mach_o_section *);
626bfd_boolean bfd_mach_o_read_symtab_symbols (bfd *);
627bfd_boolean bfd_mach_o_read_symtab_strtab (bfd *abfd);
628
7f307238
IS
629/* A placeholder in case we need to suppress emitting the dysymtab for some
630 reason (e.g. compatibility with older system versions). */
631#define bfd_mach_o_should_emit_dysymtab(x) TRUE
632
c5012cd8
TG
633extern const bfd_mach_o_xlat_name bfd_mach_o_section_attribute_name[];
634extern const bfd_mach_o_xlat_name bfd_mach_o_section_type_name[];
635
3af9a47b
NC
636extern const bfd_target mach_o_fat_vec;
637
a4551119
TG
638/* Interfaces between BFD names and Mach-O names. */
639
640typedef struct mach_o_section_name_xlat
641{
642 const char *bfd_name;
643 const char *mach_o_name;
644 flagword bfd_flags;
645 unsigned int macho_sectype;
646 unsigned int macho_secattr;
647 unsigned int sectalign;
648} mach_o_section_name_xlat;
649
650typedef struct mach_o_segment_name_xlat
651{
652 const char *segname;
653 const mach_o_section_name_xlat *sections;
654} mach_o_segment_name_xlat;
655
656const mach_o_section_name_xlat *
657bfd_mach_o_section_data_for_mach_sect (bfd *, const char *, const char *);
658const mach_o_section_name_xlat *
659bfd_mach_o_section_data_for_bfd_name (bfd *, const char *, const char **);
660
661typedef struct bfd_mach_o_backend_data
662{
663 enum bfd_architecture arch;
664 bfd_boolean (*_bfd_mach_o_swap_reloc_in)(arelent *, bfd_mach_o_reloc_info *);
665 bfd_boolean (*_bfd_mach_o_swap_reloc_out)(arelent *, bfd_mach_o_reloc_info *);
666 bfd_boolean (*_bfd_mach_o_print_thread)(bfd *, bfd_mach_o_thread_flavour *,
667 void *, char *);
668 const mach_o_segment_name_xlat *segsec_names_xlat;
ab76eeaf 669 bfd_boolean (*bfd_mach_o_section_type_valid_for_target) (unsigned long);
a4551119
TG
670}
671bfd_mach_o_backend_data;
672
7f307238
IS
673/* Symbol type tests. */
674
675#define IS_MACHO_INDIRECT(x) (((x) & BFD_MACH_O_N_TYPE) == BFD_MACH_O_N_INDR)
676
3af9a47b 677#endif /* _BFD_MACH_O_H_ */
This page took 0.493588 seconds and 4 git commands to generate.