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