Back to index

cell-binutils  2.17cvs20070401
Classes | Defines | Typedefs | Enumerations | Functions | Variables
mach-o.h File Reference
#include "bfd.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  bfd_mach_o_header
struct  bfd_mach_o_section
struct  bfd_mach_o_segment_command
struct  bfd_mach_o_symtab_command
struct  bfd_mach_o_dysymtab_command
struct  bfd_mach_o_thread_flavour
struct  bfd_mach_o_thread_command
struct  bfd_mach_o_dylinker_command
struct  bfd_mach_o_dylib_command
struct  bfd_mach_o_prebound_dylib_command
struct  bfd_mach_o_load_command
struct  mach_o_data_struct
union  bfd_mach_o_load_command.command

Defines

#define BFD_MACH_O_N_STAB   0xe0 /* If any of these bits set, a symbolic debugging entry. */
#define BFD_MACH_O_N_PEXT   0x10 /* Private external symbol bit. */
#define BFD_MACH_O_N_TYPE   0x0e /* Mask for the type bits. */
#define BFD_MACH_O_N_EXT   0x01 /* External symbol bit, set for external symbols. */
#define BFD_MACH_O_N_UNDF   0x00 /* Undefined, n_sect == NO_SECT. */
#define BFD_MACH_O_N_ABS   0x02 /* Absolute, n_sect == NO_SECT. */
#define BFD_MACH_O_N_SECT   0x0e /* Defined in section number n_sect. */
#define BFD_MACH_O_N_PBUD   0x0c /* Prebound undefined (defined in a dylib). */
#define BFD_MACH_O_N_INDR   0x0a /* Indirect. */
#define BFD_MACH_O_LC_REQ_DYLD   0x80000000
#define INDIRECT_SYMBOL_LOCAL   0x80000000
#define INDIRECT_SYMBOL_ABS   0x40000000

Typedefs

typedef enum
bfd_mach_o_ppc_thread_flavour 
bfd_mach_o_ppc_thread_flavour
typedef enum
bfd_mach_o_i386_thread_flavour 
bfd_mach_o_i386_thread_flavour
typedef enum
bfd_mach_o_load_command_type 
bfd_mach_o_load_command_type
typedef enum bfd_mach_o_cpu_type bfd_mach_o_cpu_type
typedef enum bfd_mach_o_filetype bfd_mach_o_filetype
typedef enum
bfd_mach_o_section_type 
bfd_mach_o_section_type
typedef unsigned long bfd_mach_o_cpu_subtype
typedef struct bfd_mach_o_header bfd_mach_o_header
typedef struct bfd_mach_o_section bfd_mach_o_section
typedef struct
bfd_mach_o_segment_command 
bfd_mach_o_segment_command
typedef struct
bfd_mach_o_symtab_command 
bfd_mach_o_symtab_command
typedef struct
bfd_mach_o_dysymtab_command 
bfd_mach_o_dysymtab_command
typedef struct
bfd_mach_o_thread_flavour 
bfd_mach_o_thread_flavour
typedef struct
bfd_mach_o_thread_command 
bfd_mach_o_thread_command
typedef struct
bfd_mach_o_dylinker_command 
bfd_mach_o_dylinker_command
typedef struct
bfd_mach_o_dylib_command 
bfd_mach_o_dylib_command
typedef struct
bfd_mach_o_prebound_dylib_command 
bfd_mach_o_prebound_dylib_command
typedef struct
bfd_mach_o_load_command 
bfd_mach_o_load_command
typedef struct mach_o_data_struct mach_o_data_struct

Enumerations

