Thu Aug 8 12:21:56 1996 Klaus Kaempf <kkaempf@progis.de>
[deliverable/binutils-gdb.git] / bfd / evax.h
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_REFLONG 12
182
183 /* Object language definitions. */
184
185 #define EOBJ_S_C_EMH 8 /*EVAX module header record */
186 #define EOBJ_S_C_EEOM 9 /*EVAX end of module record */
187 #define EOBJ_S_C_EGSD 10 /*EVAX global symbol definition record */
188 #define EOBJ_S_C_ETIR 11 /*EVAX text information record */
189 #define EOBJ_S_C_EDBG 12 /*EVAX Debugger information record */
190 #define EOBJ_S_C_ETBT 13 /*EVAX Traceback information record */
191 #define EOBJ_S_C_MAXRECTYP 13 /*Last assigned record type */
192 #define EOBJ_S_K_SUBTYP 4
193 #define EOBJ_S_C_SUBTYP 4
194 #define EOBJ_S_C_MAXRECSIZ 8192 /*Maximum legal record size */
195 #define EOBJ_S_C_STRLVL 2 /*Structure level */
196 #define EOBJ_S_C_SYMSIZ 64 /*Maxymum symbol length */
197 #define EOBJ_S_C_STOREPLIM -1 /*Maximum repeat count on store commands */
198 #define EOBJ_S_C_PSCALILIM 16 /*Maximum p-sect alignment */
199
200 /* Miscellaneous definitions. */
201
202 #if __GNUC__
203 typedef unsigned long long uquad;
204 #else
205 typedef unsigned long uquad;
206 #endif
207
208 #define MAX_OUTREC_SIZE 4096
209 #define MIN_OUTREC_LUFT 64
210
211 typedef struct _evax_section {
212 unsigned char *contents;
213 bfd_vma offset;
214 bfd_size_type size;
215 struct _evax_section *next;
216 } evax_section;
217
218 extern boolean _bfd_save_evax_section
219 PARAMS ((bfd *abfd, asection *section, PTR data, file_ptr offset,
220 bfd_size_type count));
221 extern evax_section *_bfd_get_evax_section PARAMS ((bfd *abfd, int index));
222
223 typedef struct _evax_reloc {
224 struct _evax_reloc *next;
225 arelent *reloc;
226 asection *section;
227 } evax_reloc;
228
229 /* evax module header */
230
231 struct emh_struc {
232 int emh_b_strlvl;
233 long emh_l_arch1;
234 long emh_l_arch2;
235 long emh_l_recsiz;
236 char *emh_t_name;
237 char *emh_t_version;
238 char *emh_t_date;
239 char *emh_c_lnm;
240 char *emh_c_src;
241 char *emh_c_ttl;
242 };
243
244
245 /* evax end of module */
246
247 struct eeom_struc {
248 long eeom_l_total_lps;
249 unsigned char eeom_b_comcod;
250 boolean eeom_has_transfer;
251 unsigned char eeom_b_tfrflg;
252 long eeom_l_psindx;
253 long eeom_l_tfradr;
254 };
255
256 enum file_format_enum { FF_UNKNOWN, FF_FOREIGN, FF_NATIVE };
257
258 typedef struct evax_symbol_struct {
259 struct bfd_hash_entry bfd_hash;
260 asymbol *symbol;
261 } evax_symbol_entry;
262
263 /* stack value for push/pop commands */
264
265 struct stack_struct {
266 uquad value;
267 int psect;
268 };
269 #define STACKSIZE 50
270
271 /* location stack definitions for CTL_DFLOC, CTL_STLOC, and CTL_STKDL */
272
273 struct location_struct {
274 unsigned long value;
275 int psect;
276 };
277 #define LOCATION_SAVE_SIZE 32
278
279 #define EVAX_SECTION_COUNT 32
280
281 struct evax_private_data_struct {
282 char *filename; /* Filename of object file */
283 boolean fixup_done; /* Flag to indicate if all
284 section pointers and PRIV(sections)
285 are set up correctly */
286 unsigned char *evax_buf; /* buffer to record */
287 int buf_size; /* max size of buffer */
288 unsigned char *evax_rec; /* actual record ptr */
289 int rec_length; /* remaining record length */
290 int rec_size; /* actual record size */
291 int rec_type; /* actual record type */
292 enum file_format_enum file_format;
293
294 struct emh_struc emh_data; /* data from EMH record */
295 struct eeom_struc eeom_data; /* data from EEOM record */
296 int egsd_sec_count; /* # of EGSD sections */
297 asection **sections; /* vector of EGSD sections */
298 int egsd_sym_count; /* # of EGSD symbols */
299 asymbol **symbols; /* vector of EGSD symbols */
300 struct proc_value *procedure;
301
302 struct stack_struct *stack;
303 int stackptr;
304
305 evax_section *evax_section_table[EVAX_SECTION_COUNT];
306
307 struct bfd_hash_table *evax_symbol_table;
308 struct symbol_cache_entry **symcache;
309 int symnum;
310
311 struct location_struct *location_stack;
312
313 unsigned char *image_ptr; /* a pointer to section->contents */
314
315 unsigned char pdsc[8]; /* procedure descriptor */
316
317 /* Output routine storage */
318
319 unsigned char *output_buf; /* output data */
320 int push_level;
321 int pushed_size;
322 int length_pos;
323 int output_size;
324 int output_alignment;
325
326 /* linkage index counter
327 used by conditional store commands (ETIR_S_C_STC_) */
328
329 int evax_linkage_index;
330
331 };
332
333 #define PRIV(name) ((struct evax_private_data_struct *)abfd->tdata.any)->name
334
335 #if EVAX_DEBUG
336 extern void _bfd_evax_debug PARAMS((int level, char *format, ...));
337 extern void _bfd_hexdump
338 PARAMS ((int level, unsigned char *ptr, int size, int offset));
339
340 #define evax_debug _bfd_evax_debug
341
342 #endif
343
344 extern struct bfd_hash_entry *_bfd_evax_hash_newfunc
345 PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table,
346 const char *string));
347 extern void _bfd_evax_get_header_values
348 PARAMS ((bfd *abfd, unsigned char *buf, int *type, int *length));
349 extern int _bfd_evax_get_record PARAMS ((bfd *abfd));
350 extern int _bfd_evax_next_record PARAMS ((bfd *abfd));
351
352 extern char *_bfd_evax_save_sized_string PARAMS ((char *str, int size));
353 extern char *_bfd_evax_save_counted_string PARAMS ((char *ptr));
354 extern void _bfd_evax_push PARAMS ((bfd *abfd, uquad val, int psect));
355 extern uquad _bfd_evax_pop PARAMS ((bfd *abfd, int *psect));
356
357 extern boolean _bfd_save_evax_section
358 PARAMS ((bfd *abfd, asection *section, PTR data, file_ptr offset,
359 bfd_size_type count));
360 extern void _bfd_evax_output_begin
361 PARAMS ((bfd *abfd, int rectype, int rechead));
362 extern void _bfd_evax_output_alignment PARAMS ((bfd *abfd, int alignto));
363 extern void _bfd_evax_output_push PARAMS ((bfd *abfd));
364 extern void _bfd_evax_output_pop PARAMS ((bfd *abfd));
365 extern void _bfd_evax_output_flush PARAMS ((bfd *abfd));
366 extern void _bfd_evax_output_end PARAMS ((bfd *abfd));
367 extern int _bfd_evax_output_check PARAMS ((bfd *abfd, int size));
368 extern void _bfd_evax_output_byte PARAMS ((bfd *abfd, unsigned int value));
369 extern void _bfd_evax_output_short PARAMS ((bfd *abfd, unsigned int value));
370 extern void _bfd_evax_output_long PARAMS ((bfd *abfd, unsigned long value));
371 extern void _bfd_evax_output_quad PARAMS ((bfd *abfd, uquad value));
372 extern void _bfd_evax_output_counted PARAMS ((bfd *abfd, char *value));
373 extern void _bfd_evax_output_dump PARAMS ((bfd *abfd, unsigned char *data,
374 int length));
375 extern void _bfd_evax_output_fill PARAMS ((bfd *abfd, int value, int length));
376 extern char *_bfd_get_vms_time_string PARAMS ((void));
377 extern char *_bfd_evax_basename PARAMS ((char *name));
378
379 #endif /* EVAX_H */
This page took 0.038451 seconds and 5 git commands to generate.