home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / binutils-2.7-src.tgz / tar.out / fsf / binutils / bfd / evax.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  15KB  |  383 lines

  1. /* evax.h -- Header file for ALPHA EVAX (openVMS/AXP) support.
  2.    Copyright 1996 Free Software Foundation, Inc.
  3.    Written by Klaus Kämpf (kkaempf@progis.de)
  4.    of proGIS Softwareentwicklung, Aachen, Germany
  5.  
  6. This file is part of BFD, the Binary File Descriptor library.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program; if not, write to the Free Software
  20. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  21.  
  22. #ifndef EVAX_H
  23. #define EVAX_H
  24.  
  25. /* EVAX Text, information and relocation record (ETIR) definitions.  */
  26.  
  27. #define ETIR_S_C_MINSTACOD 0        /* Minimum store code        */
  28. #define ETIR_S_C_STA_GBL 0        /* Stack global symbol value    */
  29. #define ETIR_S_C_STA_LW 1        /* Stack longword        */
  30. #define ETIR_S_C_STA_QW 2        /* Stack quadword        */
  31. #define ETIR_S_C_STA_PQ 3        /* Stack psect base plus quadword offset  */
  32. #define ETIR_S_C_STA_LI 4        /* Stack literal        */
  33. #define ETIR_S_C_STA_MOD 5        /* Stack module            */
  34. #define ETIR_S_C_STA_CKARG 6        /* Check Arguments        */
  35. #define ETIR_S_C_MAXSTACOD 6        /* Maximum stack code        */
  36. #define ETIR_S_C_MINSTOCOD 50        /* Minimum store code        */
  37. #define ETIR_S_C_STO_B 50        /* Store byte            */
  38. #define ETIR_S_C_STO_W 51        /* Store word            */
  39. #define ETIR_S_C_STO_LW 52        /* Store longword        */
  40. #define ETIR_S_C_STO_QW 53        /* Store quadword        */
  41. #define ETIR_S_C_STO_IMMR 54        /* Store immediate Repeated    */
  42. #define ETIR_S_C_STO_GBL 55        /* Store global            */
  43. #define ETIR_S_C_STO_CA 56        /* Store code address        */
  44. #define ETIR_S_C_STO_RB 57        /* Store relative branch    */
  45. #define ETIR_S_C_STO_AB 58        /* Store absolute branch    */
  46. #define ETIR_S_C_STO_OFF 59        /* Store offset within psect    */
  47. #define ETIR_S_C_STO_IMM 61        /* Store immediate        */
  48. #define ETIR_S_C_STO_GBL_LW 62        /* Store global Longword    */
  49. #define ETIR_S_C_STO_LP_PSB 63        /* STO_LP_PSB not valid in level 2 use STC_LP_PSB            */
  50. #define ETIR_S_C_STO_HINT_GBL 64    /* Store 14 bit HINT at global address */
  51. #define ETIR_S_C_STO_HINT_PS 65        /* Store 14 bit HINT at psect + offset */
  52. #define ETIR_S_C_MAXSTOCOD 65        /* Maximum store code        */
  53. #define ETIR_S_C_MINOPRCOD 100        /* Minimum operate code        */
  54. #define ETIR_S_C_OPR_NOP 100        /* No-op            */
  55. #define ETIR_S_C_OPR_ADD 101        /* Add                */
  56. #define ETIR_S_C_OPR_SUB 102        /* Subtract            */
  57. #define ETIR_S_C_OPR_MUL 103        /* Multiply            */
  58. #define ETIR_S_C_OPR_DIV 104        /* Divide            */
  59. #define ETIR_S_C_OPR_AND 105        /* Logical AND            */
  60. #define ETIR_S_C_OPR_IOR 106        /* Logical inclusive OR        */
  61. #define ETIR_S_C_OPR_EOR 107        /* Logical exclusive OR        */
  62. #define ETIR_S_C_OPR_NEG 108        /* Negate            */
  63. #define ETIR_S_C_OPR_COM 109        /* Complement            */
  64. #define ETIR_S_C_OPR_INSV 110        /* Insert bit field        */
  65. #define ETIR_S_C_OPR_ASH 111        /* Arithmetic shift        */
  66. #define ETIR_S_C_OPR_USH 112        /* Unsigned shift        */
  67. #define ETIR_S_C_OPR_ROT 113        /* Rotate            */
  68. #define ETIR_S_C_OPR_SEL 114        /* Select one of three longwords on top of stack  */
  69. #define ETIR_S_C_OPR_REDEF 115        /* Redefine this symbol after pass 2  */
  70. #define ETIR_S_C_OPR_DFLIT 116        /* Define a literal        */
  71. #define ETIR_S_C_MAXOPRCOD 116        /* Maximum operate code        */
  72. #define ETIR_S_C_MINCTLCOD 150        /* Minimum control code        */
  73. #define ETIR_S_C_CTL_SETRB 150        /* Set relocation base        */
  74. #define ETIR_S_C_CTL_AUGRB 151        /* Augment relocation base    */
  75. #define ETIR_S_C_CTL_DFLOC 152        /* Define debug location    */
  76. #define ETIR_S_C_CTL_STLOC 153        /* Set debug location        */
  77. #define ETIR_S_C_CTL_STKDL 154        /* Stack debug location        */
  78. #define ETIR_S_C_MAXCTLCOD 154        /* Maximum control code        */
  79. #define ETIR_S_C_MINSTCCOD 200        /* Minimum store-conditional code    */
  80. #define ETIR_S_C_STC_LP 200        /* Store-conditional Linkage Pair    */
  81. #define ETIR_S_C_STC_LP_PSB 201        /* Store-conditional Linkage Pair with Procedure Signature */
  82. #define ETIR_S_C_STC_GBL 202        /* Store-conditional Address at global address */
  83. #define ETIR_S_C_STC_GCA 203        /* Store-conditional Code Address at global address */
  84. #define ETIR_S_C_STC_PS 204        /* Store-conditional Address at psect + offset */
  85. #define ETIR_S_C_STC_NOP_GBL 205    /* Store-conditional NOP at address of global */
  86. #define ETIR_S_C_STC_NOP_PS 206        /* Store-conditional NOP at pect + offset */
  87. #define ETIR_S_C_STC_BSR_GBL 207    /* Store-conditional BSR at global address */
  88. #define ETIR_S_C_STC_BSR_PS 208        /* Store-conditional BSR at pect + offset */
  89. #define ETIR_S_C_STC_LDA_GBL 209    /* Store-conditional LDA at global address */
  90. #define ETIR_S_C_STC_LDA_PS 210        /* Store-conditional LDA at psect + offset */
  91. #define ETIR_S_C_STC_BOH_GBL 211    /* Store-conditional BSR or Hint at global address */
  92. #define ETIR_S_C_STC_BOH_PS 212        /* Store-conditional BSR or Hint at pect + offset */
  93. #define ETIR_S_C_STC_NBH_GBL 213    /* Store-conditional NOP,BSR or HINT at global address */
  94. #define ETIR_S_C_STC_NBH_PS 214        /* Store-conditional NOP,BSR or HINT at psect + offset */
  95. #define ETIR_S_C_MAXSTCCOD 214        /* Maximum store-conditional code    */
  96.  
  97. /* EVAX Global symbol definition record (EGSD).  */
  98.  
  99. #define EGSD_S_K_ENTRIES 2    /* Offset to first entry in record    */
  100. #define EGSD_S_C_ENTRIES 2    /* Offset to first entry in record    */
  101. #define EGSD_S_C_PSC 0        /* Psect definition            */
  102. #define EGSD_S_C_SYM 1        /* Symbol specification            */
  103. #define EGSD_S_C_IDC 2        /* Random entity check            */
  104. #define EGSD_S_C_SPSC 5        /* Shareable image psect definition    */
  105. #define EGSD_S_C_SYMV 6        /* Vectored (dual-valued) versions of SYM, */
  106. #define EGSD_S_C_SYMM 7        /* Masked versions of SYM,        */
  107. #define EGSD_S_C_SYMG 8        /* EGST - gst version of SYM        */
  108. #define EGSD_S_C_MAXRECTYP 8    /* Maximum entry type defined        */
  109.  
  110. #define EGPS_S_V_PIC    0x0001
  111. #define EGPS_S_V_LIB    0x0002
  112. #define EGPS_S_V_OVR    0x0004
  113. #define EGPS_S_V_REL    0x0008
  114. #define EGPS_S_V_GBL    0x0010
  115. #define EGPS_S_V_SHR    0x0020
  116. #define EGPS_S_V_EXE    0x0040
  117. #define EGPS_S_V_RD    0x0080
  118. #define EGPS_S_V_WRT    0x0100
  119. #define EGPS_S_V_VEC    0x0200
  120. #define EGPS_S_V_NOMOD    0x0400
  121. #define EGPS_S_V_COM    0x0800
  122.  
  123. #define EGSY_S_V_WEAK    0x0001
  124. #define EGSY_S_V_DEF    0x0002
  125. #define EGSY_S_V_UNI    0x0004
  126. #define EGSY_S_V_REL    0x0008
  127. #define EGSY_S_V_COMM    0x0010
  128. #define EGSY_S_V_VECEP    0x0020
  129. #define EGSY_S_V_NORM    0x0040
  130.  
  131. /* EVAX Module header record (EMH) definitions.  */
  132.  
  133. #define EMH_S_C_MHD 0        /* Main header record        */
  134. #define EMH_S_C_LNM 1        /* Language name and version    */
  135. #define EMH_S_C_SRC 2        /* Source file specification    */
  136. #define EMH_S_C_TTL 3        /* Title text of module        */
  137. #define EMH_S_C_CPR 4        /* Copyright notice        */
  138. #define EMH_S_C_MTC 5        /* Maintenance status        */
  139. #define EMH_S_C_GTX 6        /* General text            */
  140. #define EMH_S_C_MAXHDRTYP 6    /* Maximum allowable type    */
  141.  
  142. /* evax-alpha.c.  */
  143.  
  144. extern asymbol *_bfd_evax_make_empty_symbol PARAMS ((bfd *abfd));
  145.  
  146. /* evax-egsd.c.  */
  147.  
  148. extern int _bfd_evax_slurp_egsd PARAMS ((bfd *abfd));
  149. extern int _bfd_evax_write_egsd PARAMS ((bfd *abfd));
  150.  
  151. /* evax-emh.c.  */
  152.  
  153. extern int _bfd_evax_slurp_emh PARAMS ((bfd *abfd));
  154. extern int _bfd_evax_write_emh PARAMS ((bfd *abfd));
  155. extern int _bfd_evax_slurp_eeom PARAMS ((bfd *abfd));
  156. extern int _bfd_evax_write_eeom PARAMS ((bfd *abfd));
  157.  
  158. /* evax-etir.c.  */
  159.  
  160. extern int _bfd_evax_slurp_etir PARAMS ((bfd *abfd));
  161. extern int _bfd_evax_slurp_edbg PARAMS ((bfd *abfd));
  162. extern int _bfd_evax_slurp_etbt PARAMS ((bfd *abfd));
  163.  
  164. extern int _bfd_evax_write_etir PARAMS ((bfd *abfd));
  165. extern int _bfd_evax_write_etbt PARAMS ((bfd *abfd));
  166. extern int _bfd_evax_write_edbg PARAMS ((bfd *abfd));
  167.  
  168. /* The r_type field in a reloc is one of the following values.  */
  169. #define ALPHA_R_IGNORE        0
  170. #define ALPHA_R_REFQUAD        1
  171. #define ALPHA_R_BRADDR        2
  172. #define ALPHA_R_HINT        3
  173. #define ALPHA_R_SREL16        4
  174. #define ALPHA_R_SREL32        5
  175. #define ALPHA_R_SREL64        6
  176. #define ALPHA_R_OP_PUSH        7
  177. #define ALPHA_R_OP_STORE    8
  178. #define ALPHA_R_OP_PSUB        9
  179. #define ALPHA_R_OP_PRSHIFT    10
  180. #define ALPHA_R_LINKAGE        11
  181. #define ALPHA_R_SWREL32        12
  182. #define ALPHA_R_SWREL64        13
  183. #define ALPHA_R_REFLONG        14
  184.  
  185. /* Object language definitions.  */
  186.  
  187. #define EOBJ_S_C_EMH 8            /*EVAX module header record         */
  188. #define EOBJ_S_C_EEOM 9           /*EVAX end of module record         */
  189. #define EOBJ_S_C_EGSD 10          /*EVAX global symbol definition record  */
  190. #define EOBJ_S_C_ETIR 11          /*EVAX text information record      */
  191. #define EOBJ_S_C_EDBG 12          /*EVAX Debugger information record  */
  192. #define EOBJ_S_C_ETBT 13          /*EVAX Traceback information record  */
  193. #define EOBJ_S_C_MAXRECTYP 13     /*Last assigned record type         */
  194. #define EOBJ_S_K_SUBTYP 4
  195. #define EOBJ_S_C_SUBTYP 4
  196. #define EOBJ_S_C_MAXRECSIZ 8192   /*Maximum legal record size         */
  197. #define EOBJ_S_C_STRLVL 2         /*Structure level                   */
  198. #define EOBJ_S_C_SYMSIZ 64        /*Maxymum symbol length             */
  199. #define EOBJ_S_C_STOREPLIM -1     /*Maximum repeat count on store commands  */
  200. #define EOBJ_S_C_PSCALILIM 16     /*Maximum p-sect alignment          */
  201.  
  202. /* Miscellaneous definitions.  */
  203.  
  204. #if __GNUC__
  205. typedef unsigned long long uquad;
  206. #else
  207. typedef unsigned long uquad;
  208. #endif
  209.  
  210. #define MAX_OUTREC_SIZE 4096
  211. #define MIN_OUTREC_LUFT 64
  212.  
  213. typedef struct _evax_section {
  214.   unsigned char *contents;
  215.   bfd_vma offset;
  216.   bfd_size_type size;
  217.   struct _evax_section *next;
  218. } evax_section;
  219.  
  220. extern boolean _bfd_save_evax_section
  221.   PARAMS ((bfd *abfd, asection *section, PTR data, file_ptr offset,
  222.        bfd_size_type count));
  223. extern evax_section *_bfd_get_evax_section PARAMS ((bfd *abfd, int index));
  224.  
  225. typedef struct _evax_reloc {
  226.   struct _evax_reloc *next;
  227.   arelent *reloc;
  228.   asection *section;
  229. } evax_reloc;
  230.  
  231. /* evax module header  */
  232.  
  233. struct emh_struc {
  234.   int emh_b_strlvl;
  235.   long emh_l_arch1;
  236.   long emh_l_arch2;
  237.   long emh_l_recsiz;
  238.   char *emh_t_name;
  239.   char *emh_t_version;
  240.   char *emh_t_date;
  241.   char *emh_c_lnm;
  242.   char *emh_c_src;
  243.   char *emh_c_ttl;
  244. };
  245.  
  246.  
  247. /* evax end of module  */
  248.  
  249. struct eeom_struc {
  250.   long eeom_l_total_lps;
  251.   unsigned char eeom_b_comcod;
  252.   boolean eeom_has_transfer;
  253.   unsigned char eeom_b_tfrflg;
  254.   long eeom_l_psindx;
  255.   long eeom_l_tfradr;
  256. };
  257.  
  258. enum file_format_enum { FF_UNKNOWN, FF_FOREIGN, FF_NATIVE };
  259.  
  260. typedef struct evax_symbol_struct {
  261.   struct bfd_hash_entry bfd_hash;
  262.   asymbol *symbol;
  263. } evax_symbol_entry;
  264.  
  265. /* stack value for push/pop commands  */
  266.  
  267. struct stack_struct {
  268.   uquad value;
  269.   int psect;
  270. };
  271. #define STACKSIZE 50
  272.  
  273. /* location stack definitions for CTL_DFLOC, CTL_STLOC, and CTL_STKDL  */
  274.  
  275. struct location_struct {
  276.   unsigned long value;
  277.   int psect;
  278. };
  279. #define LOCATION_SAVE_SIZE 32
  280.  
  281. #define EVAX_SECTION_COUNT 32
  282.  
  283. struct evax_private_data_struct {
  284.   char *filename;            /* Filename of object file   */
  285.   boolean fixup_done;            /* Flag to indicate if all
  286.                        section pointers and PRIV(sections)
  287.                        are set up correctly  */
  288.   unsigned char *evax_buf;        /* buffer to record  */
  289.   int buf_size;                /* max size of buffer  */
  290.   unsigned char *evax_rec;        /* actual record ptr  */
  291.   int rec_length;            /* remaining record length  */
  292.   int rec_size;                /* actual record size  */
  293.   int rec_type;                /* actual record type  */
  294.   enum file_format_enum file_format;
  295.  
  296.   struct emh_struc emh_data;        /* data from EMH record  */
  297.   struct eeom_struc eeom_data;        /* data from EEOM record  */
  298.   int egsd_sec_count;            /* # of EGSD sections  */
  299.   asection **sections;            /* vector of EGSD sections  */
  300.   int egsd_sym_count;            /* # of EGSD symbols  */
  301.   asymbol **symbols;            /* vector of EGSD symbols  */
  302.   struct proc_value *procedure;
  303.  
  304.   struct stack_struct *stack;
  305.   int stackptr;
  306.  
  307.   evax_section *evax_section_table[EVAX_SECTION_COUNT];
  308.   evax_reloc *evax_reloc_table[EVAX_SECTION_COUNT];
  309.  
  310.   struct bfd_hash_table *evax_symbol_table;
  311.   struct symbol_cache_entry **symcache;
  312.   int symnum;
  313.  
  314.   struct location_struct *location_stack;
  315.  
  316.   unsigned char *image_ptr;        /* a pointer to section->contents */
  317.  
  318.   unsigned char pdsc[8];        /* procedure descriptor */
  319.  
  320.   /* Output routine storage  */
  321.  
  322.   unsigned char *output_buf;        /* output data  */
  323.   int push_level;
  324.   int pushed_size;
  325.   int length_pos;
  326.   int output_size;
  327.   int output_alignment;
  328.  
  329.   /* linkage index counter
  330.    used by conditional store commands (ETIR_S_C_STC_)  */
  331.  
  332.   int evax_linkage_index;
  333.  
  334. };
  335.  
  336. #define PRIV(name)    ((struct evax_private_data_struct *)abfd->tdata.any)->name
  337.  
  338. #if EVAX_DEBUG
  339. extern void _bfd_evax_debug PARAMS((int level, char *format, ...));
  340. extern void _bfd_hexdump
  341.   PARAMS ((int level, unsigned char *ptr, int size, int offset));
  342.  
  343. #define evax_debug _bfd_evax_debug
  344.  
  345. #endif
  346.  
  347. extern struct bfd_hash_entry *_bfd_evax_hash_newfunc
  348.   PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table,
  349.        const char *string));
  350. extern void _bfd_evax_get_header_values
  351.   PARAMS ((bfd *abfd, unsigned char *buf, int *type, int *length));
  352. extern int _bfd_evax_get_record PARAMS ((bfd *abfd));
  353. extern int _bfd_evax_next_record PARAMS ((bfd *abfd));
  354.  
  355. extern char *_bfd_evax_save_sized_string PARAMS ((char *str, int size));
  356. extern char *_bfd_evax_save_counted_string PARAMS ((char *ptr));
  357. extern void _bfd_evax_push PARAMS ((bfd *abfd, uquad val, int psect));
  358. extern uquad _bfd_evax_pop PARAMS ((bfd *abfd, int *psect));
  359.  
  360. extern boolean _bfd_save_evax_section
  361.   PARAMS ((bfd *abfd, asection *section, PTR data, file_ptr offset,
  362.        bfd_size_type count));
  363. extern void _bfd_evax_output_begin
  364.   PARAMS ((bfd *abfd, int rectype, int rechead));
  365. extern void _bfd_evax_output_alignment PARAMS ((bfd *abfd, int alignto));
  366. extern void _bfd_evax_output_push PARAMS ((bfd *abfd));
  367. extern void _bfd_evax_output_pop PARAMS ((bfd *abfd));
  368. extern void _bfd_evax_output_flush PARAMS ((bfd *abfd));
  369. extern void _bfd_evax_output_end PARAMS ((bfd *abfd));
  370. extern int _bfd_evax_output_check PARAMS ((bfd *abfd, int size));
  371. extern void _bfd_evax_output_byte PARAMS ((bfd *abfd, unsigned int value));
  372. extern void _bfd_evax_output_short PARAMS ((bfd *abfd, unsigned int value));
  373. extern void _bfd_evax_output_long PARAMS ((bfd *abfd, unsigned long value));
  374. extern void _bfd_evax_output_quad PARAMS ((bfd *abfd, uquad value));
  375. extern void _bfd_evax_output_counted PARAMS ((bfd *abfd, char *value));
  376. extern void _bfd_evax_output_dump PARAMS ((bfd *abfd, unsigned char *data,
  377.                        int length));
  378. extern void _bfd_evax_output_fill PARAMS ((bfd *abfd, int value, int length));
  379. extern char *_bfd_get_vms_time_string PARAMS ((void));
  380. extern char *_bfd_evax_basename PARAMS ((char *name));
  381.  
  382. #endif /* EVAX_H */
  383.