*** empty log message ***
[binutils-gdb.git] / include / coff-i386.h
1 /*** coff information for M68K */
2
3
4 /********************** FILE HEADER **********************/
5
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 */
14 };
15
16
17 /* Bits for f_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)
23 */
24
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
37
38 #define I386MAGIC 0514
39 #define I386BADMAG(x) (((x).f_magic!=I386MAGIC))
40 #define I386AOUTMAGIC 0413
41 #define I386AOUTVSTAMP 0000
42 #define COFF_TIMESTAMP
43
44
45 #define FILHDR struct external_filehdr
46 #define FILHSZ sizeof(FILHDR)
47
48
49 /********************** AOUT "OPTIONAL HEADER" **********************/
50
51
52 typedef struct
53 {
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 */
62 }
63 AOUTHDR;
64
65 #define AOUTSZ (sizeof(AOUTHDR))
66
67
68 /********************** STORAGE CLASSES **********************/
69
70 #define C_EFCN -1 /* physical end of function */
71 #define C_NULL 0
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 */
99
100 /********************** SECTION HEADER **********************/
101
102
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 */
114 };
115
116 /*
117 * names of "special" sections
118 */
119 #define _TEXT ".text"
120 #define _DATA ".data"
121 #define _BSS ".bss"
122 #define _COMMENT ".comment"
123 /*
124 * s_flags "type"
125 */
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. */
146
147 #define SCNHDR struct external_scnhdr
148 #define SCNHSZ sizeof(SCNHDR)
149
150
151 /********************** LINE NUMBERS **********************/
152
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.
157 */
158 struct external_lineno {
159 union {
160 char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
161 char l_paddr[4]; /* (physical) address of line number */
162 } l_addr;
163 char l_lnno[2]; /* line number */
164 };
165
166
167 #define LINENO struct external_lineno
168 #define LINESZ 6
169
170
171 /********************** SYMBOLS **********************/
172
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 */
176
177 struct external_syment
178 {
179 union {
180 char e_name[E_SYMNMLEN];
181 struct {
182 char e_zeroes[4];
183 char e_offset[4];
184 } e;
185 } e;
186 char e_value[4];
187 char e_scnum[2];
188 char e_type[2];
189 char e_sclass[1];
190 char e_numaux[1];
191 };
192
193
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
198 */
199
200 /*
201 * Relocatable symbols have number of the section in which they are defined,
202 * or one of the following:
203 */
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*/
209
210 /*
211 * Type of a symbol, in low 4 bits of the word
212 */
213 #define T_NULL 0
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 */
230
231 /*
232 * derived types, in n_type
233 */
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 */
238
239 #define N_BTMASK (0xf)
240 #define N_TMASK (0x30)
241 #define N_BTSHFT (4)
242 #define N_TSHIFT (2)
243
244 #define BTYPE(x) ((x) & N_BTMASK)
245
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))
249
250 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
251
252 union external_auxent {
253 struct {
254 char x_tagndx[4]; /* str, un, or enum tag indx */
255 union {
256 struct {
257 char x_lnno[2]; /* declaration line number */
258 char x_size[2]; /* str/union/array size */
259 } x_lnsz;
260 char x_fsize[4]; /* size of function */
261 } x_misc;
262 union {
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 */
266 } x_fcn;
267 struct { /* if ISARY, up to 4 dimen. */
268 char x_dimen[E_DIMNUM][2];
269 } x_ary;
270 } x_fcnary;
271 char x_tvndx[2]; /* tv index */
272 } x_sym;
273
274 union {
275 char x_fname[E_FILNMLEN];
276 struct {
277 char x_zeroes[4];
278 char x_offset[4];
279 } x_n;
280 } x_file;
281
282 struct {
283 char x_scnlen[4]; /* section length */
284 char x_nreloc[2]; /* # relocation entries */
285 char x_nlinno[2]; /* # line numbers */
286 } x_scn;
287
288 struct {
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)) */
293
294
295 };
296
297 #define SYMENT struct external_syment
298 #define SYMESZ 18
299 #define AUXENT union external_auxent
300 #define AUXESZ 18
301
302
303 # define _ETEXT "etext"
304
305
306 /********************** RELOCATION DIRECTIVES **********************/
307
308
309
310 struct external_reloc {
311 char r_vaddr[4];
312 char r_symndx[4];
313 char r_type[2];
314 };
315
316
317 #define RELOC struct external_reloc
318 #define RELSZ 10
319
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