enum  bfd_mach_o_ppc_thread_flavour { BFD_MACH_O_PPC_THREAD_STATE = 1, BFD_MACH_O_PPC_FLOAT_STATE = 2, BFD_MACH_O_PPC_EXCEPTION_STATE = 3, BFD_MACH_O_PPC_VECTOR_STATE = 4 }
enum  bfd_mach_o_i386_thread_flavour {
  BFD_MACH_O_i386_NEW_THREAD_STATE = 1, BFD_MACH_O_i386_FLOAT_STATE = 2, BFD_MACH_O_i386_ISA_PORT_MAP_STATE = 3, BFD_MACH_O_i386_V86_ASSIST_STATE = 4,
  BFD_MACH_O_i386_REGS_SEGS_STATE = 5, BFD_MACH_O_i386_THREAD_SYSCALL_STATE = 6, BFD_MACH_O_i386_THREAD_STATE_NONE = 7, BFD_MACH_O_i386_SAVED_STATE = 8,
  BFD_MACH_O_i386_THREAD_STATE = -1, BFD_MACH_O_i386_THREAD_FPSTATE = -2, BFD_MACH_O_i386_THREAD_EXCEPTSTATE = -3, BFD_MACH_O_i386_THREAD_CTHREADSTATE = -4
}
enum  bfd_mach_o_load_command_type {
  BFD_MACH_O_LC_SEGMENT = 0x1, BFD_MACH_O_LC_SYMTAB = 0x2, BFD_MACH_O_LC_SYMSEG = 0x3, BFD_MACH_O_LC_THREAD = 0x4,
  BFD_MACH_O_LC_UNIXTHREAD = 0x5, BFD_MACH_O_LC_LOADFVMLIB = 0x6, BFD_MACH_O_LC_IDFVMLIB = 0x7, BFD_MACH_O_LC_IDENT = 0x8,
  BFD_MACH_O_LC_FVMFILE = 0x9, BFD_MACH_O_LC_PREPAGE = 0xa, BFD_MACH_O_LC_DYSYMTAB = 0xb, BFD_MACH_O_LC_LOAD_DYLIB = 0xc,
  BFD_MACH_O_LC_ID_DYLIB = 0xd, BFD_MACH_O_LC_LOAD_DYLINKER = 0xe, BFD_MACH_O_LC_ID_DYLINKER = 0xf, BFD_MACH_O_LC_PREBOUND_DYLIB = 0x10,
  BFD_MACH_O_LC_ROUTINES = 0x11, BFD_MACH_O_LC_SUB_FRAMEWORK = 0x12, BFD_MACH_O_LC_SUB_UMBRELLA = 0x13, BFD_MACH_O_LC_SUB_CLIENT = 0x14,
  BFD_MACH_O_LC_SUB_LIBRARY = 0x15, BFD_MACH_O_LC_TWOLEVEL_HINTS = 0x16, BFD_MACH_O_LC_PREBIND_CKSUM = 0x17, BFD_MACH_O_LC_LOAD_WEAK_DYLIB = 0x18
}
enum  bfd_mach_o_cpu_type {
  BFD_MACH_O_CPU_TYPE_VAX = 1, BFD_MACH_O_CPU_TYPE_MC680x0 = 6, BFD_MACH_O_CPU_TYPE_I386 = 7, BFD_MACH_O_CPU_TYPE_MIPS = 8,
  BFD_MACH_O_CPU_TYPE_MC98000 = 10, BFD_MACH_O_CPU_TYPE_HPPA = 11, BFD_MACH_O_CPU_TYPE_ARM = 12, BFD_MACH_O_CPU_TYPE_MC88000 = 13,
  BFD_MACH_O_CPU_TYPE_SPARC = 14, BFD_MACH_O_CPU_TYPE_I860 = 15, BFD_MACH_O_CPU_TYPE_ALPHA = 16, BFD_MACH_O_CPU_TYPE_POWERPC = 18
}
enum  bfd_mach_o_filetype {
  BFD_MACH_O_MH_OBJECT = 1, BFD_MACH_O_MH_EXECUTE = 2, BFD_MACH_O_MH_FVMLIB = 3, BFD_MACH_O_MH_CORE = 4,
  BFD_MACH_O_MH_PRELOAD = 5, BFD_MACH_O_MH_DYLIB = 6, BFD_MACH_O_MH_DYLINKER = 7, BFD_MACH_O_MH_BUNDLE = 8
}
enum  bfd_mach_o_section_type {
  BFD_MACH_O_S_REGULAR = 0x0, BFD_MACH_O_S_ZEROFILL = 0x1, BFD_MACH_O_S_CSTRING_LITERALS = 0x2, BFD_MACH_O_S_4BYTE_LITERALS = 0x3,
  BFD_MACH_O_S_8BYTE_LITERALS = 0x4, BFD_MACH_O_S_LITERAL_POINTERS = 0x5, BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS = 0x6, BFD_MACH_O_S_LAZY_SYMBOL_POINTERS = 0x7,
  BFD_MACH_O_S_SYMBOL_STUBS = 0x8, BFD_MACH_O_S_MOD_INIT_FUNC_POINTERS = 0x9
}

Functions

bfd_boolean bfd_mach_o_valid (bfd *)
int bfd_mach_o_scan_read_symtab_symbol (bfd *, bfd_mach_o_symtab_command *, asymbol *, unsigned long)
int bfd_mach_o_scan_read_symtab_strtab (bfd *, bfd_mach_o_symtab_command *)
int bfd_mach_o_scan_read_symtab_symbols (bfd *, bfd_mach_o_symtab_command *)
int bfd_mach_o_scan_read_dysymtab_symbol (bfd *, bfd_mach_o_dysymtab_command *, bfd_mach_o_symtab_command *, asymbol *, unsigned long)
int bfd_mach_o_scan_start_address (bfd *)
int bfd_mach_o_scan (bfd *, bfd_mach_o_header *, bfd_mach_o_data_struct *)
bfd_boolean bfd_mach_o_mkobject (bfd *)
const bfd_targetbfd_mach_o_object_p (bfd *)
const bfd_targetbfd_mach_o_core_p (bfd *)
const bfd_targetbfd_mach_o_archive_p (bfd *)
bfdbfd_mach_o_openr_next_archived_file (bfd *, bfd *)
int bfd_mach_o_lookup_section (bfd *, asection *, bfd_mach_o_load_command **, bfd_mach_o_section **)
int bfd_mach_o_lookup_command (bfd *, bfd_mach_o_load_command_type, bfd_mach_o_load_command **)
unsigned long bfd_mach_o_stack_addr (enum bfd_mach_o_cpu_type)
int bfd_mach_o_core_fetch_environment (bfd *, unsigned char **, unsigned int *)
char * bfd_mach_o_core_file_failing_command (bfd *)
int bfd_mach_o_core_file_failing_signal (bfd *)
bfd_boolean bfd_mach_o_core_file_matches_executable_p (bfd *, bfd *)

Variables

const bfd_target mach_o_be_vec
const bfd_target mach_o_le_vec
const bfd_target mach_o_fat_vec

Class Documentation

struct bfd_mach_o_header

Definition at line 176 of file mach-o.h.

Class Members
unsigned long cpusubtype
unsigned long cputype
unsigned long filetype
unsigned long flags
unsigned long magic
unsigned long ncmds
unsigned long sizeofcmds
struct bfd_mach_o_section

Definition at line 189 of file mach-o.h.

Collaboration diagram for bfd_mach_o_section:
Class Members
bfd_vma addr
unsigned long align
asection * bfdsection
unsigned long flags
unsigned long nreloc
bfd_vma offset
bfd_vma reloff
unsigned long reserved1
unsigned long reserved2
char sectname
char segname
bfd_vma size
struct bfd_mach_o_segment_command

Definition at line 206 of file mach-o.h.

Collaboration diagram for bfd_mach_o_segment_command:
Class Members
bfd_vma fileoff
unsigned long filesize
unsigned long flags
unsigned long nsects
bfd_mach_o_section * sections
asection * segment
char segname
bfd_vma vmaddr
bfd_vma vmsize
struct bfd_mach_o_symtab_command

Definition at line 220 of file mach-o.h.

Collaboration diagram for bfd_mach_o_symtab_command:
Class Members
unsigned long nsyms
asection * stabs_segment
asection * stabstr_segment
unsigned long stroff
unsigned long strsize
char * strtab
asymbol * symbols
unsigned long symoff
struct bfd_mach_o_dysymtab_command

