/[gcl]/gcl/binutils/bfd/mach-o.h
ViewVC logotype

Diff of /gcl/binutils/bfd/mach-o.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2.2.1 by camm, Wed Feb 25 22:31:05 2004 UTC revision 1.2.2.1.14.1 by camm, Fri Sep 30 02:09:02 2005 UTC
# Line 1  Line 1 
1  /* Mach-O support for BFD.  /* Mach-O support for BFD.
2     Copyright 1999, 2000, 2001, 2002     Copyright 1999, 2000, 2001, 2002, 2003
3     Free Software Foundation, Inc.     Free Software Foundation, Inc.
4    
5     This file is part of BFD, the Binary File Descriptor library.     This file is part of BFD, the Binary File Descriptor library.
# Line 74  typedef enum bfd_mach_o_load_command_typ Line 74  typedef enum bfd_mach_o_load_command_typ
74      BFD_MACH_O_LC_FVMFILE = 0x9,        /* Fixed VM file inclusion.  */      BFD_MACH_O_LC_FVMFILE = 0x9,        /* Fixed VM file inclusion.  */
75      BFD_MACH_O_LC_PREPAGE = 0xa,        /* Prepage command (internal use).  */      BFD_MACH_O_LC_PREPAGE = 0xa,        /* Prepage command (internal use).  */
76      BFD_MACH_O_LC_DYSYMTAB = 0xb,       /* Dynamic link-edit symbol table info.  */      BFD_MACH_O_LC_DYSYMTAB = 0xb,       /* Dynamic link-edit symbol table info.  */
77      BFD_MACH_O_LC_LOAD_DYLIB = 0xc,     /* Load a dynamicly linked shared library.  */      BFD_MACH_O_LC_LOAD_DYLIB = 0xc,     /* Load a dynamically linked shared library.  */
78      BFD_MACH_O_LC_ID_DYLIB = 0xd,       /* Dynamicly linked shared lib identification.  */      BFD_MACH_O_LC_ID_DYLIB = 0xd,       /* Dynamically linked shared lib identification.  */
79      BFD_MACH_O_LC_LOAD_DYLINKER = 0xe,  /* Load a dynamic linker.  */      BFD_MACH_O_LC_LOAD_DYLINKER = 0xe,  /* Load a dynamic linker.  */
80      BFD_MACH_O_LC_ID_DYLINKER = 0xf,    /* Dynamic linker identification.  */      BFD_MACH_O_LC_ID_DYLINKER = 0xf,    /* Dynamic linker identification.  */
81      BFD_MACH_O_LC_PREBOUND_DYLIB = 0x10,/* Modules prebound for a dynamicly.  */      BFD_MACH_O_LC_PREBOUND_DYLIB = 0x10,/* Modules prebound for a dynamically.  */
82      BFD_MACH_O_LC_ROUTINES = 0x11,      /* Image routines.  */      BFD_MACH_O_LC_ROUTINES = 0x11,      /* Image routines.  */
83      BFD_MACH_O_LC_SUB_FRAMEWORK = 0x12, /* Sub framework.  */      BFD_MACH_O_LC_SUB_FRAMEWORK = 0x12, /* Sub framework.  */
84      BFD_MACH_O_LC_SUB_UMBRELLA = 0x13,  /* Sub umbrella.  */      BFD_MACH_O_LC_SUB_UMBRELLA = 0x13,  /* Sub umbrella.  */
# Line 86  typedef enum bfd_mach_o_load_command_typ Line 86  typedef enum bfd_mach_o_load_command_typ
86      BFD_MACH_O_LC_SUB_LIBRARY = 0x15,   /* Sub library.  */      BFD_MACH_O_LC_SUB_LIBRARY = 0x15,   /* Sub library.  */
87      BFD_MACH_O_LC_TWOLEVEL_HINTS = 0x16,/* Two-level namespace lookup hints.  */      BFD_MACH_O_LC_TWOLEVEL_HINTS = 0x16,/* Two-level namespace lookup hints.  */
88      BFD_MACH_O_LC_PREBIND_CKSUM = 0x17, /* Prebind checksum.  */      BFD_MACH_O_LC_PREBIND_CKSUM = 0x17, /* Prebind checksum.  */
89      /* Load a dynamicly linked shared library that is allowed to be      /* Load a dynamically linked shared library that is allowed to be
90         missing (weak).  */         missing (weak).  */
91      BFD_MACH_O_LC_LOAD_WEAK_DYLIB = 0x18      BFD_MACH_O_LC_LOAD_WEAK_DYLIB = 0x18
92    }    }
# Line 118  typedef enum bfd_mach_o_filetype Line 118  typedef enum bfd_mach_o_filetype
118      BFD_MACH_O_MH_PRELOAD = 5,      BFD_MACH_O_MH_PRELOAD = 5,
119      BFD_MACH_O_MH_DYLIB = 6,      BFD_MACH_O_MH_DYLIB = 6,
120      BFD_MACH_O_MH_DYLINKER = 7,      BFD_MACH_O_MH_DYLINKER = 7,
121      BFD_MACH_O_MH_BUNDLE = 8,      BFD_MACH_O_MH_BUNDLE = 8
     BFD_MACH_O_MH_DYLIB_STUB = 9  
