ChangeLog:
[deliverable/binutils-gdb.git] / bfd / mach-o.h
index a5045396aa0863e37b407a544fd035c37721aabe..615a4b3eda5846fa787f865fc6059b0162f3495e 100644 (file)
@@ -1,5 +1,5 @@
 /* Mach-O support for BFD.
-   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007
+   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 #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_N_PBUD  0x0c /* Prebound undefined (defined in a dylib).  */
+#define BFD_MACH_O_N_SECT  0x0e        /* Defined in section number n_sect.  */
+
+#define BFD_MACH_O_NO_SECT 0
+
+#define BFD_MACH_O_SYM_NTYPE(SYM) (((SYM)->udata.i >> 24) & 0xff)
+#define BFD_MACH_O_SYM_NSECT(SYM) (((SYM)->udata.i >> 16) & 0xff)
+#define BFD_MACH_O_SYM_NDESC(SYM) ((SYM)->udata.i & 0xffff)
 
 typedef 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
+  BFD_MACH_O_PPC_VECTOR_STATE = 4,
+  BFD_MACH_O_PPC_THREAD_STATE_64 = 5
 }
 bfd_mach_o_ppc_thread_flavour;
 
+/* Defined in <mach/i386/thread_status.h> */
 typedef 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,
+  BFD_MACH_O_x86_THREAD_STATE32 = 1,
+  BFD_MACH_O_x86_FLOAT_STATE32 = 2,
+  BFD_MACH_O_x86_EXCEPTION_STATE32 = 3,
+  BFD_MACH_O_x86_THREAD_STATE64 = 4,
+  BFD_MACH_O_x86_FLOAT_STATE64 = 5,
+  BFD_MACH_O_x86_EXCEPTION_STATE64 = 6,
+  BFD_MACH_O_x86_THREAD_STATE = 7,
+  BFD_MACH_O_x86_FLOAT_STATE = 8,
+  BFD_MACH_O_x86_EXCEPTION_STATE = 9,
+  BFD_MACH_O_x86_DEBUG_STATE32 = 10,
+  BFD_MACH_O_x86_DEBUG_STATE64 = 11,
+  BFD_MACH_O_x86_DEBUG_STATE = 12,
+  BFD_MACH_O_THREAD_STATE_NONE = 13
 }
 bfd_mach_o_i386_thread_flavour;
 
@@ -89,10 +98,23 @@ typedef enum bfd_mach_o_load_command_type
   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
+  BFD_MACH_O_LC_LOAD_WEAK_DYLIB = 0x18,
+  BFD_MACH_O_LC_SEGMENT_64 = 0x19,     /* 64-bit segment of this file to be 
+                                           mapped.  */
+  BFD_MACH_O_LC_ROUTINES_64 = 0x1a,     /* Address of the dyld init routine 
+                                           in a dylib.  */
+  BFD_MACH_O_LC_UUID = 0x1b,            /* 128-bit UUID of the executable.  */
+  BFD_MACH_O_LC_RPATH = 0x1c,          /* Run path addiions.  */
+  BFD_MACH_O_LC_CODE_SIGNATURE = 0x1d, /* Local of code signature.  */
+  BFD_MACH_O_LC_SEGMENT_SPLIT_INFO = 0x1e, /* Local of info to split seg.  */
+  BFD_MACH_O_LC_REEXPORT_DYLIB = 0x1f,  /* Load and re-export lib.  */
+  BFD_MACH_O_LC_LAZY_LOAD_DYLIB = 0x20, /* Delay load of lib until use.  */
+  BFD_MACH_O_LC_ENCRYPTION_INFO = 0x21  /* Encrypted segment info.  */
 }
 bfd_mach_o_load_command_type;
 
+#define BFD_MACH_O_CPU_IS64BIT 0x1000000
+
 typedef enum bfd_mach_o_cpu_type
 {
   BFD_MACH_O_CPU_TYPE_VAX = 1,
@@ -106,7 +128,9 @@ typedef enum bfd_mach_o_cpu_type
   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
+  BFD_MACH_O_CPU_TYPE_POWERPC = 18,
+  BFD_MACH_O_CPU_TYPE_POWERPC_64 = (BFD_MACH_O_CPU_TYPE_POWERPC | BFD_MACH_O_CPU_IS64BIT),
+  BFD_MACH_O_CPU_TYPE_X86_64 = (BFD_MACH_O_CPU_TYPE_I386 | BFD_MACH_O_CPU_IS64BIT)
 }
 bfd_mach_o_cpu_type;
 
@@ -172,6 +196,35 @@ typedef enum bfd_mach_o_section_type
 }
 bfd_mach_o_section_type;
 
+/* The flags field of a section structure is separated into two parts a section
+   type and section attributes.  The section types are mutually exclusive (it
+   can only have one type) but the section attributes are not (it may have more
+   than one attribute).  */
+
+#define BFD_MACH_O_SECTION_TYPE_MASK        0x000000ff
+
+/* Constants for the section attributes part of the flags field of a section
+   structure.  */
+#define BFD_MACH_O_SECTION_ATTRIBUTES_MASK  0xffffff00
+/* System setable attributes.  */
+#define BFD_MACH_O_SECTION_ATTRIBUTES_SYS   0x00ffff00
+/* User attributes.  */   
+#define BFD_MACH_O_SECTION_ATTRIBUTES_USR   0xff000000
+
+/* Section has local relocation entries.  */
+#define BFD_MACH_O_S_ATTR_LOC_RELOC         0x00000100
+
+/* Section has external relocation entries.  */  
+#define BFD_MACH_O_S_ATTR_EXT_RELOC         0x00000200
+
+/* Section contains some machine instructions.  */
+#define BFD_MACH_O_S_ATTR_SOME_INSTRUCTIONS 0x00004000
+
+#define BFD_MACH_O_S_ATTR_DEBUG             0x02000000
+
+/* Section contains only true machine instructions.  */
+#define BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS 0x80000000
+
 typedef unsigned long bfd_mach_o_cpu_subtype;
 
 typedef struct bfd_mach_o_header
