1 /*** coff information for M68K */
4 /********************** FILE HEADER **********************/
6 struct external_filehdr
{
7 char f_magic
[2]; /* magic number */
8 char f_nscns
[2]; /* number of sections */
9 char f_timdat
[4]; /* time & date stamp */
10 char f_symptr
[4]; /* file pointer to symtab */
11 char f_nsyms
[4]; /* number of symtab entries */
12 char f_opthdr
[2]; /* sizeof(optional hdr) */
13 char f_flags
[2]; /* flags */
18 * F_RELFLG relocation info stripped from file
19 * F_EXEC file is executable (no unresolved external references)
20 * F_LNNO line numbers stripped from file
21 * F_LSYMS local symbols stripped from file
22 * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax)
25 #define F_RELFLG 0000001
26 #define F_EXEC 0000002
27 #define F_LNNO 0000004
28 #define F_LSYMS 0000010
29 #define F_MINMAL 0000020
30 #define F_UPDATE 0000040
31 #define F_SWABD 0000100
32 #define F_AR16WR 0000200
33 #define F_AR32WR 0000400
34 #define F_AR32W 0001000
35 #define F_PATCH 0002000
36 #define F_NODF 0002000
38 #define I386MAGIC 0514
39 #define I386BADMAG(x) (((x).f_magic!=I386MAGIC))
40 #define I386AOUTMAGIC 0413
41 #define I386AOUTVSTAMP 0000
42 #define COFF_TIMESTAMP
45 #define FILHDR struct external_filehdr
46 #define FILHSZ sizeof(FILHDR)
49 /********************** AOUT "OPTIONAL HEADER" **********************/
54 char magic
[2]; /* type of file */
55 char vstamp
[2]; /* version stamp */
56 char tsize
[4]; /* text size in bytes, padded to FW bdry*/
57 char dsize
[4]; /* initialized data " " */
58 char bsize
[4]; /* uninitialized data " " */
59 char entry
[4]; /* entry pt. */
60 char text_start
[4]; /* base of text used for this file */
61 char data_start
[4]; /* base of data used for this file */
65 #define AOUTSZ (sizeof(AOUTHDR))
68 /********************** STORAGE CLASSES **********************/
70 #define C_EFCN -1 /* physical end of function */
72 #define C_AUTO 1 /* automatic variable */
73 #define C_EXT 2 /* external symbol */
74 #define C_STAT 3 /* static */
75 #define C_REG 4 /* register variable */
76 #define C_EXTDEF 5 /* external definition */
77 #define C_LABEL 6 /* label */
78 #define C_ULABEL 7 /* undefined label */
79 #define C_MOS 8 /* member of structure */
80 #define C_ARG 9 /* function argument */
81 #define C_STRTAG 10 /* structure tag */
82 #define C_MOU 11 /* member of union */
83 #define C_UNTAG 12 /* union tag */
84 #define C_TPDEF 13 /* type definition */
85 #define C_USTATIC 14 /* undefined static */
86 #define C_ENTAG 15 /* enumeration tag */
87 #define C_MOE 16 /* member of enumeration */
88 #define C_REGPARM 17 /* register parameter */
89 #define C_FIELD 18 /* bit field */
90 #define C_AUTOARG 19 /* auto argument */
91 #define C_LASTENT 20 /* dummy entry (end of block) */
92 #define C_BLOCK 100 /* ".bb" or ".eb" */
93 #define C_FCN 101 /* ".bf" or ".ef" */
94 #define C_EOS 102 /* end of structure */
95 #define C_FILE 103 /* file name */
96 #define C_LINE 104 /* line # reformatted as symbol table entry */
97 #define C_ALIAS 105 /* duplicate tag */
98 #define C_HIDDEN 106 /* ext symbol in dmert public lib */
100 /********************** SECTION HEADER **********************/
103 struct external_scnhdr
{
104 char s_name
[8]; /* section name */
105 char s_paddr
[4]; /* physical address, aliased s_nlib */
106 char s_vaddr
[4]; /* virtual address */
107 char s_size
[4]; /* section size */
108 char s_scnptr
[4]; /* file ptr to raw data for section */
109 char s_relptr
[4]; /* file ptr to relocation */
110 char s_lnnoptr
[4]; /* file ptr to line numbers */
111 char s_nreloc
[2]; /* number of relocation entries */
112 char s_nlnno
[2]; /* number of line number entries*/
113 char s_flags
[4]; /* flags */
117 * names of "special" sections
119 #define _TEXT ".text"
120 #define _DATA ".data"
122 #define _COMMENT ".comment"
126 #define STYP_REG (0x0000) /* "regular": allocated, relocated, loaded */
127 #define STYP_DSECT (0x0001) /* "dummy": relocated only*/
128 #define STYP_NOLOAD (0x0002) /* "noload": allocated, relocated, not loaded */
129 #define STYP_GROUP (0x0004) /* "grouped": formed of input sections */
130 #define STYP_PAD (0x0008) /* "padding": not allocated, not relocated, loaded */
131 #define STYP_COPY (0x0010) /* "copy": for decision function used by field update; not allocated, not relocated,
132 loaded; reloc & lineno entries processed normally */
133 #define STYP_TEXT (0x0020) /* section contains text only */
134 #define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile
135 will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will
136 update all process invocations. */
137 #define STYP_DATA (0x0040) /* section contains data only */
138 #define STYP_BSS (0x0080) /* section contains bss only */
139 #define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */
140 #define STYP_INFO (0x0200) /* comment: not allocated not relocated, not loaded */
141 #define STYP_OVER (0x0400) /* overlay: relocated not allocated or loaded */
142 #define STYP_LIB (0x0800) /* for .lib: same as INFO */
143 #define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */
144 #define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions wherever padding is necessary and there is a
145 word of contiguous bytes beginning on a word boundary. */
147 #define SCNHDR struct external_scnhdr
148 #define SCNHSZ sizeof(SCNHDR)
151 /********************** LINE NUMBERS **********************/
153 /* 1 line number entry for every "breakpointable" source line in a section.
154 * Line numbers are grouped on a per function basis; first entry in a function
155 * grouping will have l_lnno = 0 and in place of physical address will be the
156 * symbol table index of the function name.
158 struct external_lineno
{
160 char l_symndx
[4]; /* function name symbol index, iff l_lnno == 0*/
161 char l_paddr
[4]; /* (physical) address of line number */
163 char l_lnno
[2]; /* line number */
167 #define LINENO struct external_lineno
171 /********************** SYMBOLS **********************/
173 #define E_SYMNMLEN 8 /* # characters in a symbol name */
174 #define E_FILNMLEN 14 /* # characters in a file name */
175 #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
177 struct external_syment
180 char e_name
[E_SYMNMLEN
];
194 /*#define n_name _n._n_name
195 #define n_ptr _n._n_nptr[1]
196 #define n_zeroes _n._n_n._n_zeroes
197 #define n_offset _n._n_n._n_offset
201 * Relocatable symbols have number of the section in which they are defined,
202 * or one of the following:
204 #define N_UNDEF ((short)0) /* undefined symbol */
205 #define N_ABS ((short)-1) /* value of symbol is absolute */
206 #define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */
207 #define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */
208 #define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/
211 * Type of a symbol, in low 4 bits of the word
214 #define T_VOID 1 /* function argument (only used by compiler) */
215 #define T_CHAR 2 /* character */
216 #define T_SHORT 3 /* short integer */
217 #define T_INT 4 /* integer */
218 #define T_LONG 5 /* long integer */
219 #define T_FLOAT 6 /* floating point */
220 #define T_DOUBLE 7 /* double word */
221 #define T_STRUCT 8 /* structure */
222 #define T_UNION 9 /* union */
223 #define T_ENUM 10 /* enumeration */
224 #define T_MOE 11 /* member of enumeration*/
225 #define T_UCHAR 12 /* unsigned character */
226 #define T_USHORT 13 /* unsigned short */
227 #define T_UINT 14 /* unsigned integer */
228 #define T_ULONG 15 /* unsigned long */
229 #define T_LNGDBL 16 /* long double */
232 * derived types, in n_type
234 #define DT_NON (0) /* no derived type */
235 #define DT_PTR (1) /* pointer */
236 #define DT_FCN (2) /* function */
237 #define DT_ARY (3) /* array */
239 #define N_BTMASK (0xf)
240 #define N_TMASK (0x30)
244 #define BTYPE(x) ((x) & N_BTMASK)
246 #define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
247 #define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
248 #define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
250 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
252 union external_auxent
{
254 char x_tagndx
[4]; /* str, un, or enum tag indx */
257 char x_lnno
[2]; /* declaration line number */
258 char x_size
[2]; /* str/union/array size */
260 char x_fsize
[4]; /* size of function */
263 struct { /* if ISFCN, tag, or .bb */
264 char x_lnnoptr
[4]; /* ptr to fcn line # */
265 char x_endndx
[4]; /* entry ndx past block end */
267 struct { /* if ISARY, up to 4 dimen. */
268 char x_dimen
[E_DIMNUM
][2];
271 char x_tvndx
[2]; /* tv index */
275 char x_fname
[E_FILNMLEN
];
283 char x_scnlen
[4]; /* section length */
284 char x_nreloc
[2]; /* # relocation entries */
285 char x_nlinno
[2]; /* # line numbers */
289 char x_tvfill
[4]; /* tv fill value */
290 char x_tvlen
[2]; /* length of .tv */
291 char x_tvran
[2][2]; /* tv range */
292 } x_tv
; /* info about .tv section (in auxent of symbol .tv)) */
297 #define SYMENT struct external_syment
299 #define AUXENT union external_auxent
303 # define _ETEXT "etext"
306 /********************** RELOCATION DIRECTIVES **********************/
310 struct external_reloc
{
317 #define RELOC struct external_reloc
320 #define DEFAULT_DATA_SECTION_ALIGNMENT 4
321 #define DEFAULT_BSS_SECTION_ALIGNMENT 4
322 #define DEFAULT_TEXT_SECTION_ALIGNMENT 4
323 #define DEFAULT_COMMENT_SECTION_ALIGNMENT 4
324 /* For new sections we havn't heard of before */
325 #define DEFAULT_SECTION_ALIGNMENT 4