122    }    }
123  bfd_mach_o_filetype;  bfd_mach_o_filetype;
124    
# Line 160  typedef enum bfd_mach_o_section_type Line 159  typedef enum bfd_mach_o_section_type
159    
160      /* Section with only non-lazy symbol pointers.  */      /* Section with only non-lazy symbol pointers.  */
161      BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS = 0x6,      BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS = 0x6,
162      BFD_MACH_O_S_NL_SYMBOL_POINTERS = 0x6,  
       
163      /* Section with only lazy symbol pointers.  */      /* Section with only lazy symbol pointers.  */
164      BFD_MACH_O_S_LAZY_SYMBOL_POINTERS = 0x7,      BFD_MACH_O_S_LAZY_SYMBOL_POINTERS = 0x7,
165      BFD_MACH_O_S_LA_SYMBOL_POINTERS = 0x7,  
       
166      /* Section with only symbol stubs, byte size of stub in the reserved2 field.  */      /* Section with only symbol stubs, byte size of stub in the reserved2 field.  */
167      BFD_MACH_O_S_SYMBOL_STUBS = 0x8,      BFD_MACH_O_S_SYMBOL_STUBS = 0x8,
168    
# Line 174  typedef enum bfd_mach_o_section_type Line 171  typedef enum bfd_mach_o_section_type
171    }    }
172  bfd_mach_o_section_type;  bfd_mach_o_section_type;
173    
 /* mask */  
 #define BFD_MACH_O_REFERENCE_TYPE 0xf  
   
 typedef enum bfd_mach_o_n_desc  
   {  
   
     /* This symbol is a reference to an external non-lazy symbol (data).  */  
     BFD_MACH_O_REFERENCE_FLAG_UNDEFINED_NON_LAZY = 0x0,  
       
     /* This symbol is a reference to an external lazy symbol pointer (function call).  */  
     BFD_MACH_O_REFERENCE_FLAG_UNDEFINED_LAZY = 0x1,  
   
     /* This symbol is defined in this module.  */  
     BFD_MACH_O_REFERENCE_FLAG_DEFINED = 0x2  
   
   }  
 bfd_mach_o_n_desc;  
   
174  typedef unsigned long bfd_mach_o_cpu_subtype;  typedef unsigned long bfd_mach_o_cpu_subtype;
175    
176  typedef struct bfd_mach_o_header  typedef struct bfd_mach_o_header
# Line 238  typedef struct bfd_mach_o_segment_comman Line 217  typedef struct bfd_mach_o_segment_comman
217  }  }
218  bfd_mach_o_segment_command;  bfd_mach_o_segment_command;
219    
 typedef struct bfd_mach_o_nlist  
 {  
   /* BFD internal representation.  */  
   asymbol root;  
     
   /* Mach-O representation.  */  
   struct {  
     union {  
       char *n_name;  
       long  n_strx;  
     } n_un;  
     unsigned char n_type;  
     unsigned char n_sect;  
     short n_desc;  
     unsigned long n_value;  
   } nlist;  
   
   /* Index in input symbol table.  */  
   unsigned long input_index;  
     
   /* Index in output symbol table.  */  
   unsigned long output_index;  
 }  
 bfd_mach_o_nlist;  
   