@@ -183,6 +236,9 @@ typedef struct bfd_mach_o_header
   unsigned long ncmds;
   unsigned long sizeofcmds;
   unsigned long flags;
+  unsigned int reserved;
+  /* Version 1: 32 bits, version 2: 64 bits.  */
+  unsigned int version;
   enum bfd_endian byteorder;
 }
 bfd_mach_o_header;
@@ -201,16 +257,19 @@ typedef struct bfd_mach_o_section
   unsigned long flags;
   unsigned long reserved1;
   unsigned long reserved2;
+  unsigned long reserved3;
 }
 bfd_mach_o_section;
 
 typedef struct bfd_mach_o_segment_command
 {
-  char segname[16];
+  char segname[16 + 1];
   bfd_vma vmaddr;
   bfd_vma vmsize;
   bfd_vma fileoff;
   unsigned long filesize;
+  unsigned long maxprot;       /* Maximum permitted protection.  */
+  unsigned long initprot;      /* Initial protection.  */
   unsigned long nsects;
   unsigned long flags;
   bfd_mach_o_section *sections;
@@ -218,6 +277,11 @@ typedef struct bfd_mach_o_segment_command
 }
 bfd_mach_o_segment_command;
 
+/* Protection flags.  */
+#define BFD_MACH_O_PROT_READ    0x01
+#define BFD_MACH_O_PROT_WRITE   0x02
+#define BFD_MACH_O_PROT_EXECUTE 0x04
+
 typedef struct bfd_mach_o_symtab_command
 {
   unsigned long symoff;
@@ -377,8 +441,8 @@ bfd_mach_o_dysymtab_command;
    removed.  In which case it has the value INDIRECT_SYMBOL_LOCAL.  If the
    symbol was also absolute INDIRECT_SYMBOL_ABS is or'ed with that.  */
 
-#define INDIRECT_SYMBOL_LOCAL 0x80000000
-#define INDIRECT_SYMBOL_ABS   0x40000000
+#define BFD_MACH_O_INDIRECT_SYMBOL_LOCAL 0x80000000
+#define BFD_MACH_O_INDIRECT_SYMBOL_ABS   0x40000000
 
 typedef struct bfd_mach_o_thread_flavour
 {
@@ -398,10 +462,10 @@ bfd_mach_o_thread_command;
 
 typedef struct bfd_mach_o_dylinker_command
 {
-  unsigned long cmd;                   /* LC_ID_DYLIB or LC_LOAD_DYLIB.  */
-  unsigned long cmdsize;               /* Includes pathname string.  */
-  unsigned long name_offset;           /* Offset to library's path name.  */
-  unsigned long name_len;              /* Offset to library's path name.  */
+  unsigned long cmd;                 /* LC_ID_DYLINKER or LC_LOAD_DYLINKER.  */
+  unsigned long cmdsize;             /* Includes pathname string.  */
+  unsigned long name_offset;         /* Offset to library's path name.  */
+  unsigned long name_len;            /* Offset to library's path name.  */
   asection *section;
 }
 bfd_mach_o_dylinker_command;
@@ -430,6 +494,15 @@ typedef struct bfd_mach_o_prebound_dylib_command
 }
 bfd_mach_o_prebound_dylib_command;
 
+typedef struct bfd_mach_o_uuid_command
+{
+  unsigned long cmd;                 /* LC_PREBOUND_DYLIB.  */
+  unsigned long cmdsize;             /* Includes uuid.  */
+  unsigned char uuid[16];           /* Uuid.  */
+  asection *section;
+}
+bfd_mach_o_uuid_command;
+
 typedef struct bfd_mach_o_load_command
 {
   bfd_mach_o_load_command_type type;
@@ -445,6 +518,7 @@ typedef struct bfd_mach_o_load_command
     bfd_mach_o_dylib_command dylib;
     bfd_mach_o_dylinker_command dylinker;
     bfd_mach_o_prebound_dylib_command prebound_dylib;
+    bfd_mach_o_uuid_command uuid;
   }
   command;
 }
@@ -462,6 +536,8 @@ typedef struct mach_o_data_struct
 }
 mach_o_data_struct;
 
+#define bfd_get_mach_o_data(abfd) ((abfd)->tdata.mach_o_data)
+
 typedef struct mach_o_data_struct bfd_mach_o_data_struct;
 
 bfd_boolean        bfd_mach_o_valid  (bfd *);
@@ -483,6 +559,7 @@ int                bfd_mach_o_core_fetch_environment         (bfd *, unsigned ch
 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 *);
+bfd *bfd_mach_o_fat_extract (bfd *, bfd_format , const bfd_arch_info_type *);
 
 extern const bfd_target mach_o_be_vec;
 extern const bfd_target mach_o_le_vec;
This page took 0.045563 seconds and 4 git commands to generate.