home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer) / NeXT_Developer-3.3.iso / NextDeveloper / Source / GNU / cctools / include / stuff / ofile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-06  |  3.6 KB  |  98 lines

  1. /* ofile.h */
  2. #import <ar.h>
  3. #import <mach-o/loader.h>
  4. #ifdef OFI
  5. #import <mach-o/dyld.h>
  6. #endif
  7. #import "stuff/bytesex.h"
  8. #import "stuff/bool.h"
  9. #import "stuff/arch.h"
  10.  
  11. enum ofile_type {
  12.     OFILE_UNKNOWN,
  13.     OFILE_FAT,
  14.     OFILE_ARCHIVE,
  15.     OFILE_Mach_O
  16. };
  17.  
  18. /*
  19.  * The structure used by ofile_*() routines for object files.
  20.  */
  21. struct ofile {
  22.     char *file_name;            /* pointer to name malloc'ed by ofile_map */
  23.     char *file_addr;            /* pointer to vm_allocate'ed memory       */
  24.     unsigned long file_size;        /* size of vm_allocate'ed memory          */
  25.     enum ofile_type file_type;        /* type of the file                  */
  26.  
  27.     struct fat_header *fat_header;  /* If a fat file these are filled in and */
  28.     struct fat_arch *fat_archs;     /*  if needed converted to host byte sex */
  29.  
  30.     /* If this is a fat file then these are valid and filled in */
  31.     unsigned long narch;        /* the current architecture */
  32.     enum ofile_type arch_type;        /* the type of file for this arch. */
  33.     struct arch_flag arch_flag;     /* the arch_flag for this arch, the name */
  34.                     /*  field is pointing at space malloc'ed */
  35.                     /*  by ofile_map. */
  36.  
  37.     /* If this structure is currently referencing an archive member or an object
  38.        file that is an archive member these are valid and filled in. */
  39.     unsigned long member_offset;    /* logical offset to the member starting */
  40.     char *member_addr;              /* pointer to the member contents */
  41.     unsigned long member_size;      /* actual size of the member (not rounded)*/
  42.     struct ar_hdr *member_ar_hdr;   /* pointer to the ar_hdr for this member */
  43.     enum ofile_type member_type;    /* the type of file for this member */
  44.     cpu_type_t archive_cputype;        /* if the archive contains objects then */
  45.     cpu_subtype_t            /*  these two fields reflect the object */
  46.     archive_cpusubtype;        /*  at are in the archive. */
  47.  
  48.     /* If this structure is currently referencing an object file these are
  49.        valid and filled in.  The mach_header and load commands have been 
  50.        converted to the host byte sex if needed */
  51.     char *object_addr;            /* the address of the object file */
  52.     unsigned long object_size;        /* the size of the object file */
  53.     enum byte_sex object_byte_sex;  /* the byte sex of the object file */
  54.     struct mach_header *mh;        /* the mach_header of the object file */
  55.     struct load_command            /* the start of the load commands */
  56.     *load_commands;
  57. };
  58.  
  59. extern void ofile_process(
  60.     char *name,
  61.     struct arch_flag *arch_flags,
  62.     unsigned long narch_flags,
  63.     enum bool all_archs,
  64.     enum bool process_non_objects,
  65.     void (*processor)(struct ofile *ofile, char *arch_name, void *cookie),
  66.     void *cookie);
  67. #ifdef OFI
  68. extern NSObjectFileImageReturnCode ofile_map(
  69. #else
  70. extern enum bool ofile_map(
  71. #endif
  72.     const char *file_name,
  73.     const struct arch_flag *arch_flag,    /* can be NULL */
  74.     const char *object_name,        /* can be NULL */
  75.     struct ofile *ofile,
  76.     enum bool archives_with_fat_objects);
  77. extern void ofile_unmap(
  78.     struct ofile *ofile);
  79. extern enum bool ofile_first_arch(
  80.     struct ofile *ofile);
  81. extern enum bool ofile_next_arch(
  82.     struct ofile *ofile);
  83. enum bool ofile_first_member(
  84.     struct ofile *ofile);
  85. enum bool ofile_next_member(
  86.     struct ofile *ofile);
  87. extern enum bool ofile_specific_member(
  88.     const char *object_name,
  89.     struct ofile *ofile);
  90. extern void ofile_print(
  91.     struct ofile *ofile);
  92. extern unsigned long size_ar_name(
  93.     const struct ar_hdr *ar_hdr);
  94. extern long ofile_get_word(
  95.     unsigned long addr,
  96.     unsigned long *word,
  97.     void *get_word_data /* struct ofile *ofile */);
  98.