220  typedef struct bfd_mach_o_symtab_command  typedef struct bfd_mach_o_symtab_command
221  {  {
222    unsigned long symoff;    unsigned long symoff;
223    unsigned long nsyms;    unsigned long nsyms;
224    unsigned long stroff;    unsigned long stroff;
225    unsigned long strsize;    unsigned long strsize;
226    /*asymbol *symbols;*/    asymbol *symbols;
   bfd_mach_o_nlist *nlists;  
227    char *strtab;    char *strtab;
228    asection *stabs_segment;    asection *stabs_segment;
229    asection *stabstr_segment;    asection *stabstr_segment;
# Line 278  typedef struct bfd_mach_o_symtab_command Line 231  typedef struct bfd_mach_o_symtab_command
231  bfd_mach_o_symtab_command;  bfd_mach_o_symtab_command;
232    
233  /* This is the second set of the symbolic information which is used to support  /* This is the second set of the symbolic information which is used to support
234     the data structures for the dynamicly link editor.     the data structures for the dynamically link editor.
235    
236     The original set of symbolic information in the symtab_command which contains     The original set of symbolic information in the symtab_command which contains
237     the symbol and string tables must also be present when this load command is     the symbol and string tables must also be present when this load command is
# Line 297  bfd_mach_o_symtab_command; Line 250  bfd_mach_o_symtab_command;
250         reference symbol table         reference symbol table
251         indirect symbol table         indirect symbol table
252     The first three tables above (the table of contents, module table and     The first three tables above (the table of contents, module table and
253     reference symbol table) are only present if the file is a dynamicly linked     reference symbol table) are only present if the file is a dynamically linked
254     shared library.  For executable and object modules, which are files     shared library.  For executable and object modules, which are files
255     containing only one module, the information that would be in these three     containing only one module, the information that would be in these three
256     tables is determined as follows:     tables is determined as follows:
# Line 306  bfd_mach_o_symtab_command; Line 259  bfd_mach_o_symtab_command;
259                        file is part of the module.                        file is part of the module.
260         reference symbol table - is the defined and undefined external symbols         reference symbol table - is the defined and undefined external symbols
261    
262     For dynamicly linked shared library files this load command also contains     For dynamically linked shared library files this load command also contains
263     offsets and sizes to the pool of relocation entries for all sections     offsets and sizes to the pool of relocation entries for all sections
264     separated into two groups:     separated into two groups:
265         external relocation entries         external relocation entries
# Line 328  typedef struct bfd_mach_o_dysymtab_comma Line 281  typedef struct bfd_mach_o_dysymtab_comma
281    
282       The last two groups are used by the dynamic binding process to do the       The last two groups are used by the dynamic binding process to do the
283       binding (indirectly through the module table and the reference symbol       binding (indirectly through the module table and the reference symbol
284       table when this is a dynamicly linked shared library file).  */       table when this is a dynamically linked shared library file).  */
285    
286    unsigned long ilocalsym;    /* Index to local symbols.  */    unsigned long ilocalsym;    /* Index to local symbols.  */
287    unsigned long nlocalsym;    /* Number of local symbols.  */    unsigned long nlocalsym;    /* Number of local symbols.  */
# Line 340  typedef struct bfd_mach_o_dysymtab_comma Line 293  typedef struct bfd_mach_o_dysymtab_comma
293    /* For the for the dynamic binding process to find which module a symbol    /* For the for the dynamic binding process to find which module a symbol
294       is defined in the table of contents is used (analogous to the ranlib       is defined in the table of contents is used (analogous to the ranlib
295       structure in an archive) which maps defined external symbols to modules       structure in an archive) which maps defined external symbols to modules
296       they are defined in.  This exists only in a dynamicly linked shared       they are defined in.  This exists only in a dynamically linked shared
297       library file.  For executable and object modules the defined external       library file.  For executable and object modules the defined external
298       symbols are sorted by name and is use as the table of contents.  */       symbols are sorted by name and is use as the table of contents.  */
299    
# Line 351  typedef struct bfd_mach_o_dysymtab_comma Line 304  typedef struct bfd_mach_o_dysymtab_comma
304       table must reflect the modules that the file was created from.  This is       table must reflect the modules that the file was created from.  This is
305       done by having a module table that has indexes and counts into the merged       done by having a module table that has indexes and counts into the merged
306       tables for each module.  The module structure that these two entries       tables for each module.  The module structure that these two entries
307       refer to is described below.  This exists only in a dynamicly linked       refer to is described below.  This exists only in a dynamically linked
308       shared library file.  For executable and object modules the file only       shared library file.  For executable and object modules the file only
309       contains one module so everything in the file belongs to the module.  */       contains one module so everything in the file belongs to the module.  */
310    
# Line 362  typedef struct bfd_mach_o_dysymtab_comma Line 315  typedef struct bfd_mach_o_dysymtab_comma
315       indicates the external references (defined and undefined) each module       indicates the external references (defined and undefined) each module
316       makes.  For each module there is an offset and a count into the       makes.  For each module there is an offset and a count into the
317       reference symbol table for the symbols that the module references.       reference symbol table for the symbols that the module references.
318       This exists only in a dynamicly linked shared library file.  For       This exists only in a dynamically linked shared library file.  For
319       executable and object modules the defined external symbols and the       executable and object modules the defined external symbols and the
320       undefined external symbols indicates the external references.  */       undefined external symbols indicates the external references.  */
321    
# Line 410  typedef struct bfd_mach_o_dysymtab_comma Line 363  typedef struct bfd_mach_o_dysymtab_comma
363    
364    /* All the local relocation entries are grouped together (they are not    /* All the local relocation entries are grouped together (they are not
365       grouped by their module since they are only used if the object is moved       grouped by their module since they are only used if the object is moved
366       from it staticly link edited address).  */       from it statically link edited address).  */
367    
368    unsigned long locreloff;    /* Offset to local relocation entries.  */    unsigned long locreloff;    /* Offset to local relocation entries.  */
369    unsigned long nlocrel;      /* Number of local relocation entries.  */    unsigned long nlocrel;      /* Number of local relocation entries.  */
# Line 496  typedef struct bfd_mach_o_load_command Line 449  typedef struct bfd_mach_o_load_command
449  }  }
450  bfd_mach_o_load_command;  bfd_mach_o_load_command;
451    
 /* Map an indirect symbol table entry to a symbol table entry and vice-versa.  */  
 typedef struct {  
   
   /* Reference to the indirect symbol table entry.  */  
   unsigned long ist_idx;  
   
   /* Reference to the symbol table entry.  */  
   unsigned long st_idx;  
 }  
 bfd_mach_o_ist_entry;  
   
 /* Describe the indirect symbol table.  */  
 typedef struct {  
   
   /* Associated LC_DYSYMTAB load command.  */  
   bfd_mach_o_dysymtab_command *command;  
   
   /* Number of entries in this indirect symbol table.  */  
   unsigned long nmemb;  
   
   /* Number of BFD_MACH_O_S_SYMBOL_STUB sections in the following array.  */  
   unsigned long nstubs;  
     
   /* Array of stub sections.  */  
   bfd_mach_o_section **stubs;  
     
   /* Number of BFD_MACH_O_S_NL_SYMBOL_POINTERS sections in the following array.  */  
   unsigned long nnlptrs;  
   
   /* Array of non-lazy symbol pointer sections.  */  
   bfd_mach_o_section **nlptrs;  
   
   /* Number of BFD_MACH_O_S_LA_SYMBOL_POINTERS sections in the following array.  */  
   unsigned long nlaptrs;  
   
   /* Array of lazy symbol pointer sections.  */  
   bfd_mach_o_section **laptrs;  
   
   /* Raw indirect symbol table entry, as slurped from the input file.  */  
   bfd_mach_o_ist_entry *raw_ist;  
   
   /* Indirect symbol table that was sorted by chunks, depending on st_idx.  */  
   bfd_mach_o_ist_entry *sorted_ist;    
 }  
 bfd_mach_o_ist;  
   
 typedef struct  
 {  
   /* General link information.  */  
   struct bfd_link_info *info;  
   
   /* Output BFD.  */  
   bfd *output_bfd;  
   
   /* Buffer large enough to hold contents of any section.  */  
   bfd_byte *contents;  
 }  
 bfd_mach_o_final_link_info;  
   
 /* This struct is used to pass information to and from bfd_mach_o_link_output_extsym.  */  
 typedef struct  
 {  
   boolean failed;  
   bfd_mach_o_final_link_info *finfo;  
 }  
 bfd_mach_o_outext_info;  
   
 /* Mach-O back-end global hash table entries.  */  
 // typedef struct {  
 //  
 //   struct bfd_link_hash_entry root;  
 //    
 // }  
 // bfd_mach_o_link_hash_entry;  
   
 #define mach_o_tdata(abfd)    ((abfd)->tdata.mach_o_data)  
 #define mach_o_symtab(abfd)   (mach_o_tdata(abfd)->st)  
 #define mach_o_dysymtab(abfd) (mach_o_tdata(abfd)->dyst)  
   
 #define mach_o_n_type(udata)  (((udata) >> 24) & 0xff)  
 #define mach_o_n_sect(udata)  (((udata) >> 16) & 0xff)  
 #define mach_o_n_desc(udata)  ((udata) & 0xffff)  
   
