]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/binutils/include/coff/alpha.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / binutils / include / coff / alpha.h
1 /* ECOFF support on Alpha machines.
2    coff/ecoff.h must be included before this file.
3
4    Copyright 2001, 2005 Free Software Foundation, Inc.
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
19    
20 /********************** FILE HEADER **********************/
21
22 struct external_filehdr
23 {
24   unsigned char f_magic[2];     /* magic number                 */
25   unsigned char f_nscns[2];     /* number of sections           */
26   unsigned char f_timdat[4];    /* time & date stamp            */
27   unsigned char f_symptr[8];    /* file pointer to symtab       */
28   unsigned char f_nsyms[4];     /* number of symtab entries     */
29   unsigned char f_opthdr[2];    /* sizeof(optional hdr)         */
30   unsigned char f_flags[2];     /* flags                        */
31 };
32
33 /* Magic numbers are defined in coff/ecoff.h.  */
34 #define ALPHA_ECOFF_BADMAG(x) \
35   ((x).f_magic != ALPHA_MAGIC && (x).f_magic != ALPHA_MAGIC_BSD)
36
37 #define ALPHA_ECOFF_COMPRESSEDMAG(x) \
38   ((x).f_magic == ALPHA_MAGIC_COMPRESSED)
39
40 /* The object type is encoded in the f_flags.  */
41 #define F_ALPHA_OBJECT_TYPE_MASK        0x3000
42 #define F_ALPHA_NO_SHARED               0x1000
43 #define F_ALPHA_SHARABLE                0x2000
44 #define F_ALPHA_CALL_SHARED             0x3000
45
46 #define FILHDR  struct external_filehdr
47 #define FILHSZ  24
48
49 /********************** AOUT "OPTIONAL HEADER" **********************/
50
51 typedef struct external_aouthdr
52 {
53   unsigned char magic[2];       /* type of file                         */
54   unsigned char vstamp[2];      /* version stamp                        */
55   unsigned char bldrev[2];      /* ?? */
56   unsigned char padding[2];     /* pad to quadword boundary             */
57   unsigned char tsize[8];       /* text size in bytes                   */
58   unsigned char dsize[8];       /* initialized data "  "                */
59   unsigned char bsize[8];       /* uninitialized data "   "             */
60   unsigned char entry[8];       /* entry pt.                            */
61   unsigned char text_start[8];  /* base of text used for this file */
62   unsigned char data_start[8];  /* base of data used for this file */
63   unsigned char bss_start[8];   /* base of bss used for this file */
64   unsigned char gprmask[4];     /* bitmask of general registers used */
65   unsigned char fprmask[4];     /* bitmask of floating point registers used */
66   unsigned char gp_value[8];    /* value for gp register */
67 } AOUTHDR;
68
69 /* compute size of a header */
70
71 #define AOUTSZ 80
72 #define AOUTHDRSZ 80
73
74 /********************** SECTION HEADER **********************/
75
76 struct external_scnhdr
77 {
78   unsigned char s_name[8];      /* section name                 */
79   unsigned char s_paddr[8];     /* physical address, aliased s_nlib */
80   unsigned char s_vaddr[8];     /* virtual address              */
81   unsigned char s_size[8];      /* section size                 */
82   unsigned char s_scnptr[8];    /* file ptr to raw data for section */
83   unsigned char s_relptr[8];    /* file ptr to relocation       */
84   unsigned char s_lnnoptr[8];   /* file ptr to line numbers     */
85   unsigned char s_nreloc[2];    /* number of relocation entries */
86   unsigned char s_nlnno[2];     /* number of line number entries*/
87   unsigned char s_flags[4];     /* flags                        */
88 };
89
90 #define SCNHDR  struct external_scnhdr
91 #define SCNHSZ  64
92
93 /********************** RELOCATION DIRECTIVES **********************/
94
95 struct external_reloc 
96 {
97   unsigned char r_vaddr[8];
98   unsigned char r_symndx[4];
99   unsigned char r_bits[4];
100 };
101
102 #define RELOC struct external_reloc
103 #define RELSZ 16
104
105 /* Constants to unpack the r_bits field.  The Alpha seems to always be
106    little endian, so I haven't bothered to define big endian variants
107    of these.  */
108
109 #define RELOC_BITS0_TYPE_LITTLE                 0xff
110 #define RELOC_BITS0_TYPE_SH_LITTLE              0
111
112 #define RELOC_BITS1_EXTERN_LITTLE               0x01
113
114 #define RELOC_BITS1_OFFSET_LITTLE               0x7e
115 #define RELOC_BITS1_OFFSET_SH_LITTLE            1
116
117 #define RELOC_BITS1_RESERVED_LITTLE             0x80
118 #define RELOC_BITS1_RESERVED_SH_LITTLE          7
119 #define RELOC_BITS2_RESERVED_LITTLE             0xff
120 #define RELOC_BITS2_RESERVED_SH_LEFT_LITTLE     1
121 #define RELOC_BITS3_RESERVED_LITTLE             0x03
122 #define RELOC_BITS3_RESERVED_SH_LEFT_LITTLE     9
123
124 #define RELOC_BITS3_SIZE_LITTLE                 0xfc
125 #define RELOC_BITS3_SIZE_SH_LITTLE              2
126
127 /* The r_type field in a reloc is one of the following values.  */
128 #define ALPHA_R_IGNORE          0
129 #define ALPHA_R_REFLONG         1
130 #define ALPHA_R_REFQUAD         2
131 #define ALPHA_R_GPREL32         3
132 #define ALPHA_R_LITERAL         4
133 #define ALPHA_R_LITUSE          5
134 #define ALPHA_R_GPDISP          6
135 #define ALPHA_R_BRADDR          7
136 #define ALPHA_R_HINT            8
137 #define ALPHA_R_SREL16          9
138 #define ALPHA_R_SREL32         10
139 #define ALPHA_R_SREL64         11
140 #define ALPHA_R_OP_PUSH        12
141 #define ALPHA_R_OP_STORE       13
142 #define ALPHA_R_OP_PSUB        14
143 #define ALPHA_R_OP_PRSHIFT     15
144 #define ALPHA_R_GPVALUE        16
145 #define ALPHA_R_GPRELHIGH      17
146 #define ALPHA_R_GPRELLOW       18
147 #define ALPHA_R_IMMED          19
148
149 /* Overloaded reloc value used by Net- and OpenBSD.  */
150 #define ALPHA_R_LITERALSLEAZY  17
151
152 /* With ALPHA_R_LITUSE, the r_size field is one of the following values.  */
153 #define ALPHA_R_LU_BASE         1
154 #define ALPHA_R_LU_BYTOFF       2
155 #define ALPHA_R_LU_JSR          3
156
157 /* With ALPHA_R_IMMED, the r_size field is one of the following values.  */
158 #define ALPHA_R_IMMED_GP_16     1
159 #define ALPHA_R_IMMED_GP_HI32   2
160 #define ALPHA_R_IMMED_SCN_HI32  3
161 #define ALPHA_R_IMMED_BR_HI32   4
162 #define ALPHA_R_IMMED_LO32      5
163
164 /********************** SYMBOLIC INFORMATION **********************/
165
166 /* Written by John Gilmore.  */
167
168 /* ECOFF uses COFF-like section structures, but its own symbol format.
169    This file defines the symbol format in fields whose size and alignment
170    will not vary on different host systems.  */
171
172 /* File header as a set of bytes */
173
174 struct hdr_ext
175 {
176         unsigned char   h_magic[2];
177         unsigned char   h_vstamp[2];
178         unsigned char   h_ilineMax[4];
179         unsigned char   h_idnMax[4];
180         unsigned char   h_ipdMax[4];
181         unsigned char   h_isymMax[4];
182         unsigned char   h_ioptMax[4];
183         unsigned char   h_iauxMax[4];
184         unsigned char   h_issMax[4];
185         unsigned char   h_issExtMax[4];
186         unsigned char   h_ifdMax[4];
187         unsigned char   h_crfd[4];
188         unsigned char   h_iextMax[4];
189         unsigned char   h_cbLine[8];
190         unsigned char   h_cbLineOffset[8];
191         unsigned char   h_cbDnOffset[8];
192         unsigned char   h_cbPdOffset[8];
193         unsigned char   h_cbSymOffset[8];
194         unsigned char   h_cbOptOffset[8];
195         unsigned char   h_cbAuxOffset[8];
196         unsigned char   h_cbSsOffset[8];
197         unsigned char   h_cbSsExtOffset[8];
198         unsigned char   h_cbFdOffset[8];
199         unsigned char   h_cbRfdOffset[8];
200         unsigned char   h_cbExtOffset[8];
201 };
202
203 /* File descriptor external record */
204
205 struct fdr_ext
206 {
207         unsigned char   f_adr[8];
208         unsigned char   f_cbLineOffset[8];
209         unsigned char   f_cbLine[8];
210         unsigned char   f_cbSs[8];
211         unsigned char   f_rss[4];
212         unsigned char   f_issBase[4];
213         unsigned char   f_isymBase[4];
214         unsigned char   f_csym[4];
215         unsigned char   f_ilineBase[4];
216         unsigned char   f_cline[4];
217         unsigned char   f_ioptBase[4];
218         unsigned char   f_copt[4];
219         unsigned char   f_ipdFirst[4];
220         unsigned char   f_cpd[4];
221         unsigned char   f_iauxBase[4];
222         unsigned char   f_caux[4];
223         unsigned char   f_rfdBase[4];
224         unsigned char   f_crfd[4];
225         unsigned char   f_bits1[1];
226         unsigned char   f_bits2[3];
227         unsigned char   f_padding[4];
228 };
229
230 #define FDR_BITS1_LANG_BIG              0xF8
231 #define FDR_BITS1_LANG_SH_BIG           3
232 #define FDR_BITS1_LANG_LITTLE           0x1F
233 #define FDR_BITS1_LANG_SH_LITTLE        0
234
235 #define FDR_BITS1_FMERGE_BIG            0x04
236 #define FDR_BITS1_FMERGE_LITTLE         0x20
237
238 #define FDR_BITS1_FREADIN_BIG           0x02
239 #define FDR_BITS1_FREADIN_LITTLE        0x40
240
241 #define FDR_BITS1_FBIGENDIAN_BIG        0x01
242 #define FDR_BITS1_FBIGENDIAN_LITTLE     0x80
243
244 #define FDR_BITS2_GLEVEL_BIG            0xC0
245 #define FDR_BITS2_GLEVEL_SH_BIG         6
246 #define FDR_BITS2_GLEVEL_LITTLE         0x03
247 #define FDR_BITS2_GLEVEL_SH_LITTLE      0
248
249 /* We ignore the `reserved' field in bits2. */
250
251 /* Procedure descriptor external record */
252
253 struct pdr_ext {
254         unsigned char   p_adr[8];
255         unsigned char   p_cbLineOffset[8];
256         unsigned char   p_isym[4];
257         unsigned char   p_iline[4];
258         unsigned char   p_regmask[4];
259         unsigned char   p_regoffset[4];
260         unsigned char   p_iopt[4];
261         unsigned char   p_fregmask[4];
262         unsigned char   p_fregoffset[4];
263         unsigned char   p_frameoffset[4];
264         unsigned char   p_lnLow[4];
265         unsigned char   p_lnHigh[4];
266         unsigned char   p_gp_prologue[1];
267         unsigned char   p_bits1[1];
268         unsigned char   p_bits2[1];
269         unsigned char   p_localoff[1];
270         unsigned char   p_framereg[2];
271         unsigned char   p_pcreg[2];
272 };
273
274 #define PDR_BITS1_GP_USED_BIG           0x80
275 #define PDR_BITS1_REG_FRAME_BIG         0x40
276 #define PDR_BITS1_PROF_BIG              0x20
277 #define PDR_BITS1_RESERVED_BIG          0x1f
278 #define PDR_BITS1_RESERVED_SH_LEFT_BIG  8
279 #define PDR_BITS2_RESERVED_BIG          0xff
280 #define PDR_BITS2_RESERVED_SH_BIG       0
281
282 #define PDR_BITS1_GP_USED_LITTLE        0x01
283 #define PDR_BITS1_REG_FRAME_LITTLE      0x02
284 #define PDR_BITS1_PROF_LITTLE           0x04
285 #define PDR_BITS1_RESERVED_LITTLE       0xf8
286 #define PDR_BITS1_RESERVED_SH_LITTLE    3
287 #define PDR_BITS2_RESERVED_LITTLE       0xff
288 #define PDR_BITS2_RESERVED_SH_LEFT_LITTLE 5
289
290 /* Line numbers */
291
292 struct line_ext {
293         unsigned char   l_line[4];
294 };
295
296 /* Symbol external record */
297
298 struct sym_ext {
299         unsigned char   s_value[8];
300         unsigned char   s_iss[4];
301         unsigned char   s_bits1[1];
302         unsigned char   s_bits2[1];
303         unsigned char   s_bits3[1];
304         unsigned char   s_bits4[1];
305 };
306
307 #define SYM_BITS1_ST_BIG                0xFC
308 #define SYM_BITS1_ST_SH_BIG             2
309 #define SYM_BITS1_ST_LITTLE             0x3F
310 #define SYM_BITS1_ST_SH_LITTLE          0
311
312 #define SYM_BITS1_SC_BIG                0x03
313 #define SYM_BITS1_SC_SH_LEFT_BIG        3
314 #define SYM_BITS1_SC_LITTLE             0xC0
315 #define SYM_BITS1_SC_SH_LITTLE          6
316
317 #define SYM_BITS2_SC_BIG                0xE0
318 #define SYM_BITS2_SC_SH_BIG             5
319 #define SYM_BITS2_SC_LITTLE             0x07
320 #define SYM_BITS2_SC_SH_LEFT_LITTLE     2
321
322 #define SYM_BITS2_RESERVED_BIG          0x10
323 #define SYM_BITS2_RESERVED_LITTLE       0x08
324
325 #define SYM_BITS2_INDEX_BIG             0x0F
326 #define SYM_BITS2_INDEX_SH_LEFT_BIG     16
327 #define SYM_BITS2_INDEX_LITTLE          0xF0
328 #define SYM_BITS2_INDEX_SH_LITTLE       4
329
330 #define SYM_BITS3_INDEX_SH_LEFT_BIG     8
331 #define SYM_BITS3_INDEX_SH_LEFT_LITTLE  4
332
333 #define SYM_BITS4_INDEX_SH_LEFT_BIG     0
334 #define SYM_BITS4_INDEX_SH_LEFT_LITTLE  12
335
336 /* External symbol external record */
337
338 struct ext_ext {
339         struct  sym_ext es_asym;
340         unsigned char   es_bits1[1];
341         unsigned char   es_bits2[3];
342         unsigned char   es_ifd[4];
343 };
344
345 #define EXT_BITS1_JMPTBL_BIG            0x80
346 #define EXT_BITS1_JMPTBL_LITTLE         0x01
347
348 #define EXT_BITS1_COBOL_MAIN_BIG        0x40
349 #define EXT_BITS1_COBOL_MAIN_LITTLE     0x02
350
351 #define EXT_BITS1_WEAKEXT_BIG           0x20
352 #define EXT_BITS1_WEAKEXT_LITTLE        0x04
353
354 /* Dense numbers external record */
355
356 struct dnr_ext {
357         unsigned char   d_rfd[4];
358         unsigned char   d_index[4];
359 };
360
361 /* Relative file descriptor */
362
363 struct rfd_ext {
364   unsigned char rfd[4];
365 };
366
367 /* Optimizer symbol external record */
368
369 struct opt_ext {
370   unsigned char o_bits1[1];
371   unsigned char o_bits2[1];
372   unsigned char o_bits3[1];
373   unsigned char o_bits4[1];
374   struct rndx_ext o_rndx;
375   unsigned char o_offset[4];
376 };
377
378 #define OPT_BITS2_VALUE_SH_LEFT_BIG     16
379 #define OPT_BITS2_VALUE_SH_LEFT_LITTLE  0
380
381 #define OPT_BITS3_VALUE_SH_LEFT_BIG     8
382 #define OPT_BITS3_VALUE_SH_LEFT_LITTLE  8
383
384 #define OPT_BITS4_VALUE_SH_LEFT_BIG     0
385 #define OPT_BITS4_VALUE_SH_LEFT_LITTLE  16