sparc.h revision 78828
1/* coff information for Sparc. 2 3 Copyright 2001 Free Software Foundation, Inc. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 18 19/* This file is an amalgamation of several standard include files that 20 define coff format, such as filehdr.h, aouthdr.h, and so forth. In 21 addition, all datatypes have been translated into character arrays of 22 (presumed) equivalent size. This is necessary so that this file can 23 be used with different systems while still yielding the same results. */ 24 25/********************** FILE HEADER **********************/ 26 27struct external_filehdr 28{ 29 char f_magic[2]; /* magic number */ 30 char f_nscns[2]; /* number of sections */ 31 char f_timdat[4]; /* time & date stamp */ 32 char f_symptr[4]; /* file pointer to symtab */ 33 char f_nsyms[4]; /* number of symtab entries */ 34 char f_opthdr[2]; /* sizeof(optional hdr) */ 35 char f_flags[2]; /* flags */ 36}; 37 38#define F_RELFLG (0x0001) /* relocation info stripped */ 39#define F_EXEC (0x0002) /* file is executable */ 40#define F_LNNO (0x0004) /* line numbers stripped */ 41#define F_LSYMS (0x0008) /* local symbols stripped */ 42 43#define SPARCMAGIC (0540) 44 45/* This is Lynx's all-platform magic number for executables. */ 46 47#define LYNXCOFFMAGIC (0415) 48 49#define FILHDR struct external_filehdr 50#define FILHSZ 20 51 52/********************** AOUT "OPTIONAL HEADER" **********************/ 53 54typedef struct 55{ 56 char magic[2]; /* type of file */ 57 char vstamp[2]; /* version stamp */ 58 char tsize[4]; /* text size in bytes, padded to FW bdry*/ 59 char dsize[4]; /* initialized data " " */ 60 char bsize[4]; /* uninitialized data " " */ 61 char entry[4]; /* entry pt. */ 62 char text_start[4]; /* base of text used for this file */ 63 char data_start[4]; /* base of data used for this file */ 64} 65AOUTHDR; 66 67#define AOUTSZ 28 68#define AOUTHDRSZ 28 69 70#define OMAGIC 0404 /* object files, eg as output */ 71#define ZMAGIC 0413 /* demand load format, eg normal ld output */ 72#define STMAGIC 0401 /* target shlib */ 73#define SHMAGIC 0443 /* host shlib */ 74 75/********************** SECTION HEADER **********************/ 76 77struct external_scnhdr 78{ 79 char s_name[8]; /* section name */ 80 char s_paddr[4]; /* physical address, aliased s_nlib */ 81 char s_vaddr[4]; /* virtual address */ 82 char s_size[4]; /* section size */ 83 char s_scnptr[4]; /* file ptr to raw data for section */ 84 char s_relptr[4]; /* file ptr to relocation */ 85 char s_lnnoptr[4]; /* file ptr to line numbers */ 86 char s_nreloc[2]; /* number of relocation entries */ 87 char s_nlnno[2]; /* number of line number entries*/ 88 char s_flags[4]; /* flags */ 89}; 90 91#define SCNHDR struct external_scnhdr 92#define SCNHSZ 40 93 94/* Names of "special" sections. */ 95 96#define _TEXT ".text" 97#define _DATA ".data" 98#define _BSS ".bss" 99#define _TV ".tv" 100#define _INIT ".init" 101#define _FINI ".fini" 102#define _COMMENT ".comment" 103#define _LIB ".lib" 104 105/********************** LINE NUMBERS **********************/ 106 107/* 1 line number entry for every "breakpointable" source line in a section. 108 Line numbers are grouped on a per function basis; first entry in a function 109 grouping will have l_lnno = 0 and in place of physical address will be the 110 symbol table index of the function name. */ 111 112struct external_lineno 113{ 114 union { 115 char l_symndx[4]; /* fn name symbol index, iff l_lnno == 0 */ 116 char l_paddr[4]; /* (physical) address of line number */ 117 } l_addr; 118 char l_lnno[2]; /* line number */ 119}; 120 121#define LINENO struct external_lineno 122#define LINESZ (6) 123 124/********************** SYMBOLS **********************/ 125 126#define E_SYMNMLEN (8) /* # characters in a symbol name */ 127#define E_FILNMLEN (14) /* # characters in a file name */ 128#define E_DIMNUM (4) /* # array dimensions in auxiliary entry */ 129 130struct external_syment 131{ 132 union { 133 char e_name[E_SYMNMLEN]; 134 struct { 135 char e_zeroes[4]; 136 char e_offset[4]; 137 } e; 138#if 0 /* of doubtful value */ 139 char e_nptr[2][4]; 140 struct { 141 char e_leading_zero[1]; 142 char e_dbx_type[1]; 143 char e_dbx_desc[2]; 144 } e_dbx; 145#endif 146 } e; 147 148 char e_value[4]; 149 char e_scnum[2]; 150 char e_type[2]; 151 char e_sclass[1]; 152 char e_numaux[1]; 153 char padding[2]; 154}; 155 156#define N_BTMASK (0xf) 157#define N_TMASK (0x30) 158#define N_BTSHFT (4) 159#define N_TSHIFT (2) 160 161union external_auxent 162{ 163 struct { 164 char x_tagndx[4]; /* str, un, or enum tag indx */ 165 union { 166 struct { 167 char x_lnno[2]; /* declaration line number */ 168 char x_size[2]; /* str/union/array size */ 169 } x_lnsz; 170 char x_fsize[4]; /* size of function */ 171 } x_misc; 172 union { 173 struct { /* if ISFCN, tag, or .bb */ 174 char x_lnnoptr[4]; /* ptr to fcn line # */ 175 char x_endndx[4]; /* entry ndx past block end */ 176 } x_fcn; 177 struct { /* if ISARY, up to 4 dimen. */ 178 char x_dimen[E_DIMNUM][2]; 179 } x_ary; 180 } x_fcnary; 181 char x_tvndx[2]; /* tv index */ 182 } x_sym; 183 184 union { 185 char x_fname[E_FILNMLEN]; 186 struct { 187 char x_zeroes[4]; 188 char x_offset[4]; 189 } x_n; 190 } x_file; 191 192 struct { 193 char x_scnlen[4]; /* section length */ 194 char x_nreloc[2]; /* # relocation entries */ 195 char x_nlinno[2]; /* # line numbers */ 196 } x_scn; 197 198 struct { 199 char x_tvfill[4]; /* tv fill value */ 200 char x_tvlen[2]; /* length of .tv */ 201 char x_tvran[2][2]; /* tv range */ 202 } x_tv; /* .tv section info (in auxent of sym .tv)) */ 203 204 char x_fill[20]; /* forces to 20-byte size */ 205}; 206 207#define SYMENT struct external_syment 208#define SYMESZ 20 209#define AUXENT union external_auxent 210#define AUXESZ 20 211 212#define _ETEXT "etext" 213 214/********************** RELOCATION DIRECTIVES **********************/ 215 216struct external_reloc { 217 char r_vaddr[4]; 218 char r_symndx[4]; 219 char r_type[2]; 220 char r_spare[2]; 221 char r_offset[4]; 222}; 223 224#define RELOC struct external_reloc 225#define RELSZ 16 226 227