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