home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Source / GNU / cctools / include / stuff / ofile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-25  |  3.5 KB  |  91 lines

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