home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gdb-4.16-base.tgz / gdb-4.16-base.tar / fsf / gdb / include / coff / i386.h < prev    next >
C/C++ Source or Header  |  1995-10-04  |  6KB  |  225 lines

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