home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / cctools / include / stuff / ofile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-21  |  4.4 KB  |  114 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 a dynamic library module 
  49.        these are valid and filled in. */
  50.     struct dylib_module *modtab;    /* the module table */
  51.     unsigned long nmodtab;        /* the number of module table entries */
  52.     struct dylib_module            /* pointer to the dylib_module for this */
  53.     *dylib_module;            /*  module. */
  54.     char *dylib_module_name;        /* the name of the module */
  55.  
  56.     /* If this structure is currently referencing an object file these are
  57.        valid and filled in.  The mach_header and load commands have been 
  58.        converted to the host byte sex if needed */
  59.     char *object_addr;            /* the address of the object file */
  60.     unsigned long object_size;        /* the size of the object file */
  61.     enum byte_sex object_byte_sex;  /* the byte sex of the object file */
  62.     struct mach_header *mh;        /* the mach_header of the object file */
  63.     struct load_command            /* the start of the load commands */
  64.     *load_commands;
  65. };
  66.  
  67. __private_extern__ void ofile_process(
  68.     char *name,
  69.     struct arch_flag *arch_flags,
  70.     unsigned long narch_flags,
  71.     enum bool all_archs,
  72.     enum bool process_non_objects,
  73.     enum bool dylib_flat,
  74.     void (*processor)(struct ofile *ofile, char *arch_name, void *cookie),
  75.     void *cookie);
  76. #ifdef OFI
  77. __private_extern__ NSObjectFileImageReturnCode ofile_map(
  78. #else
  79. __private_extern__ enum bool ofile_map(
  80. #endif
  81.     const char *file_name,
  82.     const struct arch_flag *arch_flag,    /* can be NULL */
  83.     const char *object_name,        /* can be NULL */
  84.     struct ofile *ofile,
  85.     enum bool archives_with_fat_objects);
  86. __private_extern__ void ofile_unmap(
  87.     struct ofile *ofile);
  88. __private_extern__ enum bool ofile_first_arch(
  89.     struct ofile *ofile);
  90. __private_extern__ enum bool ofile_next_arch(
  91.     struct ofile *ofile);
  92. __private_extern__ enum bool ofile_first_member(
  93.     struct ofile *ofile);
  94. __private_extern__ enum bool ofile_next_member(
  95.     struct ofile *ofile);
  96. __private_extern__ enum bool ofile_specific_member(
  97.     const char *object_name,
  98.     struct ofile *ofile);
  99. __private_extern__ enum bool ofile_first_module(
  100.     struct ofile *ofile);
  101. __private_extern__ enum bool ofile_next_module(
  102.     struct ofile *ofile);
  103. __private_extern__ enum bool ofile_specific_module(
  104.     const char *module_name,
  105.     struct ofile *ofile);
  106. __private_extern__ void ofile_print(
  107.     struct ofile *ofile);
  108. __private_extern__ unsigned long size_ar_name(
  109.     const struct ar_hdr *ar_hdr);
  110. __private_extern__ long ofile_get_word(
  111.     unsigned long addr,
  112.     unsigned long *word,
  113.     void *get_word_data /* struct ofile *ofile */);
  114.