|
|
1.1 root 1: /* (-lgl
2: * COHERENT Version 4.0.1
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
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.magic; 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 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 (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 item for ld -r */
105:
106: /* Line number. */
107: typedef struct lineno {
108: union {
109: long l_symndx; /* Fn name symbol index */
110: long l_paddr; /* Physical address */
111: } l_addr;
112: unsigned short l_lnno; /* Line num., 0 for fn */
113: #pragma align 2
114: } LINENO;
115: #pragma align
116:
117: #define LINESZ (sizeof(LINENO))
118:
119: /* Symbol table. */
120: #define SYMNMLEN 8 /* Symbol name length */
121: #define FILNMLEN 14 /* Chars in file name */
122: #define DIMNUM 4 /* Dims 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 (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 */
149: #define N_ABS -1 /* Absolute */
150: #define N_DEBUG -2 /* Debug */
151: #define N_TV -3 /* Needs preload transfer vector */
152: #define P_TV -4 /* Needs postload transfer vector */
153:
154: /* Storage classes. */
155: #define C_EFCN -1 /* End of function */
156: #define C_NULL 0 /* None */
157: #define C_AUTO 1 /* Automatic */
158: #define C_EXT 2 /* External */
159: #define C_STAT 3 /* Static */
160: #define C_REG 4 /* Register */
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 parameter */
174: #define C_FIELD 18 /* Bit field */
175: #define C_BLOCK 100 /* Block (.bb or .eb) */
176: #define C_FCN 101 /* Function (.bf or .ef) */
177: #define C_EOS 102 /* End of structure */
178: #define C_FILE 103 /* File name */
179:
180: #define ISTAG(x) (C_STRTAG==(x) || C_UNTAG==(x) || C_ENTAG==(x))
181:
182: /* Fundimental types. */
183: #define T_NULL 0
184: #define T_ARG 1
185: #define T_CHAR 2
186: #define T_SHORT 3
187: #define T_INT 4
188: #define T_LONG 5
189: #define T_FLOAT 6
190: #define T_DOUBLE 7
191: #define T_STRUCT 8
192: #define T_UNION 9
193: #define T_ENUM 10
194: #define T_MOE 11 /* Member of enumeration */
195: #define T_UCHAR 12
196: #define T_USHORT 13
197: #define T_UINT 14
198: #define T_ULONG 15
199:
200: /* Derived types in n_type. */
201: #define DT_NON 0 /* Non-derived type */
202: #define DT_PTR 0x10 /* Pointer */
203: #define DT_FCN 0x20 /* Function */
204: #define DT_ARY 0x30 /* Array */
205:
206: /* Type packing constants. */
207: #define N_BTMASK 0x0F /* Mask for basic type */
208: #define N_TMASK 0x30 /* Derived type mask */
209: #define N_TSHIFT 2 /* Shift for more derived bits */
210:
211: /* Type processing macros. */
212: #define BTYPE(x) ((x) & N_BTMASK) /* Base type */
213: #define ISPTR(x) (DT_PTR == ((x) & N_TMASK)) /* Pointer? */
214: #define ISFCN(x) (DT_FCN == ((x) & N_TMASK)) /* Function? */
215: #define ISARY(x) (DT_ARY == ((x) & N_TMASK)) /* Array? */
216: #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|DT_PTR|((x)&N_BTMASK))
217: #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
218:
219: /* Symbol aux entries. */
220: typedef union auxent {
221: #pragma align 2
222: struct {
223: long x_tagndx; /* struct/union/enum tag index */
224: union {
225: struct {
226: unsigned short x_lnno; /* Decl. line */
227: unsigned short x_size; /* Size */
228: } x_lnsz;
229: long x_fsize; /* Function size */
230: } x_misc;
231: union {
232: struct { /* Functions */
233: long x_lnnoptr; /* line # ptr */
234: long x_endndx; /* index of .eb */
235: } x_fcn;
236: struct { /* Arrays */
237: unsigned short x_dimen[DIMNUM]; /* Dims */
238: } x_ary;
239: } x_fcnary;
240: unsigned short x_tvndx; /* TV index */
241: } x_sym;
242: struct { /* File names */
243: char x_fname[FILNMLEN]; /* File name */
244: } x_file;
245: struct { /* Sections */
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: } AUXENT;
251: #pragma align
252:
253: #define AUXESZ (sizeof(AUXENT))
254:
255: #endif /* COFF_H */
256:
257: /* end of coff.h */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.