home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / cctools / include / stuff / bytesex.h < prev    next >
Encoding:
Text File  |  1995-07-21  |  6.7 KB  |  230 lines

  1. /* bytesex.h */
  2. #import <mach-o/fat.h>
  3. #import <mach-o/loader.h>
  4. #import <mach/m68k/thread_status.h>
  5. #import <mach/m98k/thread_status.h>
  6. #import <mach/m88k/thread_status.h>
  7. #import <mach/i860/thread_status.h>
  8. #import <mach/i386/thread_status.h>
  9. #import <mach/hppa/thread_status.h>
  10. #import <mach/sparc/thread_status.h>
  11. #import <mach-o/nlist.h>
  12. #import <mach-o/reloc.h>
  13. #import <bsd/ranlib.h>
  14. #import "stuff/bool.h"
  15.  
  16. enum byte_sex {
  17.     UNKNOWN_BYTE_SEX,
  18.     BIG_ENDIAN_BYTE_SEX,
  19.     LITTLE_ENDIAN_BYTE_SEX
  20. };
  21.  
  22. #define SWAP_SHORT(a) ( ((a & 0xff) << 8) | ((unsigned short)(a) >> 8) )
  23.  
  24. #define SWAP_LONG(a) ( ((a) << 24) | \
  25.               (((a) << 8) & 0x00ff0000) | \
  26.               (((a) >> 8) & 0x0000ff00) | \
  27.     ((unsigned long)(a) >> 24) )
  28.  
  29. __private_extern__ float SWAP_FLOAT(
  30.     float f);
  31.  
  32. __private_extern__ double SWAP_DOUBLE(
  33.     double d);
  34.  
  35. __private_extern__ enum byte_sex get_host_byte_sex(
  36.     void);
  37.  
  38. __private_extern__ void swap_fat_header(
  39.     struct fat_header *fat_header,
  40.     enum byte_sex target_byte_sex);
  41.  
  42. __private_extern__ void swap_fat_arch(
  43.     struct fat_arch *fat_archs,
  44.     unsigned long nfat_arch,
  45.     enum byte_sex target_byte_sex);
  46.  
  47. __private_extern__ void swap_mach_header(
  48.     struct mach_header *mh,
  49.     enum byte_sex target_byte_sex);
  50.  
  51. __private_extern__ void swap_load_command(
  52.     struct load_command *lc,
  53.     enum byte_sex target_byte_sex);
  54.  
  55. __private_extern__ void swap_segment_command(
  56.     struct segment_command *sg,
  57.     enum byte_sex target_byte_sex);
  58.  
  59. __private_extern__ void swap_section(
  60.     struct section *s,
  61.     unsigned long nsects,
  62.     enum byte_sex target_byte_sex);
  63.  
  64. __private_extern__ void swap_symtab_command(
  65.     struct symtab_command *st,
  66.     enum byte_sex target_byte_sex);
  67.  
  68. __private_extern__ void swap_dysymtab_command(
  69.     struct dysymtab_command *dyst,
  70.     enum byte_sex target_byte_sex);
  71.  
  72. __private_extern__ void swap_symseg_command(
  73.     struct symseg_command *ss,
  74.     enum byte_sex target_byte_sex);
  75.  
  76. __private_extern__ void swap_fvmlib_command(
  77.     struct fvmlib_command *fl,
  78.     enum byte_sex target_byte_sex);
  79.  
  80. __private_extern__ void swap_dylib_command(
  81.     struct dylib_command *dl,
  82.     enum byte_sex target_byte_sex);
  83.  
  84. __private_extern__ void swap_prebound_dylib_command(
  85.     struct prebound_dylib_command *pbdylib,
  86.     enum byte_sex target_byte_sex);
  87.  
  88. __private_extern__ void swap_dylinker_command(
  89.     struct dylinker_command *dyld,
  90.     enum byte_sex target_byte_sex);
  91.  
  92. __private_extern__ void swap_fvmfile_command(
  93.     struct fvmfile_command *ff,
  94.     enum byte_sex target_byte_sex);
  95.  
  96. __private_extern__ void swap_thread_command(
  97.     struct thread_command *ut,
  98.     enum byte_sex target_byte_sex);
  99.  
  100. __private_extern__ void swap_m68k_thread_state_regs(
  101.     struct m68k_thread_state_regs *cpu,
  102.     enum byte_sex target_byte_sex);
  103.  
  104. __private_extern__ void swap_m68k_thread_state_68882(
  105.     struct m68k_thread_state_68882 *fpu,
  106.     enum byte_sex target_byte_sex);
  107.  
  108. __private_extern__ void swap_m68k_thread_state_user_reg(
  109.     struct m68k_thread_state_user_reg *user_reg,
  110.     enum byte_sex target_byte_sex);
  111.  
  112. __private_extern__ void swap_m98k_thread_state_grf_t(
  113.     m98k_thread_state_grf_t *cpu,
  114.     enum byte_sex target_byte_sex);
  115.  
  116. __private_extern__ void swap_m88k_thread_state_grf_t(
  117.     m88k_thread_state_grf_t *cpu,
  118.     enum byte_sex target_byte_sex);
  119.  
  120. __private_extern__ void swap_m88k_thread_state_xrf_t(
  121.     m88k_thread_state_xrf_t *fpu,
  122.     enum byte_sex target_byte_sex);
  123.  
  124. __private_extern__ void swap_m88k_thread_state_user_t(
  125.     m88k_thread_state_user_t *user,
  126.     enum byte_sex target_byte_sex);
  127.  
  128. __private_extern__ void swap_m88110_thread_state_impl_t(
  129.     m88110_thread_state_impl_t *spu,
  130.     enum byte_sex target_byte_sex);
  131.  
  132. __private_extern__ void swap_i860_thread_state_regs(
  133.     struct i860_thread_state_regs *cpu,
  134.     enum byte_sex target_byte_sex);
  135.  
  136. __private_extern__ void swap_i386_thread_state(
  137.     i386_thread_state_t *cpu,
  138.     enum byte_sex target_byte_sex);
  139.  
  140. __private_extern__ void swap_i386_thread_fpstate(
  141.     i386_thread_fpstate_t *fpu,
  142.     enum byte_sex target_byte_sex);
  143.  
  144. __private_extern__ void swap_i386_thread_exceptstate(
  145.     i386_thread_exceptstate_t *exc,
  146.     enum byte_sex target_byte_sex);
  147.  
  148. __private_extern__ void swap_i386_thread_cthreadstate(
  149.     i386_thread_cthreadstate_t *user,
  150.     enum byte_sex target_byte_sex);
  151.  
  152. __private_extern__ void swap_hppa_integer_thread_state(
  153.     struct hp_pa_integer_thread_state *regs,
  154.     enum byte_sex target_byte_order);
  155.  
  156. __private_extern__ void swap_hppa_frame_thread_state(
  157.   struct hp_pa_frame_thread_state *frame,
  158.   enum byte_sex target_byte_order);
  159.  
  160. __private_extern__ void swap_hppa_fp_thread_state(
  161.   struct hp_pa_fp_thread_state *fp,
  162.   enum byte_sex target_byte_order);
  163.  
  164. __private_extern__ void swap_sparc_thread_state_regs(
  165.   struct sparc_thread_state_regs *cpu,
  166.   enum byte_sex target_byte_order);
  167.  
  168. __private_extern__ void swap_sparc_thread_state_fpu(
  169.   struct sparc_thread_state_fpu *fpu,
  170.   enum byte_sex target_byte_order);
  171.  
  172. __private_extern__ void swap_ident_command(
  173.     struct ident_command *id_cmd,
  174.     enum byte_sex target_byte_sex);
  175.  
  176. __private_extern__ void swap_nlist(
  177.     struct nlist *symbols,
  178.     unsigned long nsymbols,
  179.     enum byte_sex target_byte_sex);
  180.  
  181. __private_extern__ void swap_ranlib(
  182.     struct ranlib *ranlibs,
  183.     unsigned long nranlibs,
  184.     enum byte_sex target_byte_sex);
  185.  
  186. __private_extern__ void swap_relocation_info(
  187.     struct relocation_info *relocs,
  188.     unsigned long nrelocs,
  189.     enum byte_sex target_byte_sex);
  190.  
  191. __private_extern__ void swap_indirect_symbols(
  192.     unsigned long *indirect_symbols,
  193.     unsigned long nindirect_symbols,
  194.     enum byte_sex target_byte_sex);
  195.  
  196. __private_extern__ void swap_dylib_reference(
  197.     struct dylib_reference *refs,
  198.     unsigned long nrefs,
  199.     enum byte_sex target_byte_sex);
  200.  
  201. __private_extern__ void swap_dylib_module(
  202.     struct dylib_module *mods,
  203.     unsigned long nmods,
  204.     enum byte_sex target_byte_sex);
  205.  
  206. __private_extern__ void swap_dylib_table_of_contents(
  207.     struct dylib_table_of_contents *tocs,
  208.     unsigned long ntocs,
  209.     enum byte_sex target_byte_sex);
  210.  
  211. /*
  212.  * swap_object_headers() swaps the object file headers from the host byte sex
  213.  * into the non-host byte sex.  It returns TRUE if it can and did swap the
  214.  * headers else returns FALSE and does not touch the headers and prints an error
  215.  * using the error() routine.
  216.  */
  217. __private_extern__ enum bool swap_object_headers(
  218.     struct mach_header *mh,
  219.     struct load_command *load_commands);
  220.  
  221. /*
  222.  * get_toc_byte_sex() guesses the byte sex of the table of contents of the
  223.  * library mapped in at the address, addr, of size, size based on the first
  224.  * object file's bytesex.  If it can't figure it out, because the library has
  225.  * no object file members or is malformed it will return UNKNOWN_BYTE_SEX.
  226.  */
  227. __private_extern__ enum byte_sex get_toc_byte_sex(
  228.     char *addr,
  229.     unsigned long size);
  230.