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 / mips.h < prev    next >
C/C++ Source or Header  |  1995-10-04  |  11KB  |  369 lines

  1. /* ECOFF support on MIPS machines.
  2.    coff/ecoff.h must be included before this file.  */
  3.  
  4. /********************** FILE HEADER **********************/
  5.  
  6. struct external_filehdr {
  7.   unsigned char f_magic[2];    /* magic number            */
  8.   unsigned char f_nscns[2];    /* number of sections        */
  9.   unsigned char f_timdat[4];    /* time & date stamp        */
  10.   unsigned char f_symptr[4];    /* file pointer to symtab    */
  11.   unsigned char f_nsyms[4];    /* number of symtab entries    */
  12.   unsigned char f_opthdr[2];    /* sizeof(optional hdr)        */
  13.   unsigned char f_flags[2];    /* flags            */
  14. };
  15.  
  16. /* Magic numbers are defined in coff/ecoff.h.  */
  17. #define MIPS_ECOFF_BADMAG(x) (((x).f_magic!=MIPS_MAGIC_1) && \
  18.                   ((x).f_magic!=MIPS_MAGIC_LITTLE) &&\
  19.                   ((x).f_magic!=MIPS_MAGIC_BIG) && \
  20.                   ((x).f_magic!=MIPS_MAGIC_LITTLE2) && \
  21.                   ((x).f_magic!=MIPS_MAGIC_BIG2) && \
  22.                   ((x).f_magic!=MIPS_MAGIC_LITTLE3) && \
  23.                   ((x).f_magic!=MIPS_MAGIC_BIG3))
  24.  
  25. #define    FILHDR    struct external_filehdr
  26. #define    FILHSZ    20
  27.  
  28. /********************** AOUT "OPTIONAL HEADER" **********************/
  29.  
  30.  
  31. typedef struct external_aouthdr
  32. {
  33.   unsigned char magic[2];    /* type of file                */
  34.   unsigned char    vstamp[2];    /* version stamp            */
  35.   unsigned char    tsize[4];    /* text size in bytes, padded to FW bdry*/
  36.   unsigned char    dsize[4];    /* initialized data "  "        */
  37.   unsigned char    bsize[4];    /* uninitialized data "   "        */
  38.   unsigned char    entry[4];    /* entry pt.                */
  39.   unsigned char text_start[4];    /* base of text used for this file */
  40.   unsigned char data_start[4];    /* base of data used for this file */
  41.   unsigned char bss_start[4];    /* base of bss used for this file */
  42.   unsigned char gprmask[4];    /* ?? */
  43.   unsigned char cprmask[4][4];    /* ?? */
  44.   unsigned char gp_value[4];    /* value for gp register */
  45. } AOUTHDR;
  46.  
  47. /* compute size of a header */
  48.  
  49. #define AOUTSZ (sizeof(AOUTHDR))
  50.  
  51. /********************** SECTION HEADER **********************/
  52.  
  53. struct external_scnhdr {
  54.   unsigned char    s_name[8];    /* section name            */
  55.   unsigned char    s_paddr[4];    /* physical address, aliased s_nlib */
  56.   unsigned char    s_vaddr[4];    /* virtual address        */
  57.   unsigned char    s_size[4];    /* section size            */
  58.   unsigned char    s_scnptr[4];    /* file ptr to raw data for section */
  59.   unsigned char    s_relptr[4];    /* file ptr to relocation    */
  60.   unsigned char    s_lnnoptr[4];    /* file ptr to line numbers    */
  61.   unsigned char    s_nreloc[2];    /* number of relocation entries    */
  62.   unsigned char    s_nlnno[2];    /* number of line number entries*/
  63.   unsigned char    s_flags[4];    /* flags            */
  64. };
  65.  
  66. #define    SCNHDR    struct external_scnhdr
  67. #define    SCNHSZ    sizeof(SCNHDR)
  68.  
  69. /********************** RELOCATION DIRECTIVES **********************/
  70.  
  71. struct external_reloc {
  72.   unsigned char r_vaddr[4];
  73.   unsigned char r_bits[4];
  74. };
  75.  
  76. #define RELOC struct external_reloc
  77. #define RELSZ 8
  78.  
  79. /* MIPS ECOFF uses a packed 8 byte format for relocs.  These constants
  80.    are used to unpack the r_bits field.  */
  81.  
  82. #define RELOC_BITS0_SYMNDX_SH_LEFT_BIG        16
  83. #define RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE    0
  84.  
  85. #define RELOC_BITS1_SYMNDX_SH_LEFT_BIG        8
  86. #define RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE    8
  87.  
  88. #define RELOC_BITS2_SYMNDX_SH_LEFT_BIG        0
  89. #define RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE    16
  90.  
  91. /* Originally, ECOFF used four bits for the reloc type and had three
  92.    reserved bits.  Irix 4 added another bit for the reloc type, which
  93.    was easy because it was big endian and one of the spare bits became
  94.    the new most significant bit.  To make this also work for little
  95.    endian ECOFF, we need to wrap one of the reserved bits around to
  96.    become the most significant bit of the reloc type.  */
  97. #define RELOC_BITS3_TYPE_BIG            0x3E
  98. #define RELOC_BITS3_TYPE_SH_BIG            1
  99. #define RELOC_BITS3_TYPE_LITTLE            0x78
  100. #define RELOC_BITS3_TYPE_SH_LITTLE        3
  101. #define RELOC_BITS3_TYPEHI_LITTLE        0x04
  102. #define RELOC_BITS3_TYPEHI_SH_LITTLE        2
  103.  
  104. #define RELOC_BITS3_EXTERN_BIG            0x01
  105. #define RELOC_BITS3_EXTERN_LITTLE        0x80
  106.  
  107. /* The r_type field in a reloc is one of the following values.  I
  108.    don't know if any other values can appear.  These seem to be all
  109.    that occur in the Ultrix 4.2 libraries.  */
  110. #define MIPS_R_IGNORE    0
  111. #define MIPS_R_REFHALF    1
  112. #define MIPS_R_REFWORD    2
  113. #define MIPS_R_JMPADDR    3
  114. #define MIPS_R_REFHI    4
  115. #define MIPS_R_REFLO    5
  116. #define MIPS_R_GPREL    6
  117. #define MIPS_R_LITERAL    7
  118.  
  119. /* These reloc types are a Cygnus extension used when generating
  120.    position independent code for embedded systems.  The numbers are
  121.    taken from Irix 4, but at least for internal relocs Irix 5 does not
  122.    give them the same meaning.  For an internal reloc the symbol index
  123.    of RELHI and RELLO is modified as described below for
  124.    MIPS_R_SWITCH.  */
  125. #define MIPS_R_PCREL16    12
  126. #define MIPS_R_RELHI    13
  127. #define MIPS_R_RELLO    14
  128.  
  129. /* This reloc type is a Cygnus extension used when generating position
  130.    independent code for embedded systems.  It is used for an entry in
  131.    a switch table, which looks like this:
  132.      .word $L3-$LS12
  133.    The object file will contain the correct difference, and does not
  134.    require adjustment.  However, when the linker is relaxing PC
  135.    relative calls, it is possible for $L3 to move farther away.  This
  136.    reloc always appears in the .text section, and is always against
  137.    the .text section.  However, the symbol index is not
  138.    RELOC_SECTION_TEXT.  It is, instead, the distance between this
  139.    switch table entry and $LS12.  Thus, the original value of $L12 is
  140.      vaddr - symndx
  141.    and the original value of $L3 is
  142.      vaddr - symndx + addend
  143.    where addend is the value in the object file.  Knowing this, the
  144.    linker can know whether the addend in the object file must be
  145.    adjusted.  */
  146. #define MIPS_R_SWITCH    22
  147.  
  148. /********************** STABS **********************/
  149.  
  150. #define MIPS_IS_STAB ECOFF_IS_STAB
  151. #define MIPS_MARK_STAB ECOFF_MARK_STAB
  152. #define MIPS_UNMARK_STAB ECOFF_UNMARK_STAB
  153.  
  154. /********************** SYMBOLIC INFORMATION **********************/
  155.  
  156. /* Written by John Gilmore.  */
  157.  
  158. /* ECOFF uses COFF-like section structures, but its own symbol format.
  159.    This file defines the symbol format in fields whose size and alignment
  160.    will not vary on different host systems.  */
  161.  
  162. /* File header as a set of bytes */
  163.  
  164. struct hdr_ext {
  165.     unsigned char     h_magic[2];
  166.     unsigned char    h_vstamp[2];
  167.     unsigned char    h_ilineMax[4];
  168.     unsigned char    h_cbLine[4];
  169.     unsigned char    h_cbLineOffset[4];
  170.     unsigned char    h_idnMax[4];
  171.     unsigned char    h_cbDnOffset[4];
  172.     unsigned char    h_ipdMax[4];
  173.     unsigned char    h_cbPdOffset[4];
  174.     unsigned char    h_isymMax[4];
  175.     unsigned char    h_cbSymOffset[4];
  176.     unsigned char    h_ioptMax[4];
  177.     unsigned char    h_cbOptOffset[4];
  178.     unsigned char    h_iauxMax[4];
  179.     unsigned char    h_cbAuxOffset[4];
  180.     unsigned char    h_issMax[4];
  181.     unsigned char    h_cbSsOffset[4];
  182.     unsigned char    h_issExtMax[4];
  183.     unsigned char    h_cbSsExtOffset[4];
  184.     unsigned char    h_ifdMax[4];
  185.     unsigned char    h_cbFdOffset[4];
  186.     unsigned char    h_crfd[4];
  187.     unsigned char    h_cbRfdOffset[4];
  188.     unsigned char    h_iextMax[4];
  189.     unsigned char    h_cbExtOffset[4];
  190. };
  191.  
  192. /* File descriptor external record */
  193.  
  194. struct fdr_ext {
  195.     unsigned char    f_adr[4];
  196.     unsigned char    f_rss[4];
  197.     unsigned char    f_issBase[4];
  198.     unsigned char    f_cbSs[4];
  199.     unsigned char    f_isymBase[4];
  200.     unsigned char    f_csym[4];
  201.     unsigned char    f_ilineBase[4];
  202.     unsigned char    f_cline[4];
  203.     unsigned char    f_ioptBase[4];
  204.     unsigned char    f_copt[4];
  205.     unsigned char    f_ipdFirst[2];
  206.     unsigned char    f_cpd[2];
  207.     unsigned char    f_iauxBase[4];
  208.     unsigned char    f_caux[4];
  209.     unsigned char    f_rfdBase[4];
  210.     unsigned char    f_crfd[4];
  211.     unsigned char    f_bits1[1];
  212.     unsigned char    f_bits2[3];
  213.     unsigned char    f_cbLineOffset[4];
  214.     unsigned char    f_cbLine[4];
  215. };
  216.  
  217. #define    FDR_BITS1_LANG_BIG        0xF8
  218. #define    FDR_BITS1_LANG_SH_BIG        3
  219. #define    FDR_BITS1_LANG_LITTLE        0x1F
  220. #define    FDR_BITS1_LANG_SH_LITTLE    0
  221.  
  222. #define    FDR_BITS1_FMERGE_BIG        0x04
  223. #define    FDR_BITS1_FMERGE_LITTLE        0x20
  224.  
  225. #define    FDR_BITS1_FREADIN_BIG        0x02
  226. #define    FDR_BITS1_FREADIN_LITTLE    0x40
  227.  
  228. #define    FDR_BITS1_FBIGENDIAN_BIG    0x01
  229. #define    FDR_BITS1_FBIGENDIAN_LITTLE    0x80
  230.  
  231. #define    FDR_BITS2_GLEVEL_BIG        0xC0
  232. #define    FDR_BITS2_GLEVEL_SH_BIG        6
  233. #define    FDR_BITS2_GLEVEL_LITTLE        0x03
  234. #define    FDR_BITS2_GLEVEL_SH_LITTLE    0
  235.  
  236. /* We ignore the `reserved' field in bits2. */
  237.  
  238. /* Procedure descriptor external record */
  239.  
  240. struct pdr_ext {
  241.     unsigned char    p_adr[4];
  242.     unsigned char    p_isym[4];
  243.     unsigned char    p_iline[4];
  244.     unsigned char    p_regmask[4];
  245.     unsigned char    p_regoffset[4];
  246.     unsigned char    p_iopt[4];
  247.     unsigned char    p_fregmask[4];
  248.     unsigned char    p_fregoffset[4];
  249.     unsigned char    p_frameoffset[4];
  250.     unsigned char    p_framereg[2];
  251.     unsigned char    p_pcreg[2];
  252.     unsigned char    p_lnLow[4];
  253.     unsigned char    p_lnHigh[4];
  254.     unsigned char    p_cbLineOffset[4];
  255. };
  256.  
  257. /* Runtime procedure table */
  258.  
  259. struct rpdr_ext {
  260.     unsigned char    p_adr[4];
  261.     unsigned char    p_regmask[4];
  262.     unsigned char    p_regoffset[4];
  263.     unsigned char    p_fregmask[4];
  264.     unsigned char    p_fregoffset[4];
  265.     unsigned char    p_frameoffset[4];
  266.     unsigned char    p_framereg[2];
  267.     unsigned char    p_pcreg[2];
  268.     unsigned char    p_irpss[4];
  269.     unsigned char    p_reserved[4];
  270.     unsigned char    p_exception_info[4];
  271. };
  272.  
  273. /* Line numbers */
  274.  
  275. struct line_ext {
  276.     unsigned char    l_line[4];
  277. };
  278.  
  279. /* Symbol external record */
  280.  
  281. struct sym_ext {
  282.     unsigned char    s_iss[4];
  283.     unsigned char    s_value[4];
  284.     unsigned char    s_bits1[1];
  285.     unsigned char    s_bits2[1];
  286.     unsigned char    s_bits3[1];
  287.     unsigned char    s_bits4[1];
  288. };
  289.  
  290. #define    SYM_BITS1_ST_BIG        0xFC
  291. #define    SYM_BITS1_ST_SH_BIG        2
  292. #define    SYM_BITS1_ST_LITTLE        0x3F
  293. #define    SYM_BITS1_ST_SH_LITTLE        0
  294.  
  295. #define    SYM_BITS1_SC_BIG        0x03
  296. #define    SYM_BITS1_SC_SH_LEFT_BIG    3
  297. #define    SYM_BITS1_SC_LITTLE        0xC0
  298. #define    SYM_BITS1_SC_SH_LITTLE        6
  299.  
  300. #define    SYM_BITS2_SC_BIG        0xE0
  301. #define    SYM_BITS2_SC_SH_BIG        5
  302. #define    SYM_BITS2_SC_LITTLE        0x07
  303. #define    SYM_BITS2_SC_SH_LEFT_LITTLE    2
  304.  
  305. #define    SYM_BITS2_RESERVED_BIG        0x10
  306. #define    SYM_BITS2_RESERVED_LITTLE    0x08
  307.  
  308. #define    SYM_BITS2_INDEX_BIG        0x0F
  309. #define    SYM_BITS2_INDEX_SH_LEFT_BIG    16
  310. #define    SYM_BITS2_INDEX_LITTLE        0xF0
  311. #define    SYM_BITS2_INDEX_SH_LITTLE    4
  312.  
  313. #define    SYM_BITS3_INDEX_SH_LEFT_BIG    8
  314. #define    SYM_BITS3_INDEX_SH_LEFT_LITTLE    4
  315.  
  316. #define    SYM_BITS4_INDEX_SH_LEFT_BIG    0
  317. #define    SYM_BITS4_INDEX_SH_LEFT_LITTLE    12
  318.  
  319. /* External symbol external record */
  320.  
  321. struct ext_ext {
  322.     unsigned char    es_bits1[1];
  323.     unsigned char    es_bits2[1];
  324.     unsigned char    es_ifd[2];
  325.     struct    sym_ext es_asym;
  326. };
  327.  
  328. #define    EXT_BITS1_JMPTBL_BIG        0x80
  329. #define    EXT_BITS1_JMPTBL_LITTLE        0x01
  330.  
  331. #define    EXT_BITS1_COBOL_MAIN_BIG    0x40
  332. #define    EXT_BITS1_COBOL_MAIN_LITTLE    0x02
  333.  
  334. #define    EXT_BITS1_WEAKEXT_BIG        0x20
  335. #define    EXT_BITS1_WEAKEXT_LITTLE    0x04
  336.  
  337. /* Dense numbers external record */
  338.  
  339. struct dnr_ext {
  340.     unsigned char    d_rfd[4];
  341.     unsigned char    d_index[4];
  342. };
  343.  
  344. /* Relative file descriptor */
  345.  
  346. struct rfd_ext {
  347.   unsigned char    rfd[4];
  348. };
  349.  
  350. /* Optimizer symbol external record */
  351.  
  352. struct opt_ext {
  353.   unsigned char o_bits1[1];
  354.   unsigned char o_bits2[1];
  355.   unsigned char o_bits3[1];
  356.   unsigned char o_bits4[1];
  357.   struct rndx_ext o_rndx;
  358.   unsigned char o_offset[4];
  359. };
  360.  
  361. #define OPT_BITS2_VALUE_SH_LEFT_BIG    16
  362. #define OPT_BITS2_VALUE_SH_LEFT_LITTLE    0
  363.  
  364. #define OPT_BITS3_VALUE_SH_LEFT_BIG    8
  365. #define OPT_BITS3_VALUE_SH_LEFT_LITTLE    8
  366.  
  367. #define OPT_BITS4_VALUE_SH_LEFT_BIG    0
  368. #define OPT_BITS4_VALUE_SH_LEFT_LITTLE    16
  369.