452  typedef struct mach_o_data_struct  typedef struct mach_o_data_struct
453  {  {
454    bfd_mach_o_header header;    bfd_mach_o_header header;
455    bfd_mach_o_load_command *commands;    bfd_mach_o_load_command *commands;
   bfd_mach_o_ist *ist;  
   bfd_mach_o_symtab_command *st;  
   bfd_mach_o_dysymtab_command *dyst;  
456    unsigned long nsymbols;    unsigned long nsymbols;
457    asymbol *symbols;    asymbol *symbols;
458    unsigned long nsects;    unsigned long nsects;
# Line 596  mach_o_data_struct; Line 463  mach_o_data_struct;
463    
464  typedef struct mach_o_data_struct bfd_mach_o_data_struct;  typedef struct mach_o_data_struct bfd_mach_o_data_struct;
465    
466  boolean bfd_mach_o_valid  bfd_boolean bfd_mach_o_valid
467    PARAMS ((bfd *));    PARAMS ((bfd *));
468  int bfd_mach_o_scan_read_symtab_symbol  int bfd_mach_o_scan_read_symtab_symbol
469  /*PARAMS ((bfd *, bfd_mach_o_symtab_command *, asymbol *, unsigned long));*/    PARAMS ((bfd *, bfd_mach_o_symtab_command *, asymbol *, unsigned long));
   PARAMS ((bfd *, bfd_mach_o_symtab_command *,  
            bfd_mach_o_nlist *, unsigned long));  
470  int bfd_mach_o_scan_read_symtab_strtab  int bfd_mach_o_scan_read_symtab_strtab
471    PARAMS ((bfd *, bfd_mach_o_symtab_command *));    PARAMS ((bfd *, bfd_mach_o_symtab_command *));
472  int bfd_mach_o_scan_read_symtab_symbols  int bfd_mach_o_scan_read_symtab_symbols
473    PARAMS ((bfd *, bfd_mach_o_symtab_command *));    PARAMS ((bfd *, bfd_mach_o_symtab_command *));
474  int bfd_mach_o_scan_read_dysymtab_symbol  int bfd_mach_o_scan_read_dysymtab_symbol
475    PARAMS ((bfd *, bfd_mach_o_dysymtab_command *, bfd_mach_o_symtab_command *,    PARAMS ((bfd *, bfd_mach_o_dysymtab_command *, bfd_mach_o_symtab_command *,
476             bfd_mach_o_nlist */*asymbol **/, unsigned long));             asymbol *, unsigned long));
477  int bfd_mach_o_scan_start_address  int bfd_mach_o_scan_start_address
478    PARAMS ((bfd *));    PARAMS ((bfd *));
479  int bfd_mach_o_scan  int bfd_mach_o_scan
480    PARAMS ((bfd *, bfd_mach_o_header *, bfd_mach_o_data_struct *));    PARAMS ((bfd *, bfd_mach_o_header *, bfd_mach_o_data_struct *));
481  boolean bfd_mach_o_mkobject  bfd_boolean bfd_mach_o_mkobject
482    PARAMS ((bfd *));    PARAMS ((bfd *));
483  const bfd_target * bfd_mach_o_object_p  const bfd_target * bfd_mach_o_object_p
484    PARAMS ((bfd *));    PARAMS ((bfd *));
# Line 636  char * bfd_mach_o_core_file_failing_comm Line 501  char * bfd_mach_o_core_file_failing_comm
501    PARAMS ((bfd *));    PARAMS ((bfd *));
502  int bfd_mach_o_core_file_failing_signal  int bfd_mach_o_core_file_failing_signal
503    PARAMS ((bfd *));    PARAMS ((bfd *));
504  boolean bfd_mach_o_core_file_matches_executable_p  bfd_boolean bfd_mach_o_core_file_matches_executable_p
505    PARAMS ((bfd *, bfd *));    PARAMS ((bfd *, bfd *));
506    
507  extern const bfd_target mach_o_be_vec;  extern const bfd_target mach_o_be_vec;
508  extern const bfd_target mach_o_le_vec;  extern const bfd_target mach_o_le_vec;
509  extern const bfd_target mach_o_fat_vec;  extern const bfd_target mach_o_fat_vec;
510    
 struct bfd_preserve  
 {  
   PTR marker;  
   PTR tdata;  
   flagword flags;  
   const struct bfd_arch_info *arch_info;  
   struct sec *sections;  
   struct sec **section_tail;  
   unsigned int section_count;  
   struct bfd_hash_table section_htab;  
 };  
   
 boolean  
 bfd_preserve_save PARAMS ((bfd *, struct bfd_preserve *));  
   
 void  
 bfd_preserve_restore PARAMS ((bfd *, struct bfd_preserve *));  
   
 void  
 bfd_preserve_finish PARAMS ((bfd *, struct bfd_preserve *));  
   
511  #endif /* _BFD_MACH_O_H_ */  #endif /* _BFD_MACH_O_H_ */

Legend:
Removed from v.1.2.2.1  
changed lines
  Added in v.1.2.2.1.14.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26