alpha.h revision 78828
133965Sjdp/* ECOFF support on Alpha machines.
278828Sobrien   coff/ecoff.h must be included before this file.
333965Sjdp
478828Sobrien   Copyright 2001 Free Software Foundation, Inc.
578828Sobrien
678828Sobrien   This program is free software; you can redistribute it and/or modify
778828Sobrien   it under the terms of the GNU General Public License as published by
878828Sobrien   the Free Software Foundation; either version 2 of the License, or
978828Sobrien   (at your option) any later version.
1078828Sobrien
1178828Sobrien   This program is distributed in the hope that it will be useful,
1278828Sobrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
1378828Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1478828Sobrien   GNU General Public License for more details.
1578828Sobrien
1678828Sobrien   You should have received a copy of the GNU General Public License
1778828Sobrien   along with this program; if not, write to the Free Software
1878828Sobrien   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
1978828Sobrien
2033965Sjdp/********************** FILE HEADER **********************/
2133965Sjdp
2233965Sjdpstruct external_filehdr {
2333965Sjdp  unsigned char f_magic[2];	/* magic number			*/
2433965Sjdp  unsigned char f_nscns[2];	/* number of sections		*/
2533965Sjdp  unsigned char f_timdat[4];	/* time & date stamp		*/
2633965Sjdp  unsigned char f_symptr[8];	/* file pointer to symtab	*/
2733965Sjdp  unsigned char f_nsyms[4];	/* number of symtab entries	*/
2833965Sjdp  unsigned char f_opthdr[2];	/* sizeof(optional hdr)		*/
2933965Sjdp  unsigned char f_flags[2];	/* flags			*/
3033965Sjdp};
3133965Sjdp
3233965Sjdp/* Magic numbers are defined in coff/ecoff.h.  */
3333965Sjdp#define ALPHA_ECOFF_BADMAG(x) \
3433965Sjdp  ((x).f_magic != ALPHA_MAGIC && (x).f_magic != ALPHA_MAGIC_BSD)
3533965Sjdp
3633965Sjdp/* The object type is encoded in the f_flags.  */
3733965Sjdp#define F_ALPHA_OBJECT_TYPE_MASK	0x3000
3833965Sjdp#define F_ALPHA_NO_SHARED		0x1000
3933965Sjdp#define F_ALPHA_SHARABLE		0x2000
4033965Sjdp#define F_ALPHA_CALL_SHARED		0x3000
4133965Sjdp
4233965Sjdp#define	FILHDR	struct external_filehdr
4333965Sjdp#define	FILHSZ	24
4433965Sjdp
4533965Sjdp/********************** AOUT "OPTIONAL HEADER" **********************/
4633965Sjdp
4733965Sjdp
4833965Sjdptypedef struct external_aouthdr
4933965Sjdp{
5033965Sjdp  unsigned char magic[2];	/* type of file				*/
5133965Sjdp  unsigned char	vstamp[2];	/* version stamp			*/
5233965Sjdp  unsigned char bldrev[2];	/* ?? */
5333965Sjdp  unsigned char padding[2];	/* pad to quadword boundary		*/
5433965Sjdp  unsigned char	tsize[8];	/* text size in bytes			*/
5533965Sjdp  unsigned char	dsize[8];	/* initialized data "  "		*/
5633965Sjdp  unsigned char	bsize[8];	/* uninitialized data "   "		*/
5733965Sjdp  unsigned char	entry[8];	/* entry pt.				*/
5833965Sjdp  unsigned char text_start[8];	/* base of text used for this file */
5933965Sjdp  unsigned char data_start[8];	/* base of data used for this file */
6033965Sjdp  unsigned char bss_start[8];	/* base of bss used for this file */
6133965Sjdp  unsigned char gprmask[4];	/* bitmask of general registers used */
6233965Sjdp  unsigned char fprmask[4];	/* bitmask of floating point registers used */
6333965Sjdp  unsigned char gp_value[8];	/* value for gp register */
6433965Sjdp} AOUTHDR;
6533965Sjdp
6633965Sjdp/* compute size of a header */
6733965Sjdp
6833965Sjdp#define AOUTSZ 80
6933965Sjdp#define AOUTHDRSZ 80
7033965Sjdp
7133965Sjdp/********************** SECTION HEADER **********************/
7233965Sjdp
7333965Sjdpstruct external_scnhdr {
7433965Sjdp  unsigned char	s_name[8];	/* section name			*/
7533965Sjdp  unsigned char	s_paddr[8];	/* physical address, aliased s_nlib */
7633965Sjdp  unsigned char	s_vaddr[8];	/* virtual address		*/
7733965Sjdp  unsigned char	s_size[8];	/* section size			*/
7833965Sjdp  unsigned char	s_scnptr[8];	/* file ptr to raw data for section */
7933965Sjdp  unsigned char	s_relptr[8];	/* file ptr to relocation	*/
8033965Sjdp  unsigned char	s_lnnoptr[8];	/* file ptr to line numbers	*/
8133965Sjdp  unsigned char	s_nreloc[2];	/* number of relocation entries	*/
8233965Sjdp  unsigned char	s_nlnno[2];	/* number of line number entries*/
8333965Sjdp  unsigned char	s_flags[4];	/* flags			*/
8433965Sjdp};
8533965Sjdp
8633965Sjdp#define	SCNHDR	struct external_scnhdr
8733965Sjdp#define	SCNHSZ	64
8833965Sjdp
8933965Sjdp/********************** RELOCATION DIRECTIVES **********************/
9033965Sjdp
9133965Sjdpstruct external_reloc {
9233965Sjdp  unsigned char r_vaddr[8];
9333965Sjdp  unsigned char r_symndx[4];
9433965Sjdp  unsigned char r_bits[4];
9533965Sjdp};
9633965Sjdp
9733965Sjdp#define RELOC struct external_reloc
9833965Sjdp#define RELSZ 16
9933965Sjdp
10033965Sjdp/* Constants to unpack the r_bits field.  The Alpha seems to always be
10133965Sjdp   little endian, so I haven't bothered to define big endian variants
10233965Sjdp   of these.  */
10333965Sjdp
10433965Sjdp#define RELOC_BITS0_TYPE_LITTLE			0xff
10533965Sjdp#define RELOC_BITS0_TYPE_SH_LITTLE		0
10633965Sjdp
10733965Sjdp#define RELOC_BITS1_EXTERN_LITTLE		0x01
10833965Sjdp
10933965Sjdp#define RELOC_BITS1_OFFSET_LITTLE		0x7e
11033965Sjdp#define RELOC_BITS1_OFFSET_SH_LITTLE		1
11133965Sjdp
11233965Sjdp#define RELOC_BITS1_RESERVED_LITTLE		0x80
11333965Sjdp#define RELOC_BITS1_RESERVED_SH_LITTLE		7
11433965Sjdp#define RELOC_BITS2_RESERVED_LITTLE		0xff
11533965Sjdp#define RELOC_BITS2_RESERVED_SH_LEFT_LITTLE	1
11633965Sjdp#define RELOC_BITS3_RESERVED_LITTLE		0x03
11733965Sjdp#define RELOC_BITS3_RESERVED_SH_LEFT_LITTLE	9
11833965Sjdp
11933965Sjdp#define RELOC_BITS3_SIZE_LITTLE			0xfc
12033965Sjdp#define RELOC_BITS3_SIZE_SH_LITTLE		2
12133965Sjdp
12233965Sjdp/* The r_type field in a reloc is one of the following values.  */
12333965Sjdp#define ALPHA_R_IGNORE		0
12433965Sjdp#define ALPHA_R_REFLONG		1
12533965Sjdp#define ALPHA_R_REFQUAD		2
12633965Sjdp#define ALPHA_R_GPREL32		3
12733965Sjdp#define ALPHA_R_LITERAL		4
12833965Sjdp#define ALPHA_R_LITUSE		5
12933965Sjdp#define ALPHA_R_GPDISP		6
13033965Sjdp#define ALPHA_R_BRADDR		7
13133965Sjdp#define ALPHA_R_HINT		8
13233965Sjdp#define ALPHA_R_SREL16		9
13333965Sjdp#define ALPHA_R_SREL32	       10
13433965Sjdp#define ALPHA_R_SREL64	       11
13533965Sjdp#define ALPHA_R_OP_PUSH	       12
13633965Sjdp#define ALPHA_R_OP_STORE       13
13733965Sjdp#define ALPHA_R_OP_PSUB	       14
13833965Sjdp#define ALPHA_R_OP_PRSHIFT     15
13933965Sjdp#define ALPHA_R_GPVALUE	       16
14033965Sjdp#define ALPHA_R_GPRELHIGH      17
14133965Sjdp#define ALPHA_R_GPRELLOW       18
14233965Sjdp#define ALPHA_R_IMMED          19
14333965Sjdp
14433965Sjdp/* Overloaded reloc value used by Net- and OpenBSD.  */
14533965Sjdp#define ALPHA_R_LITERALSLEAZY  17
14633965Sjdp
14733965Sjdp/* With ALPHA_R_LITUSE, the r_size field is one of the following values.  */
14833965Sjdp#define ALPHA_R_LU_BASE         1
14933965Sjdp#define ALPHA_R_LU_BYTOFF       2
15033965Sjdp#define ALPHA_R_LU_JSR          3
15133965Sjdp
15233965Sjdp/* With ALPHA_R_IMMED, the r_size field is one of the following values.  */
15333965Sjdp#define ALPHA_R_IMMED_GP_16     1
15433965Sjdp#define ALPHA_R_IMMED_GP_HI32   2
15533965Sjdp#define ALPHA_R_IMMED_SCN_HI32  3
15633965Sjdp#define ALPHA_R_IMMED_BR_HI32   4
15733965Sjdp#define ALPHA_R_IMMED_LO32      5
15833965Sjdp
15933965Sjdp/********************** SYMBOLIC INFORMATION **********************/
16033965Sjdp
16133965Sjdp/* Written by John Gilmore.  */
16233965Sjdp
16333965Sjdp/* ECOFF uses COFF-like section structures, but its own symbol format.
16433965Sjdp   This file defines the symbol format in fields whose size and alignment
16533965Sjdp   will not vary on different host systems.  */
16633965Sjdp
16733965Sjdp/* File header as a set of bytes */
16833965Sjdp
16933965Sjdpstruct hdr_ext {
17033965Sjdp	unsigned char 	h_magic[2];
17133965Sjdp	unsigned char	h_vstamp[2];
17233965Sjdp	unsigned char	h_ilineMax[4];
17333965Sjdp	unsigned char	h_idnMax[4];
17433965Sjdp	unsigned char	h_ipdMax[4];
17533965Sjdp	unsigned char	h_isymMax[4];
17633965Sjdp	unsigned char	h_ioptMax[4];
17733965Sjdp	unsigned char	h_iauxMax[4];
17833965Sjdp	unsigned char	h_issMax[4];
17933965Sjdp	unsigned char	h_issExtMax[4];
18033965Sjdp	unsigned char	h_ifdMax[4];
18133965Sjdp	unsigned char	h_crfd[4];
18233965Sjdp	unsigned char	h_iextMax[4];
18333965Sjdp	unsigned char	h_cbLine[8];
18433965Sjdp	unsigned char	h_cbLineOffset[8];
18533965Sjdp	unsigned char	h_cbDnOffset[8];
18633965Sjdp	unsigned char	h_cbPdOffset[8];
18733965Sjdp	unsigned char	h_cbSymOffset[8];
18833965Sjdp	unsigned char	h_cbOptOffset[8];
18933965Sjdp	unsigned char	h_cbAuxOffset[8];
19033965Sjdp	unsigned char	h_cbSsOffset[8];
19133965Sjdp	unsigned char	h_cbSsExtOffset[8];
19233965Sjdp	unsigned char	h_cbFdOffset[8];
19333965Sjdp	unsigned char	h_cbRfdOffset[8];
19433965Sjdp	unsigned char	h_cbExtOffset[8];
19533965Sjdp};
19633965Sjdp
19733965Sjdp/* File descriptor external record */
19833965Sjdp
19933965Sjdpstruct fdr_ext {
20033965Sjdp	unsigned char	f_adr[8];
20133965Sjdp	unsigned char	f_cbLineOffset[8];
20233965Sjdp	unsigned char	f_cbLine[8];
20333965Sjdp	unsigned char	f_cbSs[8];
20433965Sjdp	unsigned char	f_rss[4];
20533965Sjdp	unsigned char	f_issBase[4];
20633965Sjdp	unsigned char	f_isymBase[4];
20733965Sjdp	unsigned char	f_csym[4];
20833965Sjdp	unsigned char	f_ilineBase[4];
20933965Sjdp	unsigned char	f_cline[4];
21033965Sjdp	unsigned char	f_ioptBase[4];
21133965Sjdp	unsigned char	f_copt[4];
21233965Sjdp	unsigned char	f_ipdFirst[4];
21333965Sjdp	unsigned char	f_cpd[4];
21433965Sjdp	unsigned char	f_iauxBase[4];
21533965Sjdp	unsigned char	f_caux[4];
21633965Sjdp	unsigned char	f_rfdBase[4];
21733965Sjdp	unsigned char	f_crfd[4];
21833965Sjdp	unsigned char	f_bits1[1];
21933965Sjdp	unsigned char	f_bits2[3];
22033965Sjdp	unsigned char	f_padding[4];
22133965Sjdp};
22233965Sjdp
22333965Sjdp#define	FDR_BITS1_LANG_BIG		0xF8
22433965Sjdp#define	FDR_BITS1_LANG_SH_BIG		3
22533965Sjdp#define	FDR_BITS1_LANG_LITTLE		0x1F
22633965Sjdp#define	FDR_BITS1_LANG_SH_LITTLE	0
22733965Sjdp
22833965Sjdp#define	FDR_BITS1_FMERGE_BIG		0x04
22933965Sjdp#define	FDR_BITS1_FMERGE_LITTLE		0x20
23033965Sjdp
23133965Sjdp#define	FDR_BITS1_FREADIN_BIG		0x02
23233965Sjdp#define	FDR_BITS1_FREADIN_LITTLE	0x40
23333965Sjdp
23433965Sjdp#define	FDR_BITS1_FBIGENDIAN_BIG	0x01
23533965Sjdp#define	FDR_BITS1_FBIGENDIAN_LITTLE	0x80
23633965Sjdp
23733965Sjdp#define	FDR_BITS2_GLEVEL_BIG		0xC0
23833965Sjdp#define	FDR_BITS2_GLEVEL_SH_BIG		6
23933965Sjdp#define	FDR_BITS2_GLEVEL_LITTLE		0x03
24033965Sjdp#define	FDR_BITS2_GLEVEL_SH_LITTLE	0
24133965Sjdp
24233965Sjdp/* We ignore the `reserved' field in bits2. */
24333965Sjdp
24433965Sjdp/* Procedure descriptor external record */
24533965Sjdp
24633965Sjdpstruct pdr_ext {
24733965Sjdp	unsigned char	p_adr[8];
24833965Sjdp	unsigned char	p_cbLineOffset[8];
24933965Sjdp	unsigned char	p_isym[4];
25033965Sjdp	unsigned char	p_iline[4];
25133965Sjdp	unsigned char	p_regmask[4];
25233965Sjdp	unsigned char	p_regoffset[4];
25333965Sjdp	unsigned char	p_iopt[4];
25433965Sjdp	unsigned char	p_fregmask[4];
25533965Sjdp	unsigned char	p_fregoffset[4];
25633965Sjdp	unsigned char	p_frameoffset[4];
25733965Sjdp	unsigned char	p_lnLow[4];
25833965Sjdp	unsigned char	p_lnHigh[4];
25933965Sjdp	unsigned char	p_gp_prologue[1];
26033965Sjdp	unsigned char	p_bits1[1];
26133965Sjdp	unsigned char	p_bits2[1];
26233965Sjdp	unsigned char	p_localoff[1];
26333965Sjdp	unsigned char	p_framereg[2];
26433965Sjdp	unsigned char	p_pcreg[2];
26533965Sjdp};
26633965Sjdp
26733965Sjdp#define PDR_BITS1_GP_USED_BIG		0x80
26833965Sjdp#define PDR_BITS1_REG_FRAME_BIG		0x40
26933965Sjdp#define PDR_BITS1_PROF_BIG		0x20
27033965Sjdp#define PDR_BITS1_RESERVED_BIG		0x1f
27133965Sjdp#define PDR_BITS1_RESERVED_SH_LEFT_BIG	8
27233965Sjdp#define PDR_BITS2_RESERVED_BIG		0xff
27333965Sjdp#define PDR_BITS2_RESERVED_SH_BIG	0
27433965Sjdp
27533965Sjdp#define PDR_BITS1_GP_USED_LITTLE	0x01
27633965Sjdp#define PDR_BITS1_REG_FRAME_LITTLE	0x02
27733965Sjdp#define PDR_BITS1_PROF_LITTLE		0x04
27833965Sjdp#define PDR_BITS1_RESERVED_LITTLE	0xf8
27933965Sjdp#define PDR_BITS1_RESERVED_SH_LITTLE	3
28033965Sjdp#define PDR_BITS2_RESERVED_LITTLE	0xff
28133965Sjdp#define PDR_BITS2_RESERVED_SH_LEFT_LITTLE 5
28233965Sjdp
28333965Sjdp/* Line numbers */
28433965Sjdp
28533965Sjdpstruct line_ext {
28633965Sjdp	unsigned char	l_line[4];
28733965Sjdp};
28833965Sjdp
28933965Sjdp/* Symbol external record */
29033965Sjdp
29133965Sjdpstruct sym_ext {
29233965Sjdp	unsigned char	s_value[8];
29333965Sjdp	unsigned char	s_iss[4];
29433965Sjdp	unsigned char	s_bits1[1];
29533965Sjdp	unsigned char	s_bits2[1];
29633965Sjdp	unsigned char	s_bits3[1];
29733965Sjdp	unsigned char	s_bits4[1];
29833965Sjdp};
29933965Sjdp
30033965Sjdp#define	SYM_BITS1_ST_BIG		0xFC
30133965Sjdp#define	SYM_BITS1_ST_SH_BIG		2
30233965Sjdp#define	SYM_BITS1_ST_LITTLE		0x3F
30333965Sjdp#define	SYM_BITS1_ST_SH_LITTLE		0
30433965Sjdp
30533965Sjdp#define	SYM_BITS1_SC_BIG		0x03
30633965Sjdp#define	SYM_BITS1_SC_SH_LEFT_BIG	3
30733965Sjdp#define	SYM_BITS1_SC_LITTLE		0xC0
30833965Sjdp#define	SYM_BITS1_SC_SH_LITTLE		6
30933965Sjdp
31033965Sjdp#define	SYM_BITS2_SC_BIG		0xE0
31133965Sjdp#define	SYM_BITS2_SC_SH_BIG		5
31233965Sjdp#define	SYM_BITS2_SC_LITTLE		0x07
31333965Sjdp#define	SYM_BITS2_SC_SH_LEFT_LITTLE	2
31433965Sjdp
31533965Sjdp#define	SYM_BITS2_RESERVED_BIG		0x10
31633965Sjdp#define	SYM_BITS2_RESERVED_LITTLE	0x08
31733965Sjdp
31833965Sjdp#define	SYM_BITS2_INDEX_BIG		0x0F
31933965Sjdp#define	SYM_BITS2_INDEX_SH_LEFT_BIG	16
32033965Sjdp#define	SYM_BITS2_INDEX_LITTLE		0xF0
32133965Sjdp#define	SYM_BITS2_INDEX_SH_LITTLE	4
32233965Sjdp
32333965Sjdp#define	SYM_BITS3_INDEX_SH_LEFT_BIG	8
32433965Sjdp#define	SYM_BITS3_INDEX_SH_LEFT_LITTLE	4
32533965Sjdp
32633965Sjdp#define	SYM_BITS4_INDEX_SH_LEFT_BIG	0
32733965Sjdp#define	SYM_BITS4_INDEX_SH_LEFT_LITTLE	12
32833965Sjdp
32933965Sjdp/* External symbol external record */
33033965Sjdp
33133965Sjdpstruct ext_ext {
33233965Sjdp	struct	sym_ext es_asym;
33333965Sjdp	unsigned char	es_bits1[1];
33433965Sjdp	unsigned char	es_bits2[3];
33533965Sjdp	unsigned char	es_ifd[4];
33633965Sjdp};
33733965Sjdp
33833965Sjdp#define	EXT_BITS1_JMPTBL_BIG		0x80
33933965Sjdp#define	EXT_BITS1_JMPTBL_LITTLE		0x01
34033965Sjdp
34133965Sjdp#define	EXT_BITS1_COBOL_MAIN_BIG	0x40
34233965Sjdp#define	EXT_BITS1_COBOL_MAIN_LITTLE	0x02
34333965Sjdp
34433965Sjdp#define	EXT_BITS1_WEAKEXT_BIG		0x20
34533965Sjdp#define	EXT_BITS1_WEAKEXT_LITTLE	0x04
34633965Sjdp
34733965Sjdp/* Dense numbers external record */
34833965Sjdp
34933965Sjdpstruct dnr_ext {
35033965Sjdp	unsigned char	d_rfd[4];
35133965Sjdp	unsigned char	d_index[4];
35233965Sjdp};
35333965Sjdp
35433965Sjdp/* Relative file descriptor */
35533965Sjdp
35633965Sjdpstruct rfd_ext {
35733965Sjdp  unsigned char	rfd[4];
35833965Sjdp};
35933965Sjdp
36033965Sjdp/* Optimizer symbol external record */
36133965Sjdp
36233965Sjdpstruct opt_ext {
36333965Sjdp  unsigned char o_bits1[1];
36433965Sjdp  unsigned char o_bits2[1];
36533965Sjdp  unsigned char o_bits3[1];
36633965Sjdp  unsigned char o_bits4[1];
36733965Sjdp  struct rndx_ext o_rndx;
36833965Sjdp  unsigned char o_offset[4];
36933965Sjdp};
37033965Sjdp
37133965Sjdp#define OPT_BITS2_VALUE_SH_LEFT_BIG	16
37233965Sjdp#define OPT_BITS2_VALUE_SH_LEFT_LITTLE	0
37333965Sjdp
37433965Sjdp#define OPT_BITS3_VALUE_SH_LEFT_BIG	8
37533965Sjdp#define OPT_BITS3_VALUE_SH_LEFT_LITTLE	8
37633965Sjdp
37733965Sjdp#define OPT_BITS4_VALUE_SH_LEFT_BIG	0
37833965Sjdp#define OPT_BITS4_VALUE_SH_LEFT_LITTLE	16
379