1 /********************** FILE HEADER **********************/
2 struct internal_filehdr
4 unsigned short f_magic; /* magic number */
5 unsigned short f_nscns; /* number of sections */
6 long f_timdat; /* time & date stamp */
7 long f_symptr; /* file pointer to symtab */
8 long f_nsyms; /* number of symtab entries */
9 unsigned short f_opthdr; /* sizeof(optional hdr) */
10 unsigned short f_flags; /* flags */
14 * F_RELFLG relocation info stripped from file
15 * F_EXEC file is executable (no unresolved external references)
16 * F_LNNO line numbers stripped from file
17 * F_LSYMS local symbols stripped from file
18 * F_AR16WR file is 16-bit little-endian
19 * F_AR32WR file is 32-bit little-endian
20 * F_AR32W file is 32-bit big-endian
21 * F_DYNLOAD rs/6000 aix: dynamically loadable w/imports & exports
22 * F_SHROBJ rs/6000 aix: file is a shared object
25 #define F_RELFLG (0x0001)
26 #define F_EXEC (0x0002)
27 #define F_LNNO (0x0004)
28 #define F_LSYMS (0x0008)
29 #define F_AR16WR (0x0080)
30 #define F_AR32WR (0x0100)
31 #define F_AR32W (0x0200)
32 #define F_DYNLOAD (0x1000)
33 #define F_SHROBJ (0x2000)
35 /********************** AOUT "OPTIONAL HEADER" **********************/
36 struct internal_aouthdr {
37 short magic; /* type of file */
38 short vstamp; /* version stamp */
39 unsigned long tsize; /* text size in bytes, padded to FW bdry*/
40 unsigned long dsize; /* initialized data " " */
41 unsigned long bsize; /* uninitialized data " " */
42 unsigned long entry; /* entry pt. */
43 unsigned long text_start; /* base of text used for this file */
44 unsigned long data_start; /* base of data used for this file */
47 unsigned long tagentries; /* number of tag entries to follow */
50 unsigned long o_toc; /* address of TOC */
51 short o_snentry; /* section number for entry point */
52 short o_sntext; /* section number for text */
53 short o_sndata; /* section number for data */
54 short o_sntoc; /* section number for toc */
55 short o_snloader; /* section number for loader section */
56 short o_snbss; /* section number for bss */
57 short o_algntext; /* max alignment for text */
58 short o_algndata; /* max alignment for data */
59 short o_modtype; /* Module type field, 1R,RE,RO */
60 unsigned long o_maxstack; /* max stack size allowed. */
63 /********************** STORAGE CLASSES **********************/
65 #define C_EFCN -1 /* physical end of function */
67 #define C_AUTO 1 /* automatic variable */
68 #define C_EXT 2 /* external symbol */
69 #define C_STAT 3 /* static */
70 #define C_REG 4 /* register variable */
71 #define C_EXTDEF 5 /* external definition */
72 #define C_LABEL 6 /* label */
73 #define C_ULABEL 7 /* undefined label */
74 #define C_MOS 8 /* member of structure */
75 #define C_ARG 9 /* function argument */
76 #define C_STRTAG 10 /* structure tag */
77 #define C_MOU 11 /* member of union */
78 #define C_UNTAG 12 /* union tag */
79 #define C_TPDEF 13 /* type definition */
80 #define C_USTATIC 14 /* undefined static */
81 #define C_ENTAG 15 /* enumeration tag */
82 #define C_MOE 16 /* member of enumeration */
83 #define C_REGPARM 17 /* register parameter */
84 #define C_FIELD 18 /* bit field */
85 #define C_AUTOARG 19 /* auto argument */
86 #define C_LASTENT 20 /* dummy entry (end of block) */
87 #define C_BLOCK 100 /* ".bb" or ".eb" */
88 #define C_FCN 101 /* ".bf" or ".ef" */
89 #define C_EOS 102 /* end of structure */
90 #define C_FILE 103 /* file name */
91 #define C_LINE 104 /* line # reformatted as symbol table entry */
92 #define C_ALIAS 105 /* duplicate tag */
93 #define C_HIDDEN 106 /* ext symbol in dmert public lib */
95 /* New storage classes for 80960 */
97 /* C_LEAFPROC is obsolete. Use C_LEAFEXT or C_LEAFSTAT */
98 #define C_LEAFPROC 108 /* Leaf procedure, "call" via BAL */
100 #define C_SCALL 107 /* Procedure reachable via system call */
101 #define C_LEAFEXT 108 /* External leaf */
102 #define C_LEAFSTAT 113 /* Static leaf */
103 #define C_OPTVAR 109 /* Optimized variable */
104 #define C_DEFINE 110 /* Preprocessor #define */
105 #define C_PRAGMA 111 /* Advice to compiler or linker */
106 #define C_SEGMENT 112 /* 80960 segment name */
108 /* New storage classes for RS/6000 */
109 #define C_HIDEXT 107 /* Un-named external symbol */
110 #define C_BINCL 108 /* Marks beginning of include file */
111 #define C_EINCL 109 /* Marks ending of include file */
113 /* storage classes for stab symbols for RS/6000 */
130 /********************** SECTION HEADER **********************/
131 struct internal_scnhdr {
132 char s_name[8]; /* section name */
133 long s_paddr; /* physical address, aliased s_nlib */
134 long s_vaddr; /* virtual address */
135 long s_size; /* section size */
136 long s_scnptr; /* file ptr to raw data for section */
137 long s_relptr; /* file ptr to relocation */
138 long s_lnnoptr; /* file ptr to line numbers */
140 unsigned long s_nreloc;
141 unsigned long s_nlnno;
143 unsigned short s_nreloc; /* number of relocation entries */
144 unsigned short s_nlnno; /* number of line number entries*/
146 long s_flags; /* flags */
156 #define STYP_REG (0x0000) /* "regular": allocated, relocated, loaded */
157 #define STYP_DSECT (0x0001) /* "dummy": relocated only*/
158 #define STYP_NOLOAD (0x0002) /* "noload": allocated, relocated, not loaded */
159 #define STYP_GROUP (0x0004) /* "grouped": formed of input sections */
160 #define STYP_PAD (0x0008) /* "padding": not allocated, not relocated, loaded */
161 #define STYP_COPY (0x0010) /* "copy": for decision function used by field update; not allocated, not relocated,
162 loaded; reloc & lineno entries processed normally */
163 #define STYP_TEXT (0x0020) /* section contains text only */
164 #define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile
165 will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will
166 update all process invocations. */
167 #define STYP_DATA (0x0040) /* section contains data only */
168 #define STYP_BSS (0x0080) /* section contains bss only */
169 #define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */
170 #define STYP_INFO (0x0200) /* comment: not allocated not relocated, not loaded */
171 #define STYP_OVER (0x0400) /* overlay: relocated not allocated or loaded */
172 #define STYP_LIB (0x0800) /* for .lib: same as INFO */
173 #define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */
174 #define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions wherever padding is necessary and there is a
175 word of contiguous bytes beginning on a word boundary. */
176 /********************** LINE NUMBERS **********************/
178 /* 1 line number entry for every "breakpointable" source line in a section.
179 * Line numbers are grouped on a per function basis; first entry in a function
180 * grouping will have l_lnno = 0 and in place of physical address will be the
181 * symbol table index of the function name.
184 struct internal_lineno {
186 long l_symndx; /* function name symbol index, iff l_lnno == 0*/
187 long l_paddr; /* (physical) address of line number */
189 unsigned long l_lnno; /* line number */
193 /********************** SYMBOLS **********************/
195 #define SYMNMLEN 8 /* # characters in a symbol name */
196 #define FILNMLEN 14 /* # characters in a file name */
197 #define DIMNUM 4 /* # array dimensions in auxiliary entry */
199 struct internal_syment {
201 char _n_name[SYMNMLEN]; /* old COFF version */
203 long _n_zeroes; /* new == 0 */
204 long _n_offset; /* offset into string table */
206 char *_n_nptr[2]; /* allows for overlaying */
208 long n_value; /* value of symbol */
209 short n_scnum; /* section number */
210 unsigned short n_flags; /* copy of flags from filhdr */
211 unsigned short n_type; /* type and derived type */
215 char n_sclass; /* storage class */
216 char n_numaux; /* number of aux. entries */
218 #define n_name _n._n_name
219 #define n_zeroes _n._n_n._n_zeroes
220 #define n_offset _n._n_n._n_offset
223 /* Relocatable symbols have number of the section in which they are defined,
224 or one of the following: */
226 #define N_UNDEF ((short)0) /* undefined symbol */
227 #define N_ABS ((short)-1) /* value of symbol is absolute */
228 #define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */
229 #define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */
230 #define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/
233 * Type of a symbol, in low N bits of the word
236 #define T_VOID 1 /* function argument (only used by compiler) */
237 #define T_CHAR 2 /* character */
238 #define T_SHORT 3 /* short integer */
239 #define T_INT 4 /* integer */
240 #define T_LONG 5 /* long integer */
241 #define T_FLOAT 6 /* floating point */
242 #define T_DOUBLE 7 /* double word */
243 #define T_STRUCT 8 /* structure */
244 #define T_UNION 9 /* union */
245 #define T_ENUM 10 /* enumeration */
246 #define T_MOE 11 /* member of enumeration*/
247 #define T_UCHAR 12 /* unsigned character */
248 #define T_USHORT 13 /* unsigned short */
249 #define T_UINT 14 /* unsigned integer */
250 #define T_ULONG 15 /* unsigned long */
251 #define T_LNGDBL 16 /* long double */
254 * derived types, in n_type
256 #define DT_NON (0) /* no derived type */
257 #define DT_PTR (1) /* pointer */
258 #define DT_FCN (2) /* function */
259 #define DT_ARY (3) /* array */
261 #define BTYPE(x) ((x) & N_BTMASK)
263 #define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
264 #define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
265 #define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
266 #define ISTAG(x) ((x)==C_STRTAG||(x)==C_UNTAG||(x)==C_ENTAG)
267 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
270 union internal_auxent
275 long l; /* str, un, or enum tag indx */
276 struct coff_ptr_struct *p;
281 unsigned short x_lnno; /* declaration line number */
282 unsigned short x_size; /* str/union/array size */
284 long x_fsize; /* size of function */
288 struct { /* if ISFCN, tag, or .bb */
289 long x_lnnoptr; /* ptr to fcn line # */
290 union { /* entry ndx past block end */
292 struct coff_ptr_struct *p;
296 struct { /* if ISARY, up to 4 dimen. */
297 unsigned short x_dimen[DIMNUM];
301 unsigned short x_tvndx; /* tv index */
305 char x_fname[FILNMLEN];
313 long x_scnlen; /* section length */
314 unsigned short x_nreloc; /* # relocation entries */
315 unsigned short x_nlinno; /* # line numbers */
319 long x_tvfill; /* tv fill value */
320 unsigned short x_tvlen; /* length of .tv */
321 unsigned short x_tvran[2]; /* tv range */
322 } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
324 /******************************************
325 * RS/6000-specific auxent - last auxent for every external symbol
326 ******************************************/
328 long x_scnlen; /* csect length */
329 long x_parmhash; /* parm type hash index */
330 unsigned short x_snhash; /* sect num with parm hash */
331 unsigned char x_smtyp; /* symbol align and type */
332 /* 0-4 - Log 2 of alignment */
333 /* 5-7 - symbol type */
334 unsigned char x_smclas; /* storage mapping class */
335 long x_stab; /* dbx stab info index */
336 unsigned short x_snstab; /* sect num with dbx stab */
337 } x_csect; /* csect definition information */
339 /* x_smtyp values: */
341 #define SMTYP_ALIGN(x) ((x) >> 3) /* log2 of alignment */
342 #define SMTYP_SMTYP(x) ((x) & 0x7) /* symbol type */
343 /* Symbol type values: */
344 #define XTY_ER 0 /* External reference */
345 #define XTY_SD 1 /* Csect definition */
346 #define XTY_LD 2 /* Label definition */
347 #define XTY_CM 3 /* .BSS */
348 #define XTY_EM 4 /* Error message */
349 #define XTY_US 5 /* "Reserved for internal use" */
351 /* x_smclas values: */
353 #define XMC_PR 0 /* Read-only program code */
354 #define XMC_RO 1 /* Read-only constant */
355 #define XMC_DB 2 /* Read-only debug dictionary table */
356 #define XMC_TC 3 /* Read-write general TOC entry */
357 #define XMC_UA 4 /* Read-write unclassified */
358 #define XMC_RW 5 /* Read-write data */
359 #define XMC_GL 6 /* Read-only global linkage */
360 #define XMC_XO 7 /* Read-only extended operation (simulated insn) */
361 #define XMC_SV 8 /* Read-only supervisor call */
362 #define XMC_BS 9 /* Read-write BSS */
363 #define XMC_DS 10 /* Read-write descriptor csect */
364 #define XMC_UC 11 /* Read-write unnamed Fortran common */
365 #define XMC_TI 12 /* Read-only traceback index csect */
366 #define XMC_TB 13 /* Read-only traceback table csect */
368 #define XMC_TC0 15 /* Read-write TOC anchor for TOC addressability */
371 /******************************************
372 * I960-specific *2nd* aux. entry formats
373 ******************************************/
375 /* This is a very old typo that keeps getting propagated. */
376 #define x_stdindx x_stindx
377 long x_stindx; /* sys. table entry */
378 } x_sc; /* system call entry */
381 unsigned long x_balntry; /* BAL entry point */
382 } x_bal; /* BAL-callable function */
385 unsigned long x_timestamp; /* time stamp */
386 char x_idstring[20]; /* producer identity string */
387 } x_ident; /* Producer ident info */
391 /********************** RELOCATION DIRECTIVES **********************/
393 struct internal_reloc {
394 long r_vaddr; /* Virtual address of reference */
395 long r_symndx; /* Index into symbol table */
396 unsigned short r_type; /* Relocation type */
399 unsigned char r_size;
403 unsigned short r_offset;
407 #define R_RELBYTE 017
408 #define R_RELWORD 020
409 #define R_PCRBYTE 022
410 #define R_PCRWORD 023
411 #define R_PCRLONG 024
415 #define R_RELBYTE 017
416 #define R_RELWORD 020
418 #define R_PCRBYTE 022
419 #define R_PCRWORD 023
420 #define R_PCRLONG 024
428 #define R_RELLONG (0x11) /* Direct 32-bit relocation */
429 #define R_IPRSHORT (0x18)
430 #define R_IPRMED (0x19) /* 24-bit ip-relative relocation */
431 #define R_IPRLONG (0x1a)
432 #define R_OPTCALL (0x1b) /* 32-bit optimizable call (leafproc/sysproc) */
433 #define R_OPTCALLX (0x1c) /* 64-bit optimizable call (leafproc/sysproc) */
434 #define R_GETSEG (0x1d)
435 #define R_GETPA (0x1e)
436 #define R_TAGWORD (0x1f)
437 #define R_JUMPTARG 0x20 /* strange 29k 00xx00xx reloc */