|
|
1.1 root 1: /* (-lgl
2: * COHERENT Version 4.1.0
3: * Copyright (c) 1982, 1993 by Mark Williams Company.
4: * All rights reserved. May not be copied without permission.
5: -lgl) */
6: /*
7: * /usr/include/coff.h
8: *
9: * Common Object File Format (COFF) header for COHERENT.
10: *
11: * Revised Mon Mar 29 14:28:09 1993 CST
12: */
13:
14: #ifndef __COFF_H__
15: #define __COFF_H__
16:
17: /* File header. */
18: typedef struct filehdr {
19: unsigned short f_magic; /* Magic number */
20: unsigned short f_nscns; /* Number of sections */
21: long f_timdat; /* Time and date */
22: long f_symptr; /* Seek to symbol table */
23: long f_nsyms; /* Number of symbols */
24: unsigned short f_opthdr; /* Optional header size */
25: unsigned short f_flags; /* Flags */
26: } FILEHDR;
27:
28: /* Magic number. */
29: #define C_386_MAGIC 0x14C /* Intel iAPX 80386 */
30: #define ISCOFF(x) ((x) == C_386_MAGIC)
31:
32: /* Flags for f_flags field. */
33: #define F_RELFLG 0x0001 /* No relocation info */
34: #define F_EXEC 0x0002 /* Executable */
35: #define F_LNNO 0x0004 /* No line numbers */
36: #define F_LSYMS 0x0008 /* No local symbols */
37: #define F_MINMAL 0x0010 /* Product of strip */
38: #define F_AR32WR 0x0100 /* i80x86 byte order */
39: #define F_KER 0x0800 /* Loadable driver */
40:
41: /* Optional header. */
42: typedef struct aouthdr {
43: short magic; /* AOUT_MAGIC */
44: short vstamp; /* Version stamp */
45: long tsize; /* .text size in bytes */
46: long dsize; /* .data size in bytes */
47: long bsize; /* .bss size in bytes */
48: long entry; /* Entry point */
49: long text_start; /* Base of .text data */
50: long data_start; /* Base of .data data */
51: } AOUTHDR;
52:
53: /* Magic numbers for aouthdr.magic; COHERENT only supports Z_MAGIC. */
54: #define O_MAGIC 0x107 /* .text and .data are contiguous, .text not shared */
55: #define N_MAGIC 0x108 /* .data starts at seg after .text .text is protected */
56: #define I_MAGIC 0x109 /* sep id */
57: #define Z_MAGIC 0x10B /* .text and .data aligned for direct page */
58:
59: /* Section header. */
60: typedef struct scnhdr {
61: char s_name[8]; /* Section name */
62: long s_paddr; /* Physical address */
63: long s_vaddr; /* Virtual address */
64: long s_size; /* Size */
65: long s_scnptr; /* Data pointer */
66: long s_relptr; /* Reloc pointer */
67: long s_lnnoptr; /* Line number pointer */
68: unsigned short s_nreloc; /* Reloc entries */
69: unsigned short s_nlnno; /* Line number entries */
70: long s_flags; /* Flags */
71: } SCNHDR;
72:
73: /* Names of special sections */
74: #define _TEXT ".text"
75: #define _DATA ".data"
76: #define _BSS ".bss"
77: #define _COMMENT ".comment"
78: #define _TV ".tv"
79: #define _INIT ".init"
80: #define _FINI ".fini"
81: #define _RODATA ".rodata"
82:
83: /* Flags for s_flags field. */
84: #define STYP_GROUP 0x004L /* Grouped section */
85: #define STYP_PAD 0x008L /* Padding section */
86: #define STYP_COPY 0x010L /* Copy section */
87: #define STYP_TEXT 0x020L /* Code segment */
88: #define STYP_DATA 0x040L /* Data segment */
89: #define STYP_BSS 0x080L /* BSS segment */
90: #define STYP_INFO 0x200L /* Comment section */
91: #define STYP_OVER 0x400L /* Overlay section */
92: #define STYP_LIB 0x800L /* Shared library */
93:
94: /*
95: * Shared Library Section.
96: * Followed by implementation dependent data
97: * and a path name aligned on a dword boundary.
98: */
99: typedef struct shrlib {
100: long entsz; /* Entry size in longs */
101: long pathndx; /* Path offset in longs */
102: } SHRLIB;
103:
104:
105: /* Relocation items. */
106: typedef struct reloc {
107: long r_vaddr; /* Address (where) */
108: long r_symndx; /* Symbol index (what) */
109: unsigned short r_type; /* Type (how) */
110: #pragma align 2
111: } RELOC;
112: #pragma align
113:
114: #define RELSZ (sizeof(RELOC))
115:
116: /* Relocation types. */
117: #define R_DIR8 0x07 /* 8-bit direct */
118: #define R_DIR16 0x01 /* 16-bit direct */
119: #define R_DIR32 0x06 /* 32-bit direct */
120: #define R_RELBYTE 0x0f /* 8 bit direct */
121: #define R_RELWORD 0x10 /* 16 bit direct */
122: #define R_RELLONG 0x11 /* 32 bit direct */
123: #define R_PCRBYTE 0x12 /* 8-bit PC-relative */
124: #define R_PCRWORD 0x13 /* 16-bit PC-relative */
125: #define R_PCRLONG 0x14 /* 32-bit PC-relative */
126: #define R_NONREL 0x00 /* Fake item for ld -r */
127:
128: /* Line number. */
129: typedef struct lineno {
130: union {
131: long l_symndx; /* Fn name symbol index */
132: long l_paddr; /* Physical address */
133: } l_addr;
134: unsigned short l_lnno; /* Line num., 0 for fn */
135: #pragma align 2
136: } LINENO;
137: #pragma align
138:
139: #define LINESZ (sizeof(LINENO))
140:
141: /* Symbol table. */
142: #define SYMNMLEN 8 /* Symbol name length */
143: #define FILNMLEN 14 /* Chars in file name */
144: #define DIMNUM 4 /* Dims in aux entry */
145:
146: typedef struct syment {
147: union {
148: char _n_name[SYMNMLEN]; /* Name */
149: struct {
150: long _n_zeroes; /* If name[0-3] zero, */
151: long _n_offset; /* string table offset */
152: } _n_n;
153: char *_n_nptr[2];
154: } _n;
155: long n_value; /* Value */
156: short n_scnum; /* Section number */
157: unsigned short n_type; /* Type */
158: char n_sclass; /* Storage class */
159: char n_numaux; /* Auxilliary entries */
160: #pragma align 2
161: } SYMENT;
162: #pragma align
163:
164: #define SYMESZ (sizeof(SYMENT))
165: #define n_name _n._n_name
166: #define n_zeroes _n._n_n._n_zeroes
167: #define n_offset _n._n_n._n_offset
168:
169: /* Special section numbers */
170: #define N_UNDEF 0 /* Undefined */
171: #define N_ABS -1 /* Absolute */
172: #define N_DEBUG -2 /* Debug */
173: #define N_TV -3 /* Needs preload transfer vector */
174: #define P_TV -4 /* Needs postload transfer vector */
175:
176: /* Storage classes. */
177: #define C_EFCN -1 /* End of function */
178: #define C_NULL 0 /* None */
179: #define C_AUTO 1 /* Automatic */
180: #define C_EXT 2 /* External */
181: #define C_STAT 3 /* Static */
182: #define C_REG 4 /* Register */
183: #define C_EXTDEF 5 /* External definition */
184: #define C_LABEL 6 /* Label */
185: #define C_ULABEL 7 /* Undefined label */
186: #define C_MOS 8 /* Member of structure */
187: #define C_ARG 9 /* Function argument */
188: #define C_STRTAG 10 /* Structure tag */
189: #define C_MOU 11 /* Member of union */
190: #define C_UNTAG 12 /* Union tag */
191: #define C_TPDEF 13 /* Typedef */
192: #define C_USTATIC 14 /* Undefined static */
193: #define C_ENTAG 15 /* Enum tag */
194: #define C_MOE 16 /* Member of enum */
195: #define C_REGPARM 17 /* Register parameter */
196: #define C_FIELD 18 /* Bit field */
197: #define C_BLOCK 100 /* Block (.bb or .eb) */
198: #define C_FCN 101 /* Function (.bf or .ef) */
199: #define C_EOS 102 /* End of structure */
200: #define C_FILE 103 /* File name */
201:
202: #define ISTAG(x) (C_STRTAG==(x) || C_UNTAG==(x) || C_ENTAG==(x))
203:
204: /* Fundimental types. */
205: #define T_NULL 0
206: #define T_ARG 1
207: #define T_CHAR 2
208: #define T_SHORT 3
209: #define T_INT 4
210: #define T_LONG 5
211: #define T_FLOAT 6
212: #define T_DOUBLE 7
213: #define T_STRUCT 8
214: #define T_UNION 9
215: #define T_ENUM 10
216: #define T_MOE 11 /* Member of enumeration */
217: #define T_UCHAR 12
218: #define T_USHORT 13
219: #define T_UINT 14
220: #define T_ULONG 15
221:
222: /* Derived types in n_type. */
223: #define DT_NON 0 /* Non-derived type */
224: #define DT_PTR 1 /* Pointer */
225: #define DT_FCN 2 /* Function */
226: #define DT_ARY 3 /* Array */
227:
228: /* Type packing constants. */
229: #define N_BTMASK 0x0F /* Mask for basic type */
230: #define N_TMASK 0x30 /* Derived type mask */
231: #define N_TSHIFT 2 /* Shift for more derived bits */
232: #define N_BTSHFT 4 /* Shift for derived type */
233:
234: /* Type processing macros. */
235: #define BTYPE(x) ((x) & N_BTMASK) /* Base type */
236: #define ISPTR(x) ((DT_PTR<<N_BTSHFT)==((x)&N_TMASK)) /* Pointer? */
237: #define ISFCN(x) ((DT_FCN<<N_BTSHFT)==((x)&N_TMASK)) /* Function? */
238: #define ISARY(x) ((DT_ARY<<N_BTSHFT)==((x)&N_TMASK)) /* Array? */
239: #define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(DT_PTR<<N_BTSHFT)|((x)&N_BTMASK))
240: #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
241:
242: /* Symbol aux entries. */
243: typedef union auxent {
244: #pragma align 2
245: struct {
246: long x_tagndx; /* struct/union/enum tag index */
247: union {
248: struct {
249: unsigned short x_lnno; /* Decl. line */
250: unsigned short x_size; /* Size */
251: } x_lnsz;
252: long x_fsize; /* Function size */
253: } x_misc;
254: union {
255: struct { /* Functions */
256: long x_lnnoptr; /* line # ptr */
257: long x_endndx; /* index of .eb */
258: } x_fcn;
259: struct { /* Arrays */
260: unsigned short x_dimen[DIMNUM]; /* Dims */
261: } x_ary;
262: } x_fcnary;
263: unsigned short x_tvndx; /* TV index */
264: } x_sym;
265: struct { /* File names */
266: char x_fname[FILNMLEN]; /* File name */
267: } x_file;
268: struct { /* Sections */
269: long x_scnlen; /* Section length */
270: unsigned short x_nreloc; /* Reloc entrys */
271: unsigned short x_nlinno; /* Line number entries */
272: } x_scn;
273: } AUXENT;
274: #pragma align
275: #define ae_tagndx x_sym.x_tagndx
276: #define ae_lnno x_sym.x_misc.x_lnsz.x_lnno
277: #define ae_size x_sym.x_misc.x_lnsz.x_size
278: #define ae_fsize x_sym.x_misc.x_fsize
279: #define ae_lnnoptr x_sym.x_fcnary.x_fcn.x_lnnoptr
280: #define ae_endndx x_sym.x_fcnary.x_fcn.x_endndx
281: #define ae_dimen x_sym.x_fcnary.x_ary.x_dimen
282: #define ae_tvndx x_sym.x_tvndx
283: #define ae_fname x_file.x_fname
284: #define ae_scnlen x_scn.x_scnlen
285: #define ae_nreloc x_scn.x_nreloc
286: #define ae_nlinno x_scn.x_nlinno
287: #define AUXESZ (sizeof(AUXENT))
288:
289: #endif /* COFF_H */
290:
291: /* end of coff.h */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.