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

VxWorks

开发平台:

C/C++

  1. /* coff-i386.h - Cygwin32 description of PE COFF objects */
  2. /*
  3. modification history
  4. --------------------
  5. 01a,03mar98,jmb  written.
  6. */
  7. /*
  8.  *  This file from cygwin32-b18, include/coff/i386.h
  9.  *  Please update if tools are upgraded to a later version of cygwin32.
  10.  */
  11. #ifndef __INCcoffi386h
  12. #define __INCcoffi386h
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /*** coff information for Intel 386/486.  */
  17. /********************** FILE HEADER **********************/
  18. struct external_filehdr {
  19. char f_magic[2]; /* magic number */
  20. char f_nscns[2]; /* number of sections */
  21. char f_timdat[4]; /* time & date stamp */
  22. char f_symptr[4]; /* file pointer to symtab */
  23. char f_nsyms[4]; /* number of symtab entries */
  24. char f_opthdr[2]; /* sizeof(optional hdr) */
  25. char f_flags[2]; /* flags */
  26. };
  27. /* Bits for f_flags:
  28.  * F_RELFLG relocation info stripped from file
  29.  * F_EXEC file is executable (no unresolved external references)
  30.  * F_LNNO line numbers stripped from file
  31.  * F_LSYMS local symbols stripped from file
  32.  * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
  33.  */
  34. #define F_RELFLG (0x0001)
  35. #define F_EXEC (0x0002)
  36. #define F_LNNO (0x0004)
  37. #define F_LSYMS (0x0008)
  38. #define I386MAGIC 0x14c
  39. #define I386PTXMAGIC 0x154
  40. #define I386AIXMAGIC 0x175
  41. /* This is Lynx's all-platform magic number for executables. */
  42. #define LYNXCOFFMAGIC 0415
  43. #define I386BADMAG(x) (((x).f_magic != I386MAGIC) 
  44.        && (x).f_magic != I386AIXMAGIC 
  45.        && (x).f_magic != I386PTXMAGIC 
  46.        && (x).f_magic != LYNXCOFFMAGIC)
  47. #define FILHDR struct external_filehdr
  48. #define FILHSZ 20
  49. /********************** AOUT "OPTIONAL HEADER" **********************/
  50. typedef struct 
  51. {
  52.   char  magic[2]; /* type of file */
  53.   char vstamp[2]; /* version stamp */
  54.   char tsize[4]; /* text size in bytes, padded to FW bdry*/
  55.   char dsize[4]; /* initialized data "  " */
  56.   char bsize[4]; /* uninitialized data "   " */
  57.   char entry[4]; /* entry pt. */
  58.   char  text_start[4]; /* base of text used for this file */
  59.   char  data_start[4]; /* base of data used for this file */
  60. }
  61. AOUTHDR;
  62. #define AOUTSZ 28
  63. #define AOUTHDRSZ 28
  64. #define OMAGIC          0404    /* object files, eg as output */
  65. #define ZMAGIC          0413    /* demand load format, eg normal ld output */
  66. #define STMAGIC 0401 /* target shlib */
  67. #define SHMAGIC 0443 /* host   shlib */
  68. /* define some NT default values */
  69. /*  #define NT_IMAGE_BASE        0x400000 moved to internal.h */
  70. #define NT_SECTION_ALIGNMENT 0x1000
  71. #define NT_FILE_ALIGNMENT    0x200
  72. #define NT_DEF_RESERVE       0x100000
  73. #define NT_DEF_COMMIT        0x1000
  74. /********************** SECTION HEADER **********************/
  75. struct external_scnhdr {
  76. char s_name[8]; /* section name */
  77. char s_paddr[4]; /* physical address, aliased s_nlib */
  78. char s_vaddr[4]; /* virtual address */
  79. char s_size[4]; /* section size */
  80. char s_scnptr[4]; /* file ptr to raw data for section */
  81. char s_relptr[4]; /* file ptr to relocation */
  82. char s_lnnoptr[4]; /* file ptr to line numbers */
  83. char s_nreloc[2]; /* number of relocation entries */
  84. char s_nlnno[2]; /* number of line number entries*/
  85. char s_flags[4]; /* flags */
  86. };
  87. #define SCNHDR struct external_scnhdr
  88. #define SCNHSZ 40
  89. /*
  90.  * names of "special" sections
  91.  */
  92. #define _TEXT ".text"
  93. #define _DATA ".data"
  94. #define _BSS ".bss"
  95. #define _COMMENT ".comment"
  96. #define _LIB ".lib"
  97. /********************** LINE NUMBERS **********************/
  98. /* 1 line number entry for every "breakpointable" source line in a section.
  99.  * Line numbers are grouped on a per function basis; first entry in a function
  100.  * grouping will have l_lnno = 0 and in place of physical address will be the
  101.  * symbol table index of the function name.
  102.  */
  103. struct external_lineno {
  104. union {
  105. char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
  106. char l_paddr[4]; /* (physical) address of line number */
  107. } l_addr;
  108. char l_lnno[2]; /* line number */
  109. };
  110. #define LINENO struct external_lineno
  111. #define LINESZ 6
  112. /********************** SYMBOLS **********************/
  113. #define E_SYMNMLEN 8 /* # characters in a symbol name */
  114. #define E_FILNMLEN 14 /* # characters in a file name */
  115. #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
  116. struct external_syment 
  117. {
  118.   union {
  119.     char e_name[E_SYMNMLEN];
  120.     struct {
  121.       char e_zeroes[4];
  122.       char e_offset[4];
  123.     } e;
  124.   } e;
  125.   char e_value[4];
  126.   char e_scnum[2];
  127.   char e_type[2];
  128.   char e_sclass[1];
  129.   char e_numaux[1];
  130. };
  131. #define N_BTMASK (0xf)
  132. #define N_TMASK (0x30)
  133. #define N_BTSHFT (4)
  134. #define N_TSHIFT (2)
  135.   
  136. union external_auxent {
  137. struct {
  138. char x_tagndx[4]; /* str, un, or enum tag indx */
  139. union {
  140. struct {
  141.     char  x_lnno[2]; /* declaration line number */
  142.     char  x_size[2]; /* str/union/array size */
  143. } x_lnsz;
  144. char x_fsize[4]; /* size of function */
  145. } x_misc;
  146. union {
  147. struct { /* if ISFCN, tag, or .bb */
  148.     char x_lnnoptr[4]; /* ptr to fcn line # */
  149.     char x_endndx[4]; /* entry ndx past block end */
  150. } x_fcn;
  151. struct { /* if ISARY, up to 4 dimen. */
  152.     char x_dimen[E_DIMNUM][2];
  153. } x_ary;
  154. } x_fcnary;
  155. char x_tvndx[2]; /* tv index */
  156. } x_sym;
  157. union {
  158. char x_fname[E_FILNMLEN];
  159. struct {
  160. char x_zeroes[4];
  161. char x_offset[4];
  162. } x_n;
  163. } x_file;
  164. struct {
  165. char x_scnlen[4]; /* section length */
  166. char x_nreloc[2]; /* # relocation entries */
  167. char x_nlinno[2]; /* # line numbers */
  168. char x_checksum[4]; /* section COMDAT checksum */
  169. char x_associated[2]; /* COMDAT associated section index */
  170. char x_comdat[1]; /* COMDAT selection number */
  171. } x_scn;
  172.         struct {
  173. char x_tvfill[4]; /* tv fill value */
  174. char x_tvlen[2]; /* length of .tv */
  175. char x_tvran[2][2]; /* tv range */
  176. } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
  177. };
  178. #define SYMENT struct external_syment
  179. #define SYMESZ 18
  180. #define AUXENT union external_auxent
  181. #define AUXESZ 18
  182. # define _ETEXT "etext"
  183. /********************** RELOCATION DIRECTIVES **********************/
  184. struct external_reloc {
  185.   char r_vaddr[4];
  186.   char r_symndx[4];
  187.   char r_type[2];
  188. };
  189. #define RELOC struct external_reloc
  190. #define RELSZ 10
  191. #ifdef __cplusplus
  192. }
  193. #endif
  194. #endif /* __INCcoffi386h */