Definition at line 270 of file mach-o.h.

Class Members
unsigned long extrefsymoff
unsigned long extreloff
unsigned long iextdefsym
unsigned long ilocalsym
unsigned long indirectsymoff
unsigned long iundefsym
unsigned long locreloff
unsigned long modtaboff
unsigned long nextdefsym
unsigned long nextrefsyms
unsigned long nextrel
unsigned long nindirectsyms
unsigned long nlocalsym
unsigned long nlocrel
unsigned long nmodtab
unsigned long ntoc
unsigned long nundefsym
unsigned long tocoff
struct bfd_mach_o_thread_flavour

Definition at line 382 of file mach-o.h.

Class Members
unsigned long flavour
bfd_vma offset
unsigned long size
struct bfd_mach_o_thread_command

Definition at line 390 of file mach-o.h.

Collaboration diagram for bfd_mach_o_thread_command:
Class Members
bfd_mach_o_thread_flavour * flavours
unsigned long nflavours
asection * section
struct bfd_mach_o_dylinker_command

Definition at line 398 of file mach-o.h.

Collaboration diagram for bfd_mach_o_dylinker_command:
Class Members
unsigned long cmd
unsigned long cmdsize
unsigned long name_len
unsigned long name_offset
asection * section
struct bfd_mach_o_dylib_command

Definition at line 408 of file mach-o.h.

Collaboration diagram for bfd_mach_o_dylib_command:
Class Members
unsigned long cmd
unsigned long cmdsize
unsigned long compatibility_version
unsigned long current_version
unsigned long name_len
unsigned long name_offset
asection * section
unsigned long timestamp
struct bfd_mach_o_prebound_dylib_command

Definition at line 421 of file mach-o.h.

Collaboration diagram for bfd_mach_o_prebound_dylib_command:
Class Members
unsigned long cmd
unsigned long cmdsize
unsigned long linked_modules
unsigned long name
unsigned long nmodules
asection * section
struct bfd_mach_o_load_command

Definition at line 432 of file mach-o.h.

Class Members
union bfd_mach_o_load_command command
bfd_vma len
bfd_vma offset
bfd_mach_o_load_command_type type
unsigned int type_required
struct mach_o_data_struct

Definition at line 452 of file mach-o.h.

Collaboration diagram for mach_o_data_struct:
Class Members
bfd_mach_o_load_command * commands
bfd_mach_o_header header
bfd * ibfd
unsigned long nsects
unsigned long nsymbols
bfd_mach_o_section ** sections
asymbol * symbols
union bfd_mach_o_load_command.command

Define Documentation

#define BFD_MACH_O_LC_REQ_DYLD   0x80000000

Definition at line 62 of file mach-o.h.

#define BFD_MACH_O_N_ABS   0x02 /* Absolute, n_sect == NO_SECT. */

Definition at line 31 of file mach-o.h.

#define BFD_MACH_O_N_EXT   0x01 /* External symbol bit, set for external symbols. */

Definition at line 29 of file mach-o.h.

#define BFD_MACH_O_N_INDR   0x0a /* Indirect. */

Definition at line 34 of file mach-o.h.

#define BFD_MACH_O_N_PBUD   0x0c /* Prebound undefined (defined in a dylib). */

Definition at line 33 of file mach-o.h.

#define BFD_MACH_O_N_PEXT   0x10 /* Private external symbol bit. */

Definition at line 27 of file mach-o.h.

#define BFD_MACH_O_N_SECT   0x0e /* Defined in section number n_sect. */

Definition at line 32 of file mach-o.h.

#define BFD_MACH_O_N_STAB   0xe0 /* If any of these bits set, a symbolic debugging entry. */

Definition at line 26 of file mach-o.h.

#define BFD_MACH_O_N_TYPE   0x0e /* Mask for the type bits. */

Definition at line 28 of file mach-o.h.

#define BFD_MACH_O_N_UNDF   0x00 /* Undefined, n_sect == NO_SECT. */

Definition at line 30 of file mach-o.h.

#define INDIRECT_SYMBOL_ABS   0x40000000

Definition at line 380 of file mach-o.h.

#define INDIRECT_SYMBOL_LOCAL   0x80000000

Definition at line 379 of file mach-o.h.


Typedef Documentation

Definition at line 174 of file mach-o.h.

Definition at line 464 of file mach-o.h.


Enumeration Type Documentation

Enumerator:
BFD_MACH_O_CPU_TYPE_VAX 
BFD_MACH_O_CPU_TYPE_MC680x0 
BFD_MACH_O_CPU_TYPE_I386 
BFD_MACH_O_CPU_TYPE_MIPS 
BFD_MACH_O_CPU_TYPE_MC98000 
BFD_MACH_O_CPU_TYPE_HPPA 
BFD_MACH_O_CPU_TYPE_ARM 
BFD_MACH_O_CPU_TYPE_MC88000 
BFD_MACH_O_CPU_TYPE_SPARC 
BFD_MACH_O_CPU_TYPE_I860 
BFD_MACH_O_CPU_TYPE_ALPHA 
BFD_MACH_O_CPU_TYPE_POWERPC 

Definition at line 95 of file mach-o.h.

Enumerator:
BFD_MACH_O_MH_OBJECT 
BFD_MACH_O_MH_EXECUTE 
BFD_MACH_O_MH_FVMLIB 
BFD_MACH_O_MH_CORE 
BFD_MACH_O_MH_PRELOAD 
BFD_MACH_O_MH_DYLIB 
BFD_MACH_O_MH_DYLINKER 
BFD_MACH_O_MH_BUNDLE 

Definition at line 112 of file mach-o.h.

