1 /* ECOFF support on Alpha machines.
2 coff/ecoff.h must be included before this file. */
4 /********************** FILE HEADER **********************/
6 struct external_filehdr
{
7 unsigned char f_magic
[2]; /* magic number */
8 unsigned char f_nscns
[2]; /* number of sections */
9 unsigned char f_timdat
[4]; /* time & date stamp */
10 unsigned char f_symptr
[8]; /* file pointer to symtab */
11 unsigned char f_nsyms
[4]; /* number of symtab entries */
12 unsigned char f_opthdr
[2]; /* sizeof(optional hdr) */
13 unsigned char f_flags
[2]; /* flags */
16 /* Magic numbers are defined in coff/ecoff.h. */
17 #define ALPHA_ECOFF_BADMAG(x) \
18 ((x).f_magic != ALPHA_MAGIC && (x).f_magic != ALPHA_MAGIC_BSD)
20 /* The object type is encoded in the f_flags. */
21 #define F_ALPHA_OBJECT_TYPE_MASK 0x3000
22 #define F_ALPHA_NO_SHARED 0x1000
23 #define F_ALPHA_SHARABLE 0x2000
24 #define F_ALPHA_CALL_SHARED 0x3000
26 #define FILHDR struct external_filehdr
29 /********************** AOUT "OPTIONAL HEADER" **********************/
32 typedef struct external_aouthdr
34 unsigned char magic
[2]; /* type of file */
35 unsigned char vstamp
[2]; /* version stamp */
36 unsigned char bldrev
[2]; /* ?? */
37 unsigned char padding
[2]; /* pad to quadword boundary */
38 unsigned char tsize
[8]; /* text size in bytes */
39 unsigned char dsize
[8]; /* initialized data " " */
40 unsigned char bsize
[8]; /* uninitialized data " " */
41 unsigned char entry
[8]; /* entry pt. */
42 unsigned char text_start
[8]; /* base of text used for this file */
43 unsigned char data_start
[8]; /* base of data used for this file */
44 unsigned char bss_start
[8]; /* base of bss used for this file */
45 unsigned char gprmask
[4]; /* bitmask of general registers used */
46 unsigned char fprmask
[4]; /* bitmask of floating point registers used */
47 unsigned char gp_value
[8]; /* value for gp register */
50 /* compute size of a header */
55 /********************** SECTION HEADER **********************/
57 struct external_scnhdr
{
58 unsigned char s_name
[8]; /* section name */
59 unsigned char s_paddr
[8]; /* physical address, aliased s_nlib */
60 unsigned char s_vaddr
[8]; /* virtual address */
61 unsigned char s_size
[8]; /* section size */
62 unsigned char s_scnptr
[8]; /* file ptr to raw data for section */
63 unsigned char s_relptr
[8]; /* file ptr to relocation */
64 unsigned char s_lnnoptr
[8]; /* file ptr to line numbers */
65 unsigned char s_nreloc
[2]; /* number of relocation entries */
66 unsigned char s_nlnno
[2]; /* number of line number entries*/
67 unsigned char s_flags
[4]; /* flags */
70 #define SCNHDR struct external_scnhdr
73 /********************** RELOCATION DIRECTIVES **********************/
75 struct external_reloc
{
76 unsigned char r_vaddr
[8];
77 unsigned char r_symndx
[4];
78 unsigned char r_bits
[4];
81 #define RELOC struct external_reloc
84 /* Constants to unpack the r_bits field. The Alpha seems to always be
85 little endian, so I haven't bothered to define big endian variants
88 #define RELOC_BITS0_TYPE_LITTLE 0xff
89 #define RELOC_BITS0_TYPE_SH_LITTLE 0
91 #define RELOC_BITS1_EXTERN_LITTLE 0x01
93 #define RELOC_BITS1_OFFSET_LITTLE 0x7e
94 #define RELOC_BITS1_OFFSET_SH_LITTLE 1
96 #define RELOC_BITS1_RESERVED_LITTLE 0x80
97 #define RELOC_BITS1_RESERVED_SH_LITTLE 7
98 #define RELOC_BITS2_RESERVED_LITTLE 0xff
99 #define RELOC_BITS2_RESERVED_SH_LEFT_LITTLE 1
100 #define RELOC_BITS3_RESERVED_LITTLE 0x03
101 #define RELOC_BITS3_RESERVED_SH_LEFT_LITTLE 9
103 #define RELOC_BITS3_SIZE_LITTLE 0xfc
104 #define RELOC_BITS3_SIZE_SH_LITTLE 2
106 /* The r_type field in a reloc is one of the following values. */
107 #define ALPHA_R_IGNORE 0
108 #define ALPHA_R_REFLONG 1
109 #define ALPHA_R_REFQUAD 2
110 #define ALPHA_R_GPREL32 3
111 #define ALPHA_R_LITERAL 4
112 #define ALPHA_R_LITUSE 5
113 #define ALPHA_R_GPDISP 6
114 #define ALPHA_R_BRADDR 7
115 #define ALPHA_R_HINT 8
116 #define ALPHA_R_SREL16 9
117 #define ALPHA_R_SREL32 10
118 #define ALPHA_R_SREL64 11
119 #define ALPHA_R_OP_PUSH 12
120 #define ALPHA_R_OP_STORE 13
121 #define ALPHA_R_OP_PSUB 14
122 #define ALPHA_R_OP_PRSHIFT 15
123 #define ALPHA_R_GPVALUE 16
124 #define ALPHA_R_GPRELHIGH 17
125 #define ALPHA_R_GPRELLOW 18
126 #define ALPHA_R_IMMED 19
128 /* Overloaded reloc value used by Net- and OpenBSD. */
129 #define ALPHA_R_LITERALSLEAZY 17
131 /* With ALPHA_R_LITUSE, the r_size field is one of the following values. */
132 #define ALPHA_R_LU_BASE 1
133 #define ALPHA_R_LU_BYTOFF 2
134 #define ALPHA_R_LU_JSR 3
136 /* With ALPHA_R_IMMED, the r_size field is one of the following values. */
137 #define ALPHA_R_IMMED_GP_16 1
138 #define ALPHA_R_IMMED_GP_HI32 2
139 #define ALPHA_R_IMMED_SCN_HI32 3
140 #define ALPHA_R_IMMED_BR_HI32 4
141 #define ALPHA_R_IMMED_LO32 5
143 /********************** SYMBOLIC INFORMATION **********************/
145 /* Written by John Gilmore. */
147 /* ECOFF uses COFF-like section structures, but its own symbol format.
148 This file defines the symbol format in fields whose size and alignment
149 will not vary on different host systems. */
151 /* File header as a set of bytes */
154 unsigned char h_magic
[2];
155 unsigned char h_vstamp
[2];
156 unsigned char h_ilineMax
[4];
157 unsigned char h_idnMax
[4];
158 unsigned char h_ipdMax
[4];
159 unsigned char h_isymMax
[4];
160 unsigned char h_ioptMax
[4];
161 unsigned char h_iauxMax
[4];
162 unsigned char h_issMax
[4];
163 unsigned char h_issExtMax
[4];
164 unsigned char h_ifdMax
[4];
165 unsigned char h_crfd
[4];
166 unsigned char h_iextMax
[4];
167 unsigned char h_cbLine
[8];
168 unsigned char h_cbLineOffset
[8];
169 unsigned char h_cbDnOffset
[8];
170 unsigned char h_cbPdOffset
[8];
171 unsigned char h_cbSymOffset
[8];
172 unsigned char h_cbOptOffset
[8];
173 unsigned char h_cbAuxOffset
[8];
174 unsigned char h_cbSsOffset
[8];
175 unsigned char h_cbSsExtOffset
[8];
176 unsigned char h_cbFdOffset
[8];
177 unsigned char h_cbRfdOffset
[8];
178 unsigned char h_cbExtOffset
[8];
181 /* File descriptor external record */
184 unsigned char f_adr
[8];
185 unsigned char f_cbLineOffset
[8];
186 unsigned char f_cbLine
[8];
187 unsigned char f_cbSs
[8];
188 unsigned char f_rss
[4];
189 unsigned char f_issBase
[4];
190 unsigned char f_isymBase
[4];
191 unsigned char f_csym
[4];
192 unsigned char f_ilineBase
[4];
193 unsigned char f_cline
[4];
194 unsigned char f_ioptBase
[4];
195 unsigned char f_copt
[4];
196 unsigned char f_ipdFirst
[4];
197 unsigned char f_cpd
[4];
198 unsigned char f_iauxBase
[4];
199 unsigned char f_caux
[4];
200 unsigned char f_rfdBase
[4];
201 unsigned char f_crfd
[4];
202 unsigned char f_bits1
[1];
203 unsigned char f_bits2
[3];
204 unsigned char f_padding
[4];
207 #define FDR_BITS1_LANG_BIG 0xF8
208 #define FDR_BITS1_LANG_SH_BIG 3
209 #define FDR_BITS1_LANG_LITTLE 0x1F
210 #define FDR_BITS1_LANG_SH_LITTLE 0
212 #define FDR_BITS1_FMERGE_BIG 0x04
213 #define FDR_BITS1_FMERGE_LITTLE 0x20
215 #define FDR_BITS1_FREADIN_BIG 0x02
216 #define FDR_BITS1_FREADIN_LITTLE 0x40
218 #define FDR_BITS1_FBIGENDIAN_BIG 0x01
219 #define FDR_BITS1_FBIGENDIAN_LITTLE 0x80
221 #define FDR_BITS2_GLEVEL_BIG 0xC0
222 #define FDR_BITS2_GLEVEL_SH_BIG 6
223 #define FDR_BITS2_GLEVEL_LITTLE 0x03
224 #define FDR_BITS2_GLEVEL_SH_LITTLE 0
226 /* We ignore the `reserved' field in bits2. */
228 /* Procedure descriptor external record */
231 unsigned char p_adr
[8];
232 unsigned char p_cbLineOffset
[8];
233 unsigned char p_isym
[4];
234 unsigned char p_iline
[4];
235 unsigned char p_regmask
[4];
236 unsigned char p_regoffset
[4];
237 unsigned char p_iopt
[4];
238 unsigned char p_fregmask
[4];
239 unsigned char p_fregoffset
[4];
240 unsigned char p_frameoffset
[4];
241 unsigned char p_lnLow
[4];
242 unsigned char p_lnHigh
[4];
243 unsigned char p_gp_prologue
[1];
244 unsigned char p_bits1
[1];
245 unsigned char p_bits2
[1];
246 unsigned char p_localoff
[1];
247 unsigned char p_framereg
[2];
248 unsigned char p_pcreg
[2];
251 #define PDR_BITS1_GP_USED_BIG 0x80
252 #define PDR_BITS1_REG_FRAME_BIG 0x40
253 #define PDR_BITS1_PROF_BIG 0x20
254 #define PDR_BITS1_RESERVED_BIG 0x1f
255 #define PDR_BITS1_RESERVED_SH_LEFT_BIG 8
256 #define PDR_BITS2_RESERVED_BIG 0xff
257 #define PDR_BITS2_RESERVED_SH_BIG 0
259 #define PDR_BITS1_GP_USED_LITTLE 0x01
260 #define PDR_BITS1_REG_FRAME_LITTLE 0x02
261 #define PDR_BITS1_PROF_LITTLE 0x04
262 #define PDR_BITS1_RESERVED_LITTLE 0xf8
263 #define PDR_BITS1_RESERVED_SH_LITTLE 3
264 #define PDR_BITS2_RESERVED_LITTLE 0xff
265 #define PDR_BITS2_RESERVED_SH_LEFT_LITTLE 5
270 unsigned char l_line
[4];
273 /* Symbol external record */
276 unsigned char s_value
[8];
277 unsigned char s_iss
[4];
278 unsigned char s_bits1
[1];
279 unsigned char s_bits2
[1];
280 unsigned char s_bits3
[1];
281 unsigned char s_bits4
[1];
284 #define SYM_BITS1_ST_BIG 0xFC
285 #define SYM_BITS1_ST_SH_BIG 2
286 #define SYM_BITS1_ST_LITTLE 0x3F
287 #define SYM_BITS1_ST_SH_LITTLE 0
289 #define SYM_BITS1_SC_BIG 0x03
290 #define SYM_BITS1_SC_SH_LEFT_BIG 3
291 #define SYM_BITS1_SC_LITTLE 0xC0
292 #define SYM_BITS1_SC_SH_LITTLE 6
294 #define SYM_BITS2_SC_BIG 0xE0
295 #define SYM_BITS2_SC_SH_BIG 5
296 #define SYM_BITS2_SC_LITTLE 0x07
297 #define SYM_BITS2_SC_SH_LEFT_LITTLE 2
299 #define SYM_BITS2_RESERVED_BIG 0x10
300 #define SYM_BITS2_RESERVED_LITTLE 0x08
302 #define SYM_BITS2_INDEX_BIG 0x0F
303 #define SYM_BITS2_INDEX_SH_LEFT_BIG 16
304 #define SYM_BITS2_INDEX_LITTLE 0xF0
305 #define SYM_BITS2_INDEX_SH_LITTLE 4
307 #define SYM_BITS3_INDEX_SH_LEFT_BIG 8
308 #define SYM_BITS3_INDEX_SH_LEFT_LITTLE 4
310 #define SYM_BITS4_INDEX_SH_LEFT_BIG 0
311 #define SYM_BITS4_INDEX_SH_LEFT_LITTLE 12
313 /* External symbol external record */
316 struct sym_ext es_asym
;
317 unsigned char es_bits1
[1];
318 unsigned char es_bits2
[3];
319 unsigned char es_ifd
[4];
322 #define EXT_BITS1_JMPTBL_BIG 0x80
323 #define EXT_BITS1_JMPTBL_LITTLE 0x01
325 #define EXT_BITS1_COBOL_MAIN_BIG 0x40
326 #define EXT_BITS1_COBOL_MAIN_LITTLE 0x02
328 #define EXT_BITS1_WEAKEXT_BIG 0x20
329 #define EXT_BITS1_WEAKEXT_LITTLE 0x04
331 /* Dense numbers external record */
334 unsigned char d_rfd
[4];
335 unsigned char d_index
[4];
338 /* Relative file descriptor */
341 unsigned char rfd
[4];
344 /* Optimizer symbol external record */
347 unsigned char o_bits1
[1];
348 unsigned char o_bits2
[1];
349 unsigned char o_bits3
[1];
350 unsigned char o_bits4
[1];
351 struct rndx_ext o_rndx
;
352 unsigned char o_offset
[4];
355 #define OPT_BITS2_VALUE_SH_LEFT_BIG 16
356 #define OPT_BITS2_VALUE_SH_LEFT_LITTLE 0
358 #define OPT_BITS3_VALUE_SH_LEFT_BIG 8
359 #define OPT_BITS3_VALUE_SH_LEFT_LITTLE 8
361 #define OPT_BITS4_VALUE_SH_LEFT_BIG 0
362 #define OPT_BITS4_VALUE_SH_LEFT_LITTLE 16