00001 /* ECOFF support on Alpha machines. 00002 coff/ecoff.h must be included before this file. 00003 00004 Copyright 2001 Free Software Foundation, Inc. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 00019 00020 /********************** FILE HEADER **********************/ 00021 00022 struct external_filehdr 00023 { 00024 unsigned char f_magic[2]; /* magic number */ 00025 unsigned char f_nscns[2]; /* number of sections */ 00026 unsigned char f_timdat[4]; /* time & date stamp */ 00027 unsigned char f_symptr[8]; /* file pointer to symtab */ 00028 unsigned char f_nsyms[4]; /* number of symtab entries */ 00029 unsigned char f_opthdr[2]; /* sizeof(optional hdr) */ 00030 unsigned char f_flags[2]; /* flags */ 00031 }; 00032 00033 /* Magic numbers are defined in coff/ecoff.h. */ 00034 #define ALPHA_ECOFF_BADMAG(x) \ 00035 ((x).f_magic != ALPHA_MAGIC && (x).f_magic != ALPHA_MAGIC_BSD) 00036 00037 /* The object type is encoded in the f_flags. */ 00038 #define F_ALPHA_OBJECT_TYPE_MASK 0x3000 00039 #define F_ALPHA_NO_SHARED 0x1000 00040 #define F_ALPHA_SHARABLE 0x2000 00041 #define F_ALPHA_CALL_SHARED 0x3000 00042 00043 #define FILHDR struct external_filehdr 00044 #define FILHSZ 24 00045 00046 /********************** AOUT "OPTIONAL HEADER" **********************/ 00047 00048 typedef struct external_aouthdr 00049 { 00050 unsigned char magic[2]; /* type of file */ 00051 unsigned char vstamp[2]; /* version stamp */ 00052 unsigned char bldrev[2]; /* ?? */ 00053 unsigned char padding[2]; /* pad to quadword boundary */ 00054 unsigned char tsize[8]; /* text size in bytes */ 00055 unsigned char dsize[8]; /* initialized data " " */ 00056 unsigned char bsize[8]; /* uninitialized data " " */ 00057 unsigned char entry[8]; /* entry pt. */ 00058 unsigned char text_start[8]; /* base of text used for this file */ 00059 unsigned char data_start[8]; /* base of data used for this file */ 00060 unsigned char bss_start[8]; /* base of bss used for this file */ 00061 unsigned char gprmask[4]; /* bitmask of general registers used */ 00062 unsigned char fprmask[4]; /* bitmask of floating point registers used */ 00063 unsigned char gp_value[8]; /* value for gp register */ 00064 } AOUTHDR; 00065 00066 /* compute size of a header */ 00067 00068 #define AOUTSZ 80 00069 #define AOUTHDRSZ 80 00070 00071 /********************** SECTION HEADER **********************/ 00072 00073 struct external_scnhdr 00074 { 00075 unsigned char s_name[8]; /* section name */ 00076 unsigned char s_paddr[8]; /* physical address, aliased s_nlib */ 00077 unsigned char s_vaddr[8]; /* virtual address */ 00078 unsigned char s_size[8]; /* section size */ 00079 unsigned char s_scnptr[8]; /* file ptr to raw data for section */ 00080 unsigned char s_relptr[8]; /* file ptr to relocation */ 00081 unsigned char s_lnnoptr[8]; /* file ptr to line numbers */ 00082 unsigned char s_nreloc[2]; /* number of relocation entries */ 00083 unsigned char s_nlnno[2]; /* number of line number entries*/ 00084 unsigned char s_flags[4]; /* flags */ 00085 }; 00086 00087 #define SCNHDR struct external_scnhdr 00088 #define SCNHSZ 64 00089 00090 /********************** RELOCATION DIRECTIVES **********************/ 00091 00092 struct external_reloc 00093 { 00094 unsigned char r_vaddr[8]; 00095 unsigned char r_symndx[4]; 00096 unsigned char r_bits[4]; 00097 }; 00098 00099 #define RELOC struct external_reloc 00100 #define RELSZ 16 00101 00102 /* Constants to unpack the r_bits field. The Alpha seems to always be 00103 little endian, so I haven't bothered to define big endian variants 00104 of these. */ 00105 00106 #define RELOC_BITS0_TYPE_LITTLE 0xff 00107 #define RELOC_BITS0_TYPE_SH_LITTLE 0 00108 00109 #define RELOC_BITS1_EXTERN_LITTLE 0x01 00110 00111 #define RELOC_BITS1_OFFSET_LITTLE 0x7e 00112 #define RELOC_BITS1_OFFSET_SH_LITTLE 1 00113 00114 #define RELOC_BITS1_RESERVED_LITTLE 0x80 00115 #define RELOC_BITS1_RESERVED_SH_LITTLE 7 00116 #define RELOC_BITS2_RESERVED_LITTLE 0xff 00117 #define RELOC_BITS2_RESERVED_SH_LEFT_LITTLE 1 00118 #define RELOC_BITS3_RESERVED_LITTLE 0x03 00119 #define RELOC_BITS3_RESERVED_SH_LEFT_LITTLE 9 00120 00121 #define RELOC_BITS3_SIZE_LITTLE 0xfc 00122 #define RELOC_BITS3_SIZE_SH_LITTLE 2 00123 00124 /* The r_type field in a reloc is one of the following values. */ 00125 #define ALPHA_R_IGNORE 0 00126 #define ALPHA_R_REFLONG 1 00127 #define ALPHA_R_REFQUAD 2 00128 #define ALPHA_R_GPREL32 3 00129 #define ALPHA_R_LITERAL 4 00130 #define ALPHA_R_LITUSE 5 00131 #define ALPHA_R_GPDISP 6 00132 #define ALPHA_R_BRADDR 7 00133 #define ALPHA_R_HINT 8 00134 #define ALPHA_R_SREL16 9 00135 #define ALPHA_R_SREL32 10 00136 #define ALPHA_R_SREL64 11 00137 #define ALPHA_R_OP_PUSH 12 00138 #define ALPHA_R_OP_STORE 13 00139 #define ALPHA_R_OP_PSUB 14 00140 #define ALPHA_R_OP_PRSHIFT 15 00141 #define ALPHA_R_GPVALUE 16 00142 #define ALPHA_R_GPRELHIGH 17 00143 #define ALPHA_R_GPRELLOW 18 00144 #define ALPHA_R_IMMED 19 00145 00146 /* Overloaded reloc value used by Net- and OpenBSD. */ 00147 #define ALPHA_R_LITERALSLEAZY 17 00148 00149 /* With ALPHA_R_LITUSE, the r_size field is one of the following values. */ 00150 #define ALPHA_R_LU_BASE 1 00151 #define ALPHA_R_LU_BYTOFF 2 00152 #define ALPHA_R_LU_JSR 3 00153 00154 /* With ALPHA_R_IMMED, the r_size field is one of the following values. */ 00155 #define ALPHA_R_IMMED_GP_16 1 00156 #define ALPHA_R_IMMED_GP_HI32 2 00157 #define ALPHA_R_IMMED_SCN_HI32 3 00158 #define ALPHA_R_IMMED_BR_HI32 4 00159 #define ALPHA_R_IMMED_LO32 5 00160 00161 /********************** SYMBOLIC INFORMATION **********************/ 00162 00163 /* Written by John Gilmore. */ 00164 00165 /* ECOFF uses COFF-like section structures, but its own symbol format. 00166 This file defines the symbol format in fields whose size and alignment 00167 will not vary on different host systems. */ 00168 00169 /* File header as a set of bytes */ 00170 00171 struct hdr_ext 00172 { 00173 unsigned char h_magic[2]; 00174 unsigned char h_vstamp[2]; 00175 unsigned char h_ilineMax[4]; 00176 unsigned char h_idnMax[4]; 00177 unsigned char h_ipdMax[4]; 00178 unsigned char h_isymMax[4]; 00179 unsigned char h_ioptMax[4]; 00180 unsigned char h_iauxMax[4]; 00181 unsigned char h_issMax[4]; 00182 unsigned char h_issExtMax[4]; 00183 unsigned char h_ifdMax[4]; 00184 unsigned char h_crfd[4]; 00185 unsigned char h_iextMax[4]; 00186 unsigned char h_cbLine[8]; 00187 unsigned char h_cbLineOffset[8]; 00188 unsigned char h_cbDnOffset[8]; 00189 unsigned char h_cbPdOffset[8]; 00190 unsigned char h_cbSymOffset[8]; 00191 unsigned char h_cbOptOffset[8]; 00192 unsigned char h_cbAuxOffset[8]; 00193 unsigned char h_cbSsOffset[8]; 00194 unsigned char h_cbSsExtOffset[8]; 00195 unsigned char h_cbFdOffset[8]; 00196 unsigned char h_cbRfdOffset[8]; 00197 unsigned char h_cbExtOffset[8]; 00198 }; 00199 00200 /* File descriptor external record */ 00201 00202 struct fdr_ext 00203 { 00204 unsigned char f_adr[8]; 00205 unsigned char f_cbLineOffset[8]; 00206 unsigned char f_cbLine[8]; 00207 unsigned char f_cbSs[8]; 00208 unsigned char f_rss[4]; 00209 unsigned char f_issBase[4]; 00210 unsigned char f_isymBase[4]; 00211 unsigned char f_csym[4]; 00212 unsigned char f_ilineBase[4]; 00213 unsigned char f_cline[4]; 00214 unsigned char f_ioptBase[4]; 00215 unsigned char f_copt[4]; 00216 unsigned char f_ipdFirst[4]; 00217 unsigned char f_cpd[4]; 00218 unsigned char f_iauxBase[4]; 00219 unsigned char f_caux[4]; 00220 unsigned char f_rfdBase[4]; 00221 unsigned char f_crfd[4]; 00222 unsigned char f_bits1[1]; 00223 unsigned char f_bits2[3]; 00224 unsigned char f_padding[4]; 00225 }; 00226 00227 #define FDR_BITS1_LANG_BIG 0xF8 00228 #define FDR_BITS1_LANG_SH_BIG 3 00229 #define FDR_BITS1_LANG_LITTLE 0x1F 00230 #define FDR_BITS1_LANG_SH_LITTLE 0 00231 00232 #define FDR_BITS1_FMERGE_BIG 0x04 00233 #define FDR_BITS1_FMERGE_LITTLE 0x20 00234 00235 #define FDR_BITS1_FREADIN_BIG 0x02 00236 #define FDR_BITS1_FREADIN_LITTLE 0x40 00237 00238 #define FDR_BITS1_FBIGENDIAN_BIG 0x01 00239 #define FDR_BITS1_FBIGENDIAN_LITTLE 0x80 00240 00241 #define FDR_BITS2_GLEVEL_BIG 0xC0 00242 #define FDR_BITS2_GLEVEL_SH_BIG 6 00243 #define FDR_BITS2_GLEVEL_LITTLE 0x03 00244 #define FDR_BITS2_GLEVEL_SH_LITTLE 0 00245 00246 /* We ignore the `reserved' field in bits2. */ 00247 00248 /* Procedure descriptor external record */ 00249 00250 struct pdr_ext { 00251 unsigned char p_adr[8]; 00252 unsigned char p_cbLineOffset[8]; 00253 unsigned char p_isym[4]; 00254 unsigned char p_iline[4]; 00255 unsigned char p_regmask[4]; 00256 unsigned char p_regoffset[4]; 00257 unsigned char p_iopt[4]; 00258 unsigned char p_fregmask[4]; 00259 unsigned char p_fregoffset[4]; 00260 unsigned char p_frameoffset[4]; 00261 unsigned char p_lnLow[4]; 00262 unsigned char p_lnHigh[4]; 00263 unsigned char p_gp_prologue[1]; 00264 unsigned char p_bits1[1]; 00265 unsigned char p_bits2[1]; 00266 unsigned char p_localoff[1]; 00267 unsigned char p_framereg[2]; 00268 unsigned char p_pcreg[2]; 00269 }; 00270 00271 #define PDR_BITS1_GP_USED_BIG 0x80 00272 #define PDR_BITS1_REG_FRAME_BIG 0x40 00273 #define PDR_BITS1_PROF_BIG 0x20 00274 #define PDR_BITS1_RESERVED_BIG 0x1f 00275 #define PDR_BITS1_RESERVED_SH_LEFT_BIG 8 00276 #define PDR_BITS2_RESERVED_BIG 0xff 00277 #define PDR_BITS2_RESERVED_SH_BIG 0 00278 00279 #define PDR_BITS1_GP_USED_LITTLE 0x01 00280 #define PDR_BITS1_REG_FRAME_LITTLE 0x02 00281 #define PDR_BITS1_PROF_LITTLE 0x04 00282 #define PDR_BITS1_RESERVED_LITTLE 0xf8 00283 #define PDR_BITS1_RESERVED_SH_LITTLE 3 00284 #define PDR_BITS2_RESERVED_LITTLE 0xff 00285 #define PDR_BITS2_RESERVED_SH_LEFT_LITTLE 5 00286 00287 /* Line numbers */ 00288 00289 struct line_ext { 00290 unsigned char l_line[4]; 00291 }; 00292 00293 /* Symbol external record */ 00294 00295 struct sym_ext { 00296 unsigned char s_value[8]; 00297 unsigned char s_iss[4]; 00298 unsigned char s_bits1[1]; 00299 unsigned char s_bits2[1]; 00300 unsigned char s_bits3[1]; 00301 unsigned char s_bits4[1]; 00302 }; 00303 00304 #define SYM_BITS1_ST_BIG 0xFC 00305 #define SYM_BITS1_ST_SH_BIG 2 00306 #define SYM_BITS1_ST_LITTLE 0x3F 00307 #define SYM_BITS1_ST_SH_LITTLE 0 00308 00309 #define SYM_BITS1_SC_BIG 0x03 00310 #define SYM_BITS1_SC_SH_LEFT_BIG 3 00311 #define SYM_BITS1_SC_LITTLE 0xC0 00312 #define SYM_BITS1_SC_SH_LITTLE 6 00313 00314 #define SYM_BITS2_SC_BIG 0xE0 00315 #define SYM_BITS2_SC_SH_BIG 5 00316 #define SYM_BITS2_SC_LITTLE 0x07 00317 #define SYM_BITS2_SC_SH_LEFT_LITTLE 2 00318 00319 #define SYM_BITS2_RESERVED_BIG 0x10 00320 #define SYM_BITS2_RESERVED_LITTLE 0x08 00321 00322 #define SYM_BITS2_INDEX_BIG 0x0F 00323 #define SYM_BITS2_INDEX_SH_LEFT_BIG 16 00324 #define SYM_BITS2_INDEX_LITTLE 0xF0 00325 #define SYM_BITS2_INDEX_SH_LITTLE 4 00326 00327 #define SYM_BITS3_INDEX_SH_LEFT_BIG 8 00328 #define SYM_BITS3_INDEX_SH_LEFT_LITTLE 4 00329 00330 #define SYM_BITS4_INDEX_SH_LEFT_BIG 0 00331 #define SYM_BITS4_INDEX_SH_LEFT_LITTLE 12 00332 00333 /* External symbol external record */ 00334 00335 struct ext_ext { 00336 struct sym_ext es_asym; 00337 unsigned char es_bits1[1]; 00338 unsigned char es_bits2[3]; 00339 unsigned char es_ifd[4]; 00340 }; 00341 00342 #define EXT_BITS1_JMPTBL_BIG 0x80 00343 #define EXT_BITS1_JMPTBL_LITTLE 0x01 00344 00345 #define EXT_BITS1_COBOL_MAIN_BIG 0x40 00346 #define EXT_BITS1_COBOL_MAIN_LITTLE 0x02 00347 00348 #define EXT_BITS1_WEAKEXT_BIG 0x20 00349 #define EXT_BITS1_WEAKEXT_LITTLE 0x04 00350 00351 /* Dense numbers external record */ 00352 00353 struct dnr_ext { 00354 unsigned char d_rfd[4]; 00355 unsigned char d_index[4]; 00356 }; 00357 00358 /* Relative file descriptor */ 00359 00360 struct rfd_ext { 00361 unsigned char rfd[4]; 00362 }; 00363 00364 /* Optimizer symbol external record */ 00365 00366 struct opt_ext { 00367 unsigned char o_bits1[1]; 00368 unsigned char o_bits2[1]; 00369 unsigned char o_bits3[1]; 00370 unsigned char o_bits4[1]; 00371 struct rndx_ext o_rndx; 00372 unsigned char o_offset[4]; 00373 }; 00374 00375 #define OPT_BITS2_VALUE_SH_LEFT_BIG 16 00376 #define OPT_BITS2_VALUE_SH_LEFT_LITTLE 0 00377 00378 #define OPT_BITS3_VALUE_SH_LEFT_BIG 8 00379 #define OPT_BITS3_VALUE_SH_LEFT_LITTLE 8 00380 00381 #define OPT_BITS4_VALUE_SH_LEFT_BIG 0 00382 #define OPT_BITS4_VALUE_SH_LEFT_LITTLE 16
1.5.6