Enumerator:
BFD_MACH_O_i386_NEW_THREAD_STATE 
BFD_MACH_O_i386_FLOAT_STATE 
BFD_MACH_O_i386_ISA_PORT_MAP_STATE 
BFD_MACH_O_i386_V86_ASSIST_STATE 
BFD_MACH_O_i386_REGS_SEGS_STATE 
BFD_MACH_O_i386_THREAD_SYSCALL_STATE 
BFD_MACH_O_i386_THREAD_STATE_NONE 
BFD_MACH_O_i386_SAVED_STATE 
BFD_MACH_O_i386_THREAD_STATE 
BFD_MACH_O_i386_THREAD_FPSTATE 
BFD_MACH_O_i386_THREAD_EXCEPTSTATE 
BFD_MACH_O_i386_THREAD_CTHREADSTATE 

Definition at line 45 of file mach-o.h.

Enumerator:
BFD_MACH_O_LC_SEGMENT 
BFD_MACH_O_LC_SYMTAB 
BFD_MACH_O_LC_SYMSEG 
BFD_MACH_O_LC_THREAD 
BFD_MACH_O_LC_UNIXTHREAD 
BFD_MACH_O_LC_LOADFVMLIB 
BFD_MACH_O_LC_IDFVMLIB 
BFD_MACH_O_LC_IDENT 
BFD_MACH_O_LC_FVMFILE 
BFD_MACH_O_LC_PREPAGE 
BFD_MACH_O_LC_DYSYMTAB 
BFD_MACH_O_LC_LOAD_DYLIB 
BFD_MACH_O_LC_ID_DYLIB 
BFD_MACH_O_LC_LOAD_DYLINKER 
BFD_MACH_O_LC_ID_DYLINKER 
BFD_MACH_O_LC_PREBOUND_DYLIB 
BFD_MACH_O_LC_ROUTINES 
BFD_MACH_O_LC_SUB_FRAMEWORK 
BFD_MACH_O_LC_SUB_UMBRELLA 
BFD_MACH_O_LC_SUB_CLIENT 
BFD_MACH_O_LC_SUB_LIBRARY 
BFD_MACH_O_LC_TWOLEVEL_HINTS 
BFD_MACH_O_LC_PREBIND_CKSUM 
BFD_MACH_O_LC_LOAD_WEAK_DYLIB 

Definition at line 64 of file mach-o.h.

{
  BFD_MACH_O_LC_SEGMENT = 0x1,            /* File segment to be mapped.  */
  BFD_MACH_O_LC_SYMTAB = 0x2,             /* Link-edit stab symbol table info (obsolete).  */
  BFD_MACH_O_LC_SYMSEG = 0x3,             /* Link-edit gdb symbol table info.  */
  BFD_MACH_O_LC_THREAD = 0x4,             /* Thread.  */
  BFD_MACH_O_LC_UNIXTHREAD = 0x5,  /* UNIX thread (includes a stack).  */
  BFD_MACH_O_LC_LOADFVMLIB = 0x6,  /* Load a fixed VM shared library.  */
  BFD_MACH_O_LC_IDFVMLIB = 0x7,           /* Fixed VM shared library id.  */
  BFD_MACH_O_LC_IDENT = 0x8,              /* Object identification information (obsolete).  */
  BFD_MACH_O_LC_FVMFILE = 0x9,            /* Fixed VM file inclusion.  */
  BFD_MACH_O_LC_PREPAGE = 0xa,            /* Prepage command (internal use).  */
  BFD_MACH_O_LC_DYSYMTAB = 0xb,           /* Dynamic link-edit symbol table info.  */
  BFD_MACH_O_LC_LOAD_DYLIB = 0xc,  /* Load a dynamically linked shared library.  */
  BFD_MACH_O_LC_ID_DYLIB = 0xd,           /* Dynamically linked shared lib identification.  */
  BFD_MACH_O_LC_LOAD_DYLINKER = 0xe,      /* Load a dynamic linker.  */
  BFD_MACH_O_LC_ID_DYLINKER = 0xf, /* Dynamic linker identification.  */
  BFD_MACH_O_LC_PREBOUND_DYLIB = 0x10,    /* Modules prebound for a dynamically.  */
  BFD_MACH_O_LC_ROUTINES = 0x11,   /* Image routines.  */
  BFD_MACH_O_LC_SUB_FRAMEWORK = 0x12,     /* Sub framework.  */
  BFD_MACH_O_LC_SUB_UMBRELLA = 0x13,      /* Sub umbrella.  */
  BFD_MACH_O_LC_SUB_CLIENT = 0x14, /* Sub client.  */
  BFD_MACH_O_LC_SUB_LIBRARY = 0x15,       /* Sub library.  */
  BFD_MACH_O_LC_TWOLEVEL_HINTS = 0x16,    /* Two-level namespace lookup hints.  */
  BFD_MACH_O_LC_PREBIND_CKSUM = 0x17,     /* Prebind checksum.  */
  /* Load a dynamically linked shared library that is allowed to be
       missing (weak).  */
  BFD_MACH_O_LC_LOAD_WEAK_DYLIB = 0x18
}
Enumerator:
BFD_MACH_O_PPC_THREAD_STATE 
BFD_MACH_O_PPC_FLOAT_STATE 
BFD_MACH_O_PPC_EXCEPTION_STATE 
BFD_MACH_O_PPC_VECTOR_STATE 

Definition at line 36 of file mach-o.h.

Enumerator:
BFD_MACH_O_S_REGULAR 
BFD_MACH_O_S_ZEROFILL 
BFD_MACH_O_S_CSTRING_LITERALS 
BFD_MACH_O_S_4BYTE_LITERALS 
BFD_MACH_O_S_8BYTE_LITERALS 
BFD_MACH_O_S_LITERAL_POINTERS 
BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS 
BFD_MACH_O_S_LAZY_SYMBOL_POINTERS 
BFD_MACH_O_S_SYMBOL_STUBS 
BFD_MACH_O_S_MOD_INIT_FUNC_POINTERS 

Definition at line 127 of file mach-o.h.

