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