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