{
  /* Regular section.  */
  BFD_MACH_O_S_REGULAR = 0x0,

  /* Zero fill on demand section.  */
  BFD_MACH_O_S_ZEROFILL = 0x1,

  /* Section with only literal C strings.  */
  BFD_MACH_O_S_CSTRING_LITERALS = 0x2,

  /* Section with only 4 byte literals.  */
  BFD_MACH_O_S_4BYTE_LITERALS = 0x3,

  /* Section with only 8 byte literals.  */
  BFD_MACH_O_S_8BYTE_LITERALS = 0x4,

  /* Section with only pointers to literals.  */
  BFD_MACH_O_S_LITERAL_POINTERS = 0x5,

  /* For the two types of symbol pointers sections and the symbol stubs
     section they have indirect symbol table entries.  For each of the
     entries in the section the indirect symbol table entries, in
     corresponding order in the indirect symbol table, start at the index
     stored in the reserved1 field of the section structure.  Since the
     indirect symbol table entries correspond to the entries in the
     section the number of indirect symbol table entries is inferred from
     the size of the section divided by the size of the entries in the
     section.  For symbol pointers sections the size of the entries in
     the section is 4 bytes and for symbol stubs sections the byte size
     of the stubs is stored in the reserved2 field of the section
     structure.  */

  /* Section with only non-lazy symbol pointers.  */
  BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS = 0x6,

  /* Section with only lazy symbol pointers.  */
  BFD_MACH_O_S_LAZY_SYMBOL_POINTERS = 0x7,

  /* Section with only symbol stubs, byte size of stub in the reserved2 field.  */
  BFD_MACH_O_S_SYMBOL_STUBS = 0x8,

  /* Section with only function pointers for initialization.  */
  BFD_MACH_O_S_MOD_INIT_FUNC_POINTERS = 0x9
}

Function Documentation

Definition at line 1679 of file mach-o.c.

{
  mach_o_fat_data_struct *adata = NULL;
  unsigned char buf[20];
  unsigned long i;

  bfd_seek (abfd, 0, SEEK_SET);
  if (bfd_bread ((PTR) buf, 8, abfd) != 8)
    goto error;

  adata = bfd_alloc (abfd, sizeof (mach_o_fat_data_struct));
  if (adata == NULL)
    goto error;

  adata->magic = bfd_getb32 (buf);
  adata->nfat_arch = bfd_getb32 (buf + 4);
  if (adata->magic != 0xcafebabe)
    goto error;

  adata->archentries = 
    bfd_alloc (abfd, adata->nfat_arch * sizeof (mach_o_fat_archentry));
  if (adata->archentries == NULL)
    goto error;

  for (i = 0; i < adata->nfat_arch; i++)
    {
      bfd_seek (abfd, 8 + 20 * i, SEEK_SET);

      if (bfd_bread ((PTR) buf, 20, abfd) != 20)
       goto error;
      adata->archentries[i].cputype = bfd_getb32 (buf);
      adata->archentries[i].cpusubtype = bfd_getb32 (buf + 4);
      adata->archentries[i].offset = bfd_getb32 (buf + 8);
      adata->archentries[i].size = bfd_getb32 (buf + 12);
      adata->archentries[i].align = bfd_getb32 (buf + 16);
      adata->archentries[i].abfd = NULL;
    }

  abfd->tdata.mach_o_fat_data = adata;
  return abfd->xvec;

 error:
  if (adata != NULL)
    bfd_release (abfd, adata);
  bfd_set_error (bfd_error_wrong_format);
  return NULL;
}

Here is the call graph for this function:

Definition at line 1891 of file mach-o.c.

