|
|
1.1 root 1: /* (-lgl
2: * COHERENT Version 4.0
3: * Copyright (c) 1982, 1992 by Mark Williams Company.
4: * All rights reserved. May not be copied without permission.
5: -lgl) */
6: /*
7: * coff.h
8: * Common Object File Format (COFF) header for COHERENT.
9: */
10:
11: #ifndef COFF_H /* Rest of file. */
12: #define COFF_H
13:
14: /* File header. */
15: typedef struct filehdr {
16: unsigned short f_magic; /* Magic number */
17: unsigned short f_nscns; /* Number of sections */
18: long f_timdat; /* Time and date */
19: long f_symptr; /* Seek to symbol table */
20: long f_nsyms; /* Number of symbols */
21: unsigned short f_opthdr; /* Optional header size */
22: unsigned short f_flags; /* Flags */
23: } FILEHDR;
24:
25: /* Magic number. */
26: #define C_386_MAGIC 0x14C /* Intel iAPX 80386 */
27: #define ISCOFF(x) ((x) == C_386_MAGIC)
28:
29: /* Flags for f_flags field. */
30: #define F_RELFLG 0x0001 /* No relocation info */
31: #define F_EXEC 0x0002 /* Executable */
32: #define F_LNNO 0x0004 /* No line numbers */
33: #define F_LSYMS 0x0008 /* No local symbols */
34: #define F_MINMAL 0x0010 /* product of strip */
35: #define F_AR32WR 0x0100 /* i80x86 byte order */
36: #define F_KER 0x0800 /* Loadable driver */
37:
38: /* Optional header. */
39: typedef struct aouthdr {
40: short magic; /* AOUT_MAGIC */
41: short vstamp; /* version stamp */
42: long tsize; /* .text size in bytes */
43: long dsize; /* .data size in bytes */
44: long bsize; /* .bss size in bytes */
45: long entry; /* entry point */
46: long text_start; /* base of .text data */
47: long data_start; /* base of .data data */
48: } AOUTHDR;
49:
50: /* Magic numbers for aouthdr. Coherent only supports Z_MAGIC */
51: #define O_MAGIC 0x107 /* Text and data are contiguous text not shared */
52: #define N_MAGIC 0x108 /* .data starts at seg after .text .text is protected */
53: #define I_MAGIC 0x109 /* sep id */
54: #define Z_MAGIC 0x10B /* Text and data aligned within a.out for direct page */
55:
56: /* Section header. */
57: typedef struct scnhdr {
58: char s_name[8]; /* Section name */
59: long s_paddr; /* Physical address */
60: long s_vaddr; /* Virtual address */
61: long s_size; /* Size */
62: long s_scnptr; /* Data pointer */
63: long s_relptr; /* Reloc pointer */
64: long s_lnnoptr; /* Line number pointer */
65: unsigned short s_nreloc; /* Reloc entries */
66: unsigned short s_nlnno; /* Line number entries */
67: long s_flags; /* Flags */
68: } SCNHDR;
69:
70: /* Names of special sections */
71: #define _TEXT ".text"
72: #define _DATA ".data"
73: #define _BSS ".bss"
74: #define _TV ".tv"
75: #define _INIT ".init"
76: #define _FINI ".fini"
77:
78: /* Flags for s_flags field. */
79: #define STYP_TEXT 0x20L /* Code segment */
80: #define STYP_DATA 0x40L /* Data segment */
81: #define STYP_BSS 0x80L /* BSS segment */
82:
83: /* Relocation items. */
84: typedef struct reloc {
85: long r_vaddr; /* Address (where) */
86: long r_symndx; /* Symbol index (what) */
87: unsigned short r_type; /* Type (how) */
88: #pragma align 2
89: } RELOC;
90: #pragma align
91:
92: #define RELSZ 10 /* sizeof(RELOC) */
93:
94: /* Relocation types. */
95: #define R_DIR8 0x07 /* 8-bit direct */
96: #define R_DIR16 0x01 /* 16-bit direct */
97: #define R_DIR32 0x06 /* 32-bit direct */
98: #define R_RELBYTE 0x0f /* 8 bit direct */
99: #define R_RELWORD 0x10 /* 16 bit direct */
100: #define R_RELLONG 0x11 /* 32 bit direct */
101: #define R_PCRBYTE 0x12 /* 8-bit PC-relative */
102: #define R_PCRWORD 0x13 /* 16-bit PC-relative */
103: #define R_PCRLONG 0x14 /* 32-bit PC-relative */
104: #define R_NONREL 0x00 /* fake record for ld -r */
105:
106: /* Line number. */
107: typedef struct lineno {
108: union {
109: long l_symndx; /* sym table ix of fun name */
110: long l_paddr; /* physical addr */
111: } l_addr;
112: unsigned short l_lnno; /* line number or 0 for fun */
113: #pragma align 2
114: } LINENO;
115: #pragma align
116:
117: #define LINESZ 6 /* sizeof(LINENO) */
118:
119: /* Symbol table. */
120: #define SYMNMLEN 8 /* Symbol name length */
121: #define FILNMLEN 14 /* Characters in a file name */
122: #define DIMNUM 4 /* dimensions in aux entry */
123:
124: typedef struct syment {
125: union {
126: char _n_name[SYMNMLEN]; /* Name */
127: struct {
128: long _n_zeroes; /* If name[0-3] zero, */
129: long _n_offset; /* string table offset */
130: } _n_n;
131: char *_n_nptr[2];
132: } _n;
133: long n_value; /* Value */
134: short n_scnum; /* Section number */
135: unsigned short n_type; /* Type */
136: char n_sclass; /* Storage class */
137: char n_numaux; /* Auxilliary entries */
138: #pragma align 2
139: } SYMENT;
140: #pragma align
141:
142: #define SYMESZ 18 /* sizeof(SYMENT) */
143: #define n_name _n._n_name
144: #define n_zeroes _n._n_n._n_zeroes
145: #define n_offset _n._n_n._n_offset
146:
147: /* Special section numbers */
148: #define N_UNDEF 0 /* undefined symbol */
149: #define N_ABS -1 /* absolute symbol */
150: #define N_DEBUG -2 /* special debugging symbol */
151: #define N_TV -3 /* symbol needs transfer vector (preload) */
152: #define P_TV -4 /* symbol needs transfer vector (postload) */
153:
154: /* Storage classes. */
155: #define C_EFCN -1 /* end of function */
156: #define C_NULL 0 /* none given */
157: #define C_AUTO 1 /* automatic variable */
158: #define C_EXT 2 /* External */
159: #define C_STAT 3 /* Static */
160: #define C_REG 4 /* register variable */
161: #define C_EXTDEF 5 /* External definition */
162: #define C_LABEL 6 /* label */
163: #define C_ULABEL 7 /* undefined label */
164: #define C_MOS 8 /* member of structure */
165: #define C_ARG 9 /* function argument */
166: #define C_STRTAG 10 /* structure tag */
167: #define C_MOU 11 /* member of union */
168: #define C_UNTAG 12 /* union tag */
169: #define C_TPDEF 13 /* typedef */
170: #define C_USTATIC 14 /* undefined static */
171: #define C_ENTAG 15 /* enum tag */
172: #define C_MOE 16 /* member of enum */
173: #define C_REGPARM 17 /* register parm */
174: #define C_FIELD 18 /* bit field */
175: #define C_BLOCK 100 /* .bb or .eb */
176: #define C_FCN 101 /* .bf or .ef */
177: #define C_EOS 102 /* end of structure */
178: #define C_FILE 103 /* file name */
179:
180: /* is x a tag */
181: #define ISTAG(x) (C_STRTAG==(x) || C_UNTAG==(x) || C_ENTAG==(x))
182:
183: /* fundimental type */
184: #define T_NULL 0
185: #define T_ARG 1
186: #define T_CHAR 2
187: #define T_SHORT 3
188: #define T_INT 4
189: #define T_LONG 5
190: #define T_FLOAT 6
191: #define T_DOUBLE 7
192: #define T_STRUCT 8
193: #define T_UNION 9
194: #define T_ENUM 10
195: #define T_MOE 11 /* member of enumeration */
196: #define T_UCHAR 12
197: #define T_USHORT 13
198: #define T_UINT 14
199: #define T_ULONG 15
200:
201: /* Derived Types in n_type */
202: #define DT_NON 0 /* non derived type */
203: #define DT_PTR 0x10 /* pointer */
204: #define DT_FCN 0x20 /* function */
205: #define DT_ARY 0x30 /* array */
206:
207: /* Type packing constants */
208: #define N_BTMASK 0x15 /* Mask for basic type */
209: #define N_TMASK 0x30 /* Derived type mask */
210: #define N_TSHIFT 2 /* Shift to get at more derivations */
211:
212: /* Type processing macros */
213: #define BTYPE(x) ((x) & N_BTMASK) /* Basic type of x */
214: #define ISPTR(x) (DT_PTR == ((x) & N_TMASK)) /* Is x a pointer */
215: #define ISFCN(x) (DT_FCN == ((x) & N_TMASK)) /* Is x a function */
216: #define ISARY(x) (DT_ARY == ((x) & N_TMASK)) /* Is x an array */
217: #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|DT_PTR|((x)&N_BTMASK))
218: #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
219:
220: /* Aux symbols */
221: typedef union auxent {
222: struct {
223: long x_tagndx; /* struct, union or enum tag index */
224: union {
225: struct {
226: unsigned short x_lnno; /* declaration line */
227: unsigned short x_size; /* size */
228: } x_lnsz;
229: long x_fsize; /* size of function */
230: } x_misc;
231: union {
232: struct { /* if ISFCN tag or .bb */
233: long x_lnnoptr; /* ptr to fcn line # */
234: long x_endndx; /* index past block */
235: } x_fcn;
236: struct { /* if ISARY */
237: unsigned short x_dimen[DIMNUM];
238: } x_ary;
239: } x_fcnary;
240: unsigned short x_tvndx; /* tv index */
241: } x_sym;
242: struct {
243: char x_fname[FILNMLEN];
244: } x_file;
245: struct {
246: long x_scnlen; /* section length */
247: unsigned short x_nreloc; /* reloc entrys */
248: unsigned short x_nlinno; /* line number entries */
249: } x_scn;
250: #pragma align 2
251: } AUXENT;
252: #pragma align
253:
254: #define AUXESZ 18 /* sizeof(auxent) */
255:
256: #endif /* COFF_H */
257: /* end of coff.h */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.