coff-pe.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:7k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* coff-pe.h - Cygwin32 description of the PEI header and AOUT header in PE COFF */
  2. /*
  3. modification history
  4. --------------------
  5. 01a,03mar98,jmb  written.
  6. */
  7. /*
  8.  *  This file from cygwin32-b18, include/coff/pe.h
  9.  *  Please update if tools are upgraded to a later version of cygwin32.
  10.  */
  11. #ifndef __INCcoffpeh
  12. #define __INCcoffpeh
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /* PE COFF header information */
  17. #ifndef _PE_H
  18. #define _PE_H
  19. /* NT specific file attributes */
  20. #define IMAGE_FILE_RELOCS_STRIPPED           0x0001
  21. #define IMAGE_FILE_EXECUTABLE_IMAGE          0x0002
  22. #define IMAGE_FILE_LINE_NUMS_STRIPPED        0x0004
  23. #define IMAGE_FILE_LOCAL_SYMS_STRIPPED       0x0008
  24. #define IMAGE_FILE_BYTES_REVERSED_LO         0x0080
  25. #define IMAGE_FILE_32BIT_MACHINE             0x0100
  26. #define IMAGE_FILE_DEBUG_STRIPPED            0x0200
  27. #define IMAGE_FILE_SYSTEM                    0x1000
  28. #define IMAGE_FILE_DLL                       0x2000
  29. #define IMAGE_FILE_BYTES_REVERSED_HI         0x8000
  30. /* additional flags to be set for section headers to allow the NT loader to
  31.    read and write to the section data (to replace the addresses of data in
  32.    dlls for one thing); also to execute the section in .text's case */
  33. #define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
  34. #define IMAGE_SCN_MEM_EXECUTE     0x20000000
  35. #define IMAGE_SCN_MEM_READ        0x40000000
  36. #define IMAGE_SCN_MEM_WRITE       0x80000000
  37. /*
  38.  * Section characteristics added for ppc-nt
  39.  */
  40. #define IMAGE_SCN_TYPE_NO_PAD                0x00000008  /* Reserved. */
  41. #define IMAGE_SCN_CNT_CODE                   0x00000020  /* Section contains code. */
  42. #define IMAGE_SCN_CNT_INITIALIZED_DATA       0x00000040  /* Section contains initialized data. */
  43. #define IMAGE_SCN_CNT_UNINITIALIZED_DATA     0x00000080  /* Section contains uninitialized data. */
  44. #define IMAGE_SCN_LNK_OTHER                  0x00000100  /* Reserved. */
  45. #define IMAGE_SCN_LNK_INFO                   0x00000200  /* Section contains comments or some other type of information. */
  46. #define IMAGE_SCN_LNK_REMOVE                 0x00000800  /* Section contents will not become part of image. */
  47. #define IMAGE_SCN_LNK_COMDAT                 0x00001000  /* Section contents comdat. */
  48. #define IMAGE_SCN_MEM_FARDATA                0x00008000
  49. #define IMAGE_SCN_MEM_PURGEABLE              0x00020000
  50. #define IMAGE_SCN_MEM_16BIT                  0x00020000
  51. #define IMAGE_SCN_MEM_LOCKED                 0x00040000
  52. #define IMAGE_SCN_MEM_PRELOAD                0x00080000
  53. #define IMAGE_SCN_ALIGN_1BYTES               0x00100000
  54. #define IMAGE_SCN_ALIGN_2BYTES               0x00200000
  55. #define IMAGE_SCN_ALIGN_4BYTES               0x00300000
  56. #define IMAGE_SCN_ALIGN_8BYTES               0x00400000
  57. #define IMAGE_SCN_ALIGN_16BYTES              0x00500000  /* Default alignment if no others are specified. */
  58. #define IMAGE_SCN_ALIGN_32BYTES              0x00600000
  59. #define IMAGE_SCN_ALIGN_64BYTES              0x00700000
  60. #define IMAGE_SCN_LNK_NRELOC_OVFL            0x01000000  /* Section contains extended relocations. */
  61. #define IMAGE_SCN_MEM_NOT_CACHED             0x04000000  /* Section is not cachable.               */
  62. #define IMAGE_SCN_MEM_NOT_PAGED              0x08000000  /* Section is not pageable.               */
  63. #define IMAGE_SCN_MEM_SHARED                 0x10000000  /* Section is shareable.                  */
  64. /* COMDAT selection codes.  */
  65. #define IMAGE_COMDAT_SELECT_NODUPLICATES     (1) /* Warn if duplicates.  */
  66. #define IMAGE_COMDAT_SELECT_ANY      (2) /* No warning.  */
  67. #define IMAGE_COMDAT_SELECT_SAME_SIZE      (3) /* Warn if different size.  */
  68. #define IMAGE_COMDAT_SELECT_EXACT_MATCH      (4) /* Warn if different.  */
  69. #define IMAGE_COMDAT_SELECT_ASSOCIATIVE      (5) /* Base on other section.  */
  70. /* Magic values that are true for all dos/nt implementations */
  71. #define DOSMAGIC       0x5a4d  
  72. #define NT_SIGNATURE   0x00004550
  73.   /* NT allows long filenames, we want to accommodate this.  This may break
  74.      some of the bfd functions */
  75. #undef  FILNMLEN
  76. #define FILNMLEN 18 /* # characters in a file name */
  77. #ifdef COFF_IMAGE_WITH_PE
  78. /* The filehdr is only weired in images */
  79. #undef FILHDR
  80. struct external_PE_filehdr
  81. {
  82.   /* DOS header fields */
  83.   char e_magic[2]; /* Magic number, 0x5a4d */
  84.   char e_cblp[2]; /* Bytes on last page of file, 0x90 */
  85.   char e_cp[2]; /* Pages in file, 0x3 */
  86.   char e_crlc[2]; /* Relocations, 0x0 */
  87.   char e_cparhdr[2]; /* Size of header in paragraphs, 0x4 */
  88.   char e_minalloc[2]; /* Minimum extra paragraphs needed, 0x0 */
  89.   char e_maxalloc[2]; /* Maximum extra paragraphs needed, 0xFFFF */
  90.   char e_ss[2]; /* Initial (relative) SS value, 0x0 */
  91.   char e_sp[2]; /* Initial SP value, 0xb8 */
  92.   char e_csum[2]; /* Checksum, 0x0 */
  93.   char e_ip[2]; /* Initial IP value, 0x0 */
  94.   char e_cs[2]; /* Initial (relative) CS value, 0x0 */
  95.   char e_lfarlc[2]; /* File address of relocation table, 0x40 */
  96.   char e_ovno[2]; /* Overlay number, 0x0 */
  97.   char e_res[4][2]; /* Reserved words, all 0x0 */
  98.   char e_oemid[2]; /* OEM identifier (for e_oeminfo), 0x0 */
  99.   char e_oeminfo[2]; /* OEM information; e_oemid specific, 0x0 */
  100.   char e_res2[10][2]; /* Reserved words, all 0x0 */
  101.   char e_lfanew[4]; /* File address of new exe header, 0x80 */
  102.   char dos_message[16][4]; /* other stuff, always follow DOS header */
  103.   char nt_signature[4]; /* required NT signature, 0x4550 */ 
  104.   /* From standard header */  
  105.   char f_magic[2]; /* magic number */
  106.   char f_nscns[2]; /* number of sections */
  107.   char f_timdat[4]; /* time & date stamp */
  108.   char f_symptr[4]; /* file pointer to symtab */
  109.   char f_nsyms[4]; /* number of symtab entries */
  110.   char f_opthdr[2]; /* sizeof(optional hdr) */
  111.   char f_flags[2]; /* flags */
  112. };
  113. #define FILHDR struct external_PE_filehdr
  114. #undef FILHSZ
  115. #define FILHSZ 152
  116. #endif
  117. typedef struct 
  118. {
  119.   AOUTHDR standard;
  120.   /* NT extra fields; see internal.h for descriptions */
  121.   char  ImageBase[4];
  122.   char  SectionAlignment[4];
  123.   char  FileAlignment[4];
  124.   char  MajorOperatingSystemVersion[2];
  125.   char  MinorOperatingSystemVersion[2];
  126.   char  MajorImageVersion[2];
  127.   char  MinorImageVersion[2];
  128.   char  MajorSubsystemVersion[2];
  129.   char  MinorSubsystemVersion[2];
  130.   char  Reserved1[4];
  131.   char  SizeOfImage[4];
  132.   char  SizeOfHeaders[4];
  133.   char  CheckSum[4];
  134.   char  Subsystem[2];
  135.   char  DllCharacteristics[2];
  136.   char  SizeOfStackReserve[4];
  137.   char  SizeOfStackCommit[4];
  138.   char  SizeOfHeapReserve[4];
  139.   char  SizeOfHeapCommit[4];
  140.   char  LoaderFlags[4];
  141.   char  NumberOfRvaAndSizes[4];
  142.   /* IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; */
  143.   char  DataDirectory[16][2][4]; /* 16 entries, 2 elements/entry, 4 chars */
  144. } PEAOUTHDR;
  145. #undef AOUTSZ
  146. #define AOUTSZ (AOUTHDRSZ + 196)
  147. #undef  E_FILNMLEN
  148. #define E_FILNMLEN 18 /* # characters in a file name */
  149. #endif
  150. #ifdef __cplusplus
  151. }
  152. #endif
  153. #endif /* __INCcoffpeh */