home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / GDB / GDB-4.13 / GDB-4 / gdb-4.13 / include / coff / ecoff.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-20  |  13.3 KB  |  370 lines

  1. #ifndef ECOFF_H
  2. #define ECOFF_H
  3.  
  4. /* Generic ECOFF support.
  5.    This does not include symbol information, found in sym.h and
  6.    symconst.h.  */
  7.  
  8. /* Mips magic numbers used in filehdr.  MIPS_MAGIC_LITTLE is used on
  9.    little endian machines.  MIPS_MAGIC_BIG is used on big endian
  10.    machines.  Where is MIPS_MAGIC_1 from?  */
  11. #define MIPS_MAGIC_1 0x0180
  12. #define MIPS_MAGIC_LITTLE 0x0162
  13. #define MIPS_MAGIC_BIG 0x0160
  14.  
  15. /* These are the magic numbers used for MIPS code compiled at ISA
  16.    level 2.  */
  17. #define MIPS_MAGIC_LITTLE2 0x0166
  18. #define MIPS_MAGIC_BIG2 0x0163
  19.  
  20. /* These are the magic numbers used for MIPS code compiled at ISA
  21.    level 3.  */
  22. #define MIPS_MAGIC_LITTLE3 0x142
  23. #define MIPS_MAGIC_BIG3 0x140
  24.  
  25. /* Alpha magic numbers used in filehdr.  */
  26. #define ALPHA_MAGIC 0x183
  27.  
  28. /* Magic numbers used in a.out header.  */
  29. #define ECOFF_AOUT_OMAGIC 0407    /* not demand paged (ld -N).  */
  30. #define ECOFF_AOUT_ZMAGIC 0413    /* demand load format, eg normal ld output */
  31.  
  32. /* Names of special sections.  */
  33. #define _TEXT   ".text"
  34. #define _DATA   ".data"
  35. #define _BSS    ".bss"
  36. #define _RDATA    ".rdata"
  37. #define _SDATA    ".sdata"
  38. #define _SBSS    ".sbss"
  39. #define _LITA    ".lita"
  40. #define _LIT4    ".lit4"
  41. #define _LIT8    ".lit8"
  42. #define _LIB    ".lib"
  43. #define _INIT    ".init"
  44. #define _FINI    ".fini"
  45. #define _PDATA    ".pdata"
  46. #define _XDATA    ".xdata"
  47.  
  48. /* ECOFF uses some additional section flags.  */
  49. #define STYP_RDATA         0x100
  50. #define STYP_SDATA         0x200
  51. #define STYP_SBSS         0x400
  52. #define STYP_ECOFF_FINI     0x1000000
  53. #define STYP_EXTENDESC     0x2000000 /* 0x02FFF000 bits => scn type, rest clr */
  54. #define STYP_LITA     0x4000000
  55. #define STYP_LIT8     0x8000000
  56. #define STYP_LIT4    0x10000000
  57. #define STYP_ECOFF_LIB    0x40000000
  58. #define STYP_ECOFF_INIT 0x80000000
  59. #define STYP_OTHER_LOAD (STYP_ECOFF_INIT | STYP_ECOFF_FINI)
  60.  
  61. /* extended section types */
  62. #define STYP_COMMENT     0x2100000
  63. #define STYP_XDATA     0x2400000
  64. #define STYP_PDATA     0x2800000
  65.  
  66. /* The linker needs a section to hold small common variables while
  67.    linking.  There is no convenient way to create it when the linker
  68.    needs it, so we always create one for each BFD.  We then avoid
  69.    writing it out.  */
  70. #define SCOMMON ".scommon"
  71.  
  72. /* If the extern bit in a reloc is 1, then r_symndx is an index into
  73.    the external symbol table.  If the extern bit is 0, then r_symndx
  74.    indicates a section, and is one of the following values.  */
  75. #define RELOC_SECTION_NONE    0
  76. #define RELOC_SECTION_TEXT    1
  77. #define RELOC_SECTION_RDATA    2
  78. #define RELOC_SECTION_DATA    3
  79. #define RELOC_SECTION_SDATA    4
  80. #define RELOC_SECTION_SBSS    5
  81. #define RELOC_SECTION_BSS    6
  82. #define RELOC_SECTION_INIT    7
  83. #define RELOC_SECTION_LIT8    8
  84. #define RELOC_SECTION_LIT4    9
  85. #define RELOC_SECTION_XDATA    10
  86. #define RELOC_SECTION_PDATA    11
  87. #define RELOC_SECTION_FINI     12
  88. #define RELOC_SECTION_LITA     13
  89. #define RELOC_SECTION_ABS      14
  90.  
  91. #define NUM_RELOC_SECTIONS     15
  92.  
  93. /********************** STABS **********************/
  94.  
  95. /* gcc uses mips-tfile to output type information in special stabs
  96.    entries.  These must match the corresponding definition in
  97.    gcc/config/mips.h.  At some point, these should probably go into a
  98.    shared include file, but currently gcc and gdb do not share any
  99.    directories. */
  100. #define CODE_MASK 0x8F300
  101. #define ECOFF_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
  102. #define ECOFF_MARK_STAB(code) ((code)+CODE_MASK)
  103. #define ECOFF_UNMARK_STAB(code) ((code)-CODE_MASK)
  104. #define STABS_SYMBOL "@stabs"
  105.  
  106. /********************** COFF **********************/
  107.  
  108. /* gcc also uses mips-tfile to output COFF debugging information.
  109.    These are the values it uses when outputting the .type directive.
  110.    These should also be in a shared include file.  */
  111. #define N_BTMASK    (017)
  112. #define N_TMASK        (060)
  113. #define N_BTSHFT    (4)
  114. #define N_TSHIFT    (2)
  115.  
  116. /********************** AUX **********************/
  117.  
  118. /* The auxiliary type information is the same on all known ECOFF
  119.    targets.  I can't see any reason that it would ever change, so I am
  120.    going to gamble and define the external structures here, in the
  121.    target independent ECOFF header file.  The internal forms are
  122.    defined in coff/sym.h, which was originally donated by MIPS
  123.    Computer Systems.  */
  124.  
  125. /* Type information external record */
  126.  
  127. struct tir_ext {
  128.     unsigned char    t_bits1[1];
  129.     unsigned char    t_tq45[1];
  130.     unsigned char    t_tq01[1];
  131.     unsigned char    t_tq23[1];
  132. };
  133.  
  134. #define    TIR_BITS1_FBITFIELD_BIG        ((unsigned int) 0x80)
  135. #define    TIR_BITS1_FBITFIELD_LITTLE    ((unsigned int) 0x01)
  136.  
  137. #define    TIR_BITS1_CONTINUED_BIG        ((unsigned int) 0x40)
  138. #define    TIR_BITS1_CONTINUED_LITTLE    ((unsigned int) 0x02)
  139.  
  140. #define    TIR_BITS1_BT_BIG        ((unsigned int) 0x3F)
  141. #define    TIR_BITS1_BT_SH_BIG        0
  142. #define    TIR_BITS1_BT_LITTLE        ((unsigned int) 0xFC)
  143. #define    TIR_BITS1_BT_SH_LITTLE        2
  144.  
  145. #define    TIR_BITS_TQ4_BIG        ((unsigned int) 0xF0)
  146. #define    TIR_BITS_TQ4_SH_BIG        4
  147. #define    TIR_BITS_TQ5_BIG        ((unsigned int) 0x0F)
  148. #define    TIR_BITS_TQ5_SH_BIG        0
  149. #define    TIR_BITS_TQ4_LITTLE        ((unsigned int) 0x0F)
  150. #define    TIR_BITS_TQ4_SH_LITTLE        0
  151. #define    TIR_BITS_TQ5_LITTLE        ((unsigned int) 0xF0)
  152. #define    TIR_BITS_TQ5_SH_LITTLE        4
  153.  
  154. #define    TIR_BITS_TQ0_BIG        ((unsigned int) 0xF0)
  155. #define    TIR_BITS_TQ0_SH_BIG        4
  156. #define    TIR_BITS_TQ1_BIG        ((unsigned int) 0x0F)
  157. #define    TIR_BITS_TQ1_SH_BIG        0
  158. #define    TIR_BITS_TQ0_LITTLE        ((unsigned int) 0x0F)
  159. #define    TIR_BITS_TQ0_SH_LITTLE        0
  160. #define    TIR_BITS_TQ1_LITTLE        ((unsigned int) 0xF0)
  161. #define    TIR_BITS_TQ1_SH_LITTLE        4
  162.  
  163. #define    TIR_BITS_TQ2_BIG        ((unsigned int) 0xF0)
  164. #define    TIR_BITS_TQ2_SH_BIG        4
  165. #define    TIR_BITS_TQ3_BIG        ((unsigned int) 0x0F)
  166. #define    TIR_BITS_TQ3_SH_BIG        0
  167. #define    TIR_BITS_TQ2_LITTLE        ((unsigned int) 0x0F)
  168. #define    TIR_BITS_TQ2_SH_LITTLE        0
  169. #define    TIR_BITS_TQ3_LITTLE        ((unsigned int) 0xF0)
  170. #define    TIR_BITS_TQ3_SH_LITTLE        4
  171.  
  172. /* Relative symbol external record */
  173.  
  174. struct rndx_ext {
  175.     unsigned char    r_bits[4];
  176. };
  177.  
  178. #define    RNDX_BITS0_RFD_SH_LEFT_BIG    4
  179. #define    RNDX_BITS1_RFD_BIG        ((unsigned int) 0xF0)
  180. #define    RNDX_BITS1_RFD_SH_BIG        4
  181.  
  182. #define    RNDX_BITS0_RFD_SH_LEFT_LITTLE    0
  183. #define    RNDX_BITS1_RFD_LITTLE        ((unsigned int) 0x0F)
  184. #define    RNDX_BITS1_RFD_SH_LEFT_LITTLE    8
  185.  
  186. #define    RNDX_BITS1_INDEX_BIG        ((unsigned int) 0x0F)
  187. #define    RNDX_BITS1_INDEX_SH_LEFT_BIG    16
  188. #define    RNDX_BITS2_INDEX_SH_LEFT_BIG    8
  189. #define    RNDX_BITS3_INDEX_SH_LEFT_BIG    0
  190.  
  191. #define    RNDX_BITS1_INDEX_LITTLE        ((unsigned int) 0xF0)
  192. #define    RNDX_BITS1_INDEX_SH_LITTLE    4
  193. #define    RNDX_BITS2_INDEX_SH_LEFT_LITTLE    4
  194. #define    RNDX_BITS3_INDEX_SH_LEFT_LITTLE    12
  195.  
  196. /* Auxiliary symbol information external record */
  197.  
  198. union aux_ext {
  199.     struct tir_ext    a_ti;
  200.     struct rndx_ext    a_rndx;
  201.     unsigned char    a_dnLow[4];
  202.     unsigned char    a_dnHigh[4];
  203.     unsigned char    a_isym[4];
  204.     unsigned char    a_iss[4];
  205.     unsigned char    a_width[4];
  206.     unsigned char    a_count[4];
  207. };
  208.  
  209. #define AUX_GET_ANY(bigend, ax, field) \
  210.   ((bigend) ? bfd_getb32 ((ax)->field) : bfd_getl32 ((ax)->field))
  211.  
  212. #define    AUX_GET_DNLOW(bigend, ax)    AUX_GET_ANY ((bigend), (ax), a_dnLow)
  213. #define    AUX_GET_DNHIGH(bigend, ax)    AUX_GET_ANY ((bigend), (ax), a_dnHigh)
  214. #define    AUX_GET_ISYM(bigend, ax)    AUX_GET_ANY ((bigend), (ax), a_isym)
  215. #define AUX_GET_ISS(bigend, ax)        AUX_GET_ANY ((bigend), (ax), a_iss)
  216. #define AUX_GET_WIDTH(bigend, ax)    AUX_GET_ANY ((bigend), (ax), a_width)
  217. #define AUX_GET_COUNT(bigend, ax)    AUX_GET_ANY ((bigend), (ax), a_count)
  218.  
  219. #define AUX_PUT_ANY(bigend, val, ax, field) \
  220.   ((bigend) \
  221.    ? (bfd_putb32 ((bfd_vma) (val), (ax)->field), 0) \
  222.    : (bfd_putl32 ((bfd_vma) (val), (ax)->field), 0))
  223.  
  224. #define AUX_PUT_DNLOW(bigend, val, ax) \
  225.   AUX_PUT_ANY ((bigend), (val), (ax), a_dnLow)
  226. #define AUX_PUT_DNHIGH(bigend, val, ax) \
  227.   AUX_PUT_ANY ((bigend), (val), (ax), a_dnHigh)
  228. #define AUX_PUT_ISYM(bigend, val, ax) \
  229.   AUX_PUT_ANY ((bigend), (val), (ax), a_isym)
  230. #define AUX_PUT_ISS(bigend, val, ax) \
  231.   AUX_PUT_ANY ((bigend), (val), (ax), a_iss)
  232. #define AUX_PUT_WIDTH(bigend, val, ax) \
  233.   AUX_PUT_ANY ((bigend), (val), (ax), a_width)
  234. #define AUX_PUT_COUNT(bigend, val, ax) \
  235.   AUX_PUT_ANY ((bigend), (val), (ax), a_count)
  236.  
  237. /********************** SYMBOLS **********************/
  238.  
  239. /* For efficiency, gdb deals directly with the unswapped symbolic
  240.    information (that way it only takes the time to swap information
  241.    that it really needs to read).  gdb originally retrieved the
  242.    information directly from the BFD backend information, but that
  243.    strategy, besides being sort of ugly, does not work for MIPS ELF,
  244.    which also uses ECOFF debugging information.  This structure holds
  245.    pointers to the (mostly) unswapped symbolic information.  */
  246.  
  247. struct ecoff_debug_info
  248. {
  249.   /* The swapped ECOFF symbolic header.  */
  250.   HDRR symbolic_header;
  251.  
  252.   /* Pointers to the unswapped symbolic information.  Note that the
  253.      pointers to external structures point to different sorts of
  254.      information on different ECOFF targets.  The ecoff_debug_swap
  255.      structure provides the sizes of the structures and the functions
  256.      needed to swap the information in and out.  These pointers are
  257.      all pointers to arrays, not single structures.  They will be NULL
  258.      if there are no instances of the relevant structure.  These
  259.      fields are also used by the assembler to output ECOFF debugging
  260.      information.  */
  261.   unsigned char *line;
  262.   PTR external_dnr;    /* struct dnr_ext */
  263.   PTR external_pdr;    /* struct pdr_ext */
  264.   PTR external_sym;    /* struct sym_ext */
  265.   PTR external_opt;    /* struct opt_ext */
  266.   union aux_ext *external_aux;
  267.   char *ss;
  268.   char *ssext;
  269.   PTR external_fdr;    /* struct fdr_ext */
  270.   PTR external_rfd;    /* struct rfd_ext */
  271.   PTR external_ext;    /* struct ext_ext */
  272.  
  273.   /* These fields are used when linking.  They may disappear at some
  274.      point.  */
  275.   char *ssext_end;
  276.   PTR external_ext_end;
  277.  
  278.   /* When linking, this field holds a mapping from the input FDR
  279.      numbers to the output numbers, and is used when writing out the
  280.      external symbols.  It is NULL if no mapping is required.  */
  281.   RFDT *ifdmap;
  282.  
  283.   /* The swapped FDR information.  Currently this is never NULL, but
  284.      code using this structure should probably double-check in case
  285.      this changes in the future.  This is a pointer to an array, not a
  286.      single structure.  */
  287.   FDR *fdr;
  288.  
  289.   /* When relaxing MIPS embedded PIC code, we may need to adjust
  290.      symbol values when they are output.  This is a linked list of
  291.      structures indicating how values should be adjusted.  There is no
  292.      requirement that the entries be in any order, or that they not
  293.      overlap.  This field is normally NULL, in which case no
  294.      adjustments need to be made.  */
  295.   struct ecoff_value_adjust *adjust;
  296. };
  297.  
  298. /* This structure describes how to adjust symbol values when
  299.    outputting MIPS embedded PIC code.  These adjustments only apply to
  300.    the internal symbols, as the external symbol values will come from
  301.    the hash table and have already been adjusted.  */
  302.  
  303. struct ecoff_value_adjust
  304. {
  305.   /* Next entry on adjustment list.  */
  306.   struct ecoff_value_adjust *next;
  307.   /* Starting VMA of adjustment.  This is the VMA in the ECOFF file,
  308.      not the offset from the start of the section.  Thus it should
  309.      indicate a particular section.  */
  310.   bfd_vma start;
  311.   /* Ending VMA of adjustment.  */
  312.   bfd_vma end;
  313.   /* Adjustment.  This should be added to the value of the symbol, or
  314.      FDR.  This is zero for the last entry in the array.  */
  315.   long adjust;
  316. };
  317.  
  318. /********************** SWAPPING **********************/
  319.  
  320. /* The generic ECOFF code needs to be able to swap debugging
  321.    information in and out in the specific format used by a particular
  322.    ECOFF implementation.  This structure provides the information
  323.    needed to do this.  */
  324.  
  325. struct ecoff_debug_swap
  326. {
  327.   /* Symbol table magic number.  */
  328.   int sym_magic;
  329.   /* Alignment of debugging information.  E.g., 4.  */
  330.   bfd_size_type debug_align;
  331.   /* Sizes of external symbolic information.  */
  332.   bfd_size_type external_hdr_size;
  333.   bfd_size_type external_dnr_size;
  334.   bfd_size_type external_pdr_size;
  335.   bfd_size_type external_sym_size;
  336.   bfd_size_type external_opt_size;
  337.   bfd_size_type external_fdr_size;
  338.   bfd_size_type external_rfd_size;
  339.   bfd_size_type external_ext_size;
  340.   /* Functions to swap in external symbolic data.  */
  341.   void (*swap_hdr_in) PARAMS ((bfd *, PTR, HDRR *));
  342.   void (*swap_dnr_in) PARAMS ((bfd *, PTR, DNR *));
  343.   void (*swap_pdr_in) PARAMS ((bfd *, PTR, PDR *));
  344.   void (*swap_sym_in) PARAMS ((bfd *, PTR, SYMR *));
  345.   void (*swap_opt_in) PARAMS ((bfd *, PTR, OPTR *));
  346.   void (*swap_fdr_in) PARAMS ((bfd *, PTR, FDR *));
  347.   void (*swap_rfd_in) PARAMS ((bfd *, PTR, RFDT *));
  348.   void (*swap_ext_in) PARAMS ((bfd *, PTR, EXTR *));
  349.   void (*swap_tir_in) PARAMS ((int, const struct tir_ext *, TIR *));
  350.   void (*swap_rndx_in) PARAMS ((int, const struct rndx_ext *, RNDXR *));
  351.   /* Functions to swap out external symbolic data.  */
  352.   void (*swap_hdr_out) PARAMS ((bfd *, const HDRR *, PTR));
  353.   void (*swap_dnr_out) PARAMS ((bfd *, const DNR *, PTR));
  354.   void (*swap_pdr_out) PARAMS ((bfd *, const PDR *, PTR));
  355.   void (*swap_sym_out) PARAMS ((bfd *, const SYMR *, PTR));
  356.   void (*swap_opt_out) PARAMS ((bfd *, const OPTR *, PTR));
  357.   void (*swap_fdr_out) PARAMS ((bfd *, const FDR *, PTR));
  358.   void (*swap_rfd_out) PARAMS ((bfd *, const RFDT *, PTR));
  359.   void (*swap_ext_out) PARAMS ((bfd *, const EXTR *, PTR));
  360.   void (*swap_tir_out) PARAMS ((int, const TIR *, struct tir_ext *));
  361.   void (*swap_rndx_out) PARAMS ((int, const RNDXR *, struct rndx_ext *));
  362.   /* Function to read symbol data and set up pointers in
  363.      ecoff_debug_info structure.  The section argument is used for
  364.      ELF, not straight ECOFF.  */
  365.   boolean (*read_debug_info) PARAMS ((bfd *, asection *,
  366.                       struct ecoff_debug_info *));
  367. };
  368.  
  369. #endif /* ! defined (ECOFF_H) */
  370.