{
  bfd_mach_o_data_struct *mdata = abfd->tdata.mach_o_data;
  unsigned long stackaddr = bfd_mach_o_stack_addr (mdata->header.cputype);
  unsigned int i = 0;

  for (i = 0; i < mdata->header.ncmds; i++)
    {
      bfd_mach_o_load_command *cur = &mdata->commands[i];
      bfd_mach_o_segment_command *seg = NULL;

      if (cur->type != BFD_MACH_O_LC_SEGMENT)
       continue;

      seg = &cur->command.segment;

      if ((seg->vmaddr + seg->vmsize) == stackaddr)
       {
         unsigned long start = seg->fileoff;
         unsigned long end = seg->fileoff + seg->filesize;
         unsigned char *buf = bfd_malloc (1024);
         unsigned long size = 1024;

         for (;;)
           {
             bfd_size_type nread = 0;
             unsigned long offset;
             int found_nonnull = 0;

             if (size > (end - start))
              size = (end - start);

             buf = bfd_realloc (buf, size);

             bfd_seek (abfd, end - size, SEEK_SET);
             nread = bfd_bread (buf, size, abfd);

             if (nread != size)
              return -1;

             for (offset = 4; offset <= size; offset += 4)
              {
                unsigned long val;

                val = *((unsigned long *) (buf + size - offset));
                if (! found_nonnull)
                  {
                    if (val != 0)
                     found_nonnull = 1;
                  }
                else if (val == 0x0)
                  {
                    unsigned long bottom;
                    unsigned long top;

                    bottom = seg->fileoff + seg->filesize - offset;
                    top = seg->fileoff + seg->filesize - 4;
                    *rbuf = bfd_malloc (top - bottom);
                    *rlen = top - bottom;

                    memcpy (*rbuf, buf + size - *rlen, *rlen);
                    return 0;
                  }
              }

             if (size == (end - start))
              break;

             size *= 2;
           }
       }
    }

  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1970 of file mach-o.c.

{
  unsigned char *buf = NULL;
  unsigned int len = 0;
  int ret = -1;

  ret = bfd_mach_o_core_fetch_environment (abfd, &buf, &len);
  if (ret < 0)
    return NULL;

  return (char *) buf;
}

Here is the call graph for this function:

Definition at line 1612 of file mach-o.c.

{
  struct bfd_preserve preserve;
  bfd_mach_o_header header;

  preserve.marker = NULL;
  if (bfd_mach_o_read_header (abfd, &header) != 0)
    goto wrong;

  if (! (header.byteorder == BFD_ENDIAN_BIG
        || header.byteorder == BFD_ENDIAN_LITTLE))
    {
      fprintf (stderr, "unknown header byte-order value 0x%lx\n",
              (long) header.byteorder);
      abort ();
    }

  if (! ((header.byteorder == BFD_ENDIAN_BIG
         && abfd->xvec->byteorder == BFD_ENDIAN_BIG
         && abfd->xvec->header_byteorder == BFD_ENDIAN_BIG)
        || (header.byteorder == BFD_ENDIAN_LITTLE
            && abfd->xvec->byteorder == BFD_ENDIAN_LITTLE
            && abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE)))
    goto wrong;

  if (header.filetype != BFD_MACH_O_MH_CORE)
    goto wrong;

  preserve.marker = bfd_zalloc (abfd, sizeof (bfd_mach_o_data_struct));
  if (preserve.marker == NULL
      || !bfd_preserve_save (abfd, &preserve))
    goto fail;

  if (bfd_mach_o_scan (abfd, &header,
                     (bfd_mach_o_data_struct *) preserve.marker) != 0)
    goto wrong;

  bfd_preserve_finish (abfd, &preserve);
  return abfd->xvec;

 wrong:
  bfd_set_error (bfd_error_wrong_format);

 fail:
  if (preserve.marker != NULL)
    bfd_preserve_restore (abfd, &preserve);
  return NULL;
}

Here is the call graph for this function:

Definition at line 1836 of file mach-o.c.

{
  struct mach_o_data_struct *md = NULL;
  bfd_mach_o_load_command *ncmd = NULL;
  unsigned int i, num;

  md = abfd->tdata.mach_o_data;

  BFD_ASSERT (md != NULL);
  BFD_ASSERT (mcommand != NULL);

  num = 0;
  for (i = 0; i < md->header.ncmds; i++)
    {
      struct bfd_mach_o_load_command *cmd = &md->commands[i];

      if (cmd->type != type)
       continue;

      if (num == 0)
       ncmd = cmd;
      num++;
    }

  *mcommand = ncmd;
  return num;
}

Definition at line 1786 of file mach-o.c.

{
  struct mach_o_data_struct *md = abfd->tdata.mach_o_data;
  unsigned int i, j, num;

  bfd_mach_o_load_command *ncmd = NULL;
  bfd_mach_o_section *nsect = NULL;

  BFD_ASSERT (mcommand != NULL);
  BFD_ASSERT (msection != NULL);

  num = 0;
  for (i = 0; i < md->header.ncmds; i++)
    {
      struct bfd_mach_o_load_command *cmd = &md->commands[i];
      struct bfd_mach_o_segment_command *seg = NULL;

      if (cmd->type != BFD_MACH_O_LC_SEGMENT)
       continue;
      seg = &cmd->command.segment;

      if (seg->segment == section)
       {
         if (num == 0)
           ncmd = cmd;
         num++;
       }

      for (j = 0; j < seg->nsects; j++)
       {
         struct bfd_mach_o_section *sect = &seg->sections[j];

         if (sect->bfdsection == section)
           {
             if (num == 0)
              nsect = sect;
             num++;
           }
       }
    }

  *mcommand = ncmd;
  *msection = nsect;
  return num;
}

Definition at line 1537 of file mach-o.c.

{
  bfd_mach_o_data_struct *mdata = NULL;

  mdata = bfd_alloc (abfd, sizeof (bfd_mach_o_data_struct));
  if (mdata == NULL)
    return FALSE;
  abfd->tdata.mach_o_data = mdata;

  mdata->header.magic = 0;
  mdata->header.cputype = 0;
  mdata->header.cpusubtype = 0;
  mdata->header.filetype = 0;
  mdata->header.ncmds = 0;
  mdata->header.sizeofcmds = 0;
  mdata->header.flags = 0;
  mdata->header.byteorder = BFD_ENDIAN_UNKNOWN;
  mdata->commands = NULL;
  mdata->nsymbols = 0;
  mdata->symbols = NULL;
  mdata->nsects = 0;
  mdata->sections = NULL;
  mdata->ibfd = NULL;

  return TRUE;
}

Here is the call graph for this function:

Definition at line 1565 of file mach-o.c.

{
  struct bfd_preserve preserve;
  bfd_mach_o_header header;

  preserve.marker = NULL;
  if (bfd_mach_o_read_header (abfd, &header) != 0)
    goto wrong;

  if (! (header.byteorder == BFD_ENDIAN_BIG
        || header.byteorder == BFD_ENDIAN_LITTLE))
    {
      fprintf (stderr, "unknown header byte-order value 0x%lx\n",
              (long) header.byteorder);
      goto wrong;
    }

  if (! ((header.byteorder == BFD_ENDIAN_BIG
         && abfd->xvec->byteorder == BFD_ENDIAN_BIG
         && abfd->xvec->header_byteorder == BFD_ENDIAN_BIG)
        || (header.byteorder == BFD_ENDIAN_LITTLE
            && abfd->xvec->byteorder == BFD_ENDIAN_LITTLE
            && abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE)))
    goto wrong;

  preserve.marker = bfd_zalloc (abfd, sizeof (bfd_mach_o_data_struct));
  if (preserve.marker == NULL
      || !bfd_preserve_save (abfd, &preserve))
    goto fail;

  if (bfd_mach_o_scan (abfd, &header,
                     (bfd_mach_o_data_struct *) preserve.marker) != 0)
    goto wrong;

  bfd_preserve_finish (abfd, &preserve);
  return abfd->xvec;

 wrong:
  bfd_set_error (bfd_error_wrong_format);

 fail:
  if (preserve.marker != NULL)
    bfd_preserve_restore (abfd, &preserve);
  return NULL;
}

Here is the call graph for this function:

Definition at line 1728 of file mach-o.c.

{
  mach_o_fat_data_struct *adata;
  mach_o_fat_archentry *entry = NULL;
  unsigned long i;

  adata = (mach_o_fat_data_struct *) archive->tdata.mach_o_fat_data;
  BFD_ASSERT (adata != NULL);

  /* Find index of previous entry.  */
  if (prev == NULL)
    i = 0;    /* Start at first one.  */
  else
    {
      for (i = 0; i < adata->nfat_arch; i++)
       {
         if (adata->archentries[i].abfd == prev)
           break;
       }

      if (i == adata->nfat_arch)
       {
         /* Not found.  */
         bfd_set_error (bfd_error_bad_value);
         return NULL;
       }
    i++;      /* Get next entry.  */
  }

  if (i >= adata->nfat_arch)
    {
      bfd_set_error (bfd_error_no_more_archived_files);
      return NULL;
    }

  entry = &adata->archentries[i];
  if (entry->abfd == NULL)
    {
      bfd *nbfd = _bfd_new_bfd_contained_in (archive);
      char *s = NULL;

      if (nbfd == NULL)
       return NULL;

      nbfd->origin = entry->offset;
      s = bfd_malloc (strlen (archive->filename) + 1);
      if (s == NULL)
       return NULL;
      strcpy (s, archive->filename);
      nbfd->filename = s;
      nbfd->iostream = NULL;
      entry->abfd = nbfd;
    }

  return entry->abfd;
}

Here is the call graph for this function:

int bfd_mach_o_scan ( bfd ,
bfd_mach_o_header ,
bfd_mach_o_data_struct *   
)

Definition at line 1480 of file mach-o.c.

{
  unsigned int i;
  enum bfd_architecture cputype;
  unsigned long cpusubtype;

  mdata->header = *header;
  mdata->symbols = NULL;

  abfd->flags = (abfd->xvec->object_flags
               | (abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS)));
  abfd->tdata.mach_o_data = mdata;

  bfd_mach_o_convert_architecture (header->cputype, header->cpusubtype,
                               &cputype, &cpusubtype);
  if (cputype == bfd_arch_unknown)
    {
      fprintf (stderr, "bfd_mach_o_scan: unknown architecture 0x%lx/0x%lx\n",
              header->cputype, header->cpusubtype);
      return -1;
    }

  bfd_set_arch_mach (abfd, cputype, cpusubtype);

  if (header->ncmds != 0)
    {
      mdata->commands = bfd_alloc (abfd, header->ncmds * sizeof (bfd_mach_o_load_command));
      if (mdata->commands == NULL)
       return -1;

      for (i = 0; i < header->ncmds; i++)
       {
         bfd_mach_o_load_command *cur = &mdata->commands[i];

         if (i == 0)
           cur->offset = 28;
         else
           {
             bfd_mach_o_load_command *prev = &mdata->commands[i - 1];
             cur->offset = prev->offset + prev->len;
           }

         if (bfd_mach_o_scan_read_command (abfd, cur) < 0)
           return -1;
       }
    }

  if (bfd_mach_o_scan_start_address (abfd) < 0)
    return -1;

  bfd_mach_o_flatten_sections (abfd);
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 872 of file mach-o.c.

{
  unsigned long isymoff = dysym->indirectsymoff + (i * 4);
  unsigned long symindex;
  unsigned char buf[4];

  BFD_ASSERT (i < dysym->nindirectsyms);

  bfd_seek (abfd, isymoff, SEEK_SET);
  if (bfd_bread ((PTR) buf, 4, abfd) != 4)
    {
      fprintf (stderr, "bfd_mach_o_scan_read_dysymtab_symbol: unable to read %lu bytes at %lu\n",
              (unsigned long) 4, isymoff);
      return -1;
    }
  symindex = bfd_h_get_32 (abfd, buf);

  return bfd_mach_o_scan_read_symtab_symbol (abfd, sym, s, symindex);
}

Here is the call graph for this function:

Definition at line 806 of file mach-o.c.

{
  BFD_ASSERT (sym->strtab == NULL);

  if (abfd->flags & BFD_IN_MEMORY)
    {
      struct bfd_in_memory *b;

      b = (struct bfd_in_memory *) abfd->iostream;

      if ((sym->stroff + sym->strsize) > b->size)
       {
         bfd_set_error (bfd_error_file_truncated);
         return -1;
       }
      sym->strtab = (char *) b->buffer + sym->stroff;
      return 0;
    }

  sym->strtab = bfd_alloc (abfd, sym->strsize);
  if (sym->strtab == NULL)
    return -1;

  bfd_seek (abfd, sym->stroff, SEEK_SET);
  if (bfd_bread ((PTR) sym->strtab, sym->strsize, abfd) != sym->strsize)
    {
      fprintf (stderr, "bfd_mach_o_scan_read_symtab_strtab: unable to read %lu bytes at %lu\n",
              sym->strsize, sym->stroff);
      return -1;
    }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 694 of file mach-o.c.

{
  bfd_mach_o_data_struct *mdata = abfd->tdata.mach_o_data;
  bfd_vma symoff = sym->symoff + (i * 12);
  unsigned char buf[12];
  unsigned char type = -1;
  unsigned char section = -1;
  short desc = -1;
  unsigned long value = -1;
  unsigned long stroff = -1;
  unsigned int symtype = -1;

  BFD_ASSERT (sym->strtab != NULL);

  bfd_seek (abfd, symoff, SEEK_SET);
  if (bfd_bread ((PTR) buf, 12, abfd) != 12)
    {
      fprintf (stderr, "bfd_mach_o_scan_read_symtab_symbol: unable to read %d bytes at %lu\n",
              12, (unsigned long) symoff);
      return -1;
    }

  stroff = bfd_h_get_32 (abfd, buf);
  type = bfd_h_get_8 (abfd, buf + 4);
  symtype = (type & 0x0e);
  section = bfd_h_get_8 (abfd, buf + 5) - 1;
  desc = bfd_h_get_16 (abfd, buf + 6);
  value = bfd_h_get_32 (abfd, buf + 8);

  if (stroff >= sym->strsize)
    {
      fprintf (stderr, "bfd_mach_o_scan_read_symtab_symbol: symbol name out of range (%lu >= %lu)\n",
              (unsigned long) stroff, (unsigned long) sym->strsize);
      return -1;
    }

  s->the_bfd = abfd;
  s->name = sym->strtab + stroff;
  s->value = value;
  s->udata.i = (type << 24) | (section << 16) | desc;
  s->flags = 0x0;

  if (type & BFD_MACH_O_N_STAB)
    {
      s->flags |= BSF_DEBUGGING;
      s->section = bfd_und_section_ptr;
    }
  else
    {
      if (type & BFD_MACH_O_N_PEXT)
       {
         type &= ~BFD_MACH_O_N_PEXT;
         s->flags |= BSF_GLOBAL;
       }

      if (type & BFD_MACH_O_N_EXT)
       {
         type &= ~BFD_MACH_O_N_EXT;
         s->flags |= BSF_GLOBAL;
       }

      switch (symtype)
       {
       case BFD_MACH_O_N_UNDF:
         s->section = bfd_und_section_ptr;
         break;
       case BFD_MACH_O_N_PBUD:
         s->section = bfd_und_section_ptr;
         break;
       case BFD_MACH_O_N_ABS:
         s->section = bfd_abs_section_ptr;
         break;
       case BFD_MACH_O_N_SECT:
         if ((section > 0) && (section <= mdata->nsects))
           {
             s->section = mdata->sections[section - 1]->bfdsection;
             s->value = s->value - mdata->sections[section - 1]->addr;
           }
         else
           {
             /* Mach-O uses 0 to mean "no section"; not an error.  */
             if (section != 0)
              {
                fprintf (stderr, "bfd_mach_o_scan_read_symtab_symbol: "
                        "symbol \"%s\" specified invalid section %d (max %lu): setting to undefined\n",
                        s->name, section, mdata->nsects);
              }
             s->section = bfd_und_section_ptr;
           }
         break;
       case BFD_MACH_O_N_INDR:
         fprintf (stderr, "bfd_mach_o_scan_read_symtab_symbol: "
                 "symbol \"%s\" is unsupported 'indirect' reference: setting to undefined\n",
                 s->name);
         s->section = bfd_und_section_ptr;
         break;
       default:
         fprintf (stderr, "bfd_mach_o_scan_read_symtab_symbol: "
                 "symbol \"%s\" specified invalid type field 0x%x: setting to undefined\n",
                 s->name, symtype);
         s->section = bfd_und_section_ptr;
         break;
       }
    }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 842 of file mach-o.c.

{
  unsigned long i;
  int ret;

  BFD_ASSERT (sym->symbols == NULL);
  sym->symbols = bfd_alloc (abfd, sym->nsyms * sizeof (asymbol));

  if (sym->symbols == NULL)
    {
      fprintf (stderr, "bfd_mach_o_scan_read_symtab_symbols: unable to allocate memory for symbols\n");
      return -1;
    }

  ret = bfd_mach_o_scan_read_symtab_strtab (abfd, sym);
  if (ret != 0)
    return ret;

  for (i = 0; i < sym->nsyms; i++)
    {
      ret = bfd_mach_o_scan_read_symtab_symbol (abfd, sym, &sym->symbols[i], i);
      if (ret != 0)
       return ret;
    }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1426 of file mach-o.c.

{
  bfd_mach_o_data_struct *mdata = abfd->tdata.mach_o_data;
  bfd_mach_o_thread_command *cmd = NULL;
  unsigned long i;

  for (i = 0; i < mdata->header.ncmds; i++)
    {
      if ((mdata->commands[i].type == BFD_MACH_O_LC_THREAD) ||
         (mdata->commands[i].type == BFD_MACH_O_LC_UNIXTHREAD))
       {
         if (cmd == NULL)
           cmd = &mdata->commands[i].command.thread;
         else
           return 0;
       }
    }

  if (cmd == NULL)
    return 0;

  for (i = 0; i < cmd->nflavours; i++)
    {
      if ((mdata->header.cputype == BFD_MACH_O_CPU_TYPE_I386)
         && (cmd->flavours[i].flavour
             == (unsigned long) BFD_MACH_O_i386_THREAD_STATE))
       {
         unsigned char buf[4];

         bfd_seek (abfd, cmd->flavours[i].offset + 40, SEEK_SET);

         if (bfd_bread (buf, 4, abfd) != 4)
           return -1;

         abfd->start_address = bfd_h_get_32 (abfd, buf);
       }
      else if ((mdata->header.cputype == BFD_MACH_O_CPU_TYPE_POWERPC)
              && (cmd->flavours[i].flavour == BFD_MACH_O_PPC_THREAD_STATE))
       {
         unsigned char buf[4];

         bfd_seek (abfd, cmd->flavours[i].offset + 0, SEEK_SET);

         if (bfd_bread (buf, 4, abfd) != 4)
           return -1;

         abfd->start_address = bfd_h_get_32 (abfd, buf);
       }
    }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long bfd_mach_o_stack_addr ( enum  bfd_mach_o_cpu_type)

Definition at line 1867 of file mach-o.c.

{
  switch (type)
    {
    case BFD_MACH_O_CPU_TYPE_MC680x0:
      return 0x04000000;
    case BFD_MACH_O_CPU_TYPE_MC88000:
      return 0xffffe000;
    case BFD_MACH_O_CPU_TYPE_POWERPC:
      return 0xc0000000;
    case BFD_MACH_O_CPU_TYPE_I386:
      return 0xc0000000;
    case BFD_MACH_O_CPU_TYPE_SPARC:
      return 0xf0000000;
    case BFD_MACH_O_CPU_TYPE_I860:
      return 0;
    case BFD_MACH_O_CPU_TYPE_HPPA:
      return 0xc0000000 - 0x04000000;
    default:
      return 0;
    }
}

Here is the caller graph for this function:

Definition at line 105 of file mach-o.c.

{
  if (abfd == NULL || abfd->xvec == NULL)
    return 0;

  if (! ((abfd->xvec == &mach_o_be_vec)
        || (abfd->xvec == &mach_o_le_vec)
        || (abfd->xvec == &mach_o_fat_vec)))
    return 0;

  if (abfd->tdata.mach_o_data == NULL)
    return 0;
  return 1;
}

Here is the caller graph for this function:


Variable Documentation