Correct comment.
[deliverable/binutils-gdb.git] / include / coff / internal.h
1 /* Internal format of COFF object file data structures, for GNU BFD.
2 This file is part of BFD, the Binary File Descriptor library. */
3
4 /* First, make "signed char" work, even on old compilers. */
5 #ifndef signed
6 #ifndef __STDC__
7 #define signed /**/
8 #endif
9 #endif
10
11 /********************** FILE HEADER **********************/
12 struct internal_filehdr
13 {
14 unsigned short f_magic; /* magic number */
15 unsigned short f_nscns; /* number of sections */
16 long f_timdat; /* time & date stamp */
17 bfd_vma f_symptr; /* file pointer to symtab */
18 long f_nsyms; /* number of symtab entries */
19 unsigned short f_opthdr; /* sizeof(optional hdr) */
20 unsigned short f_flags; /* flags */
21 };
22
23 /* Bits for f_flags:
24 * F_RELFLG relocation info stripped from file
25 * F_EXEC file is executable (no unresolved external references)
26 * F_LNNO line numbers stripped from file
27 * F_LSYMS local symbols stripped from file
28 * F_AR16WR file is 16-bit little-endian
29 * F_AR32WR file is 32-bit little-endian
30 * F_AR32W file is 32-bit big-endian
31 * F_DYNLOAD rs/6000 aix: dynamically loadable w/imports & exports
32 * F_SHROBJ rs/6000 aix: file is a shared object
33 */
34
35 #define F_RELFLG (0x0001)
36 #define F_EXEC (0x0002)
37 #define F_LNNO (0x0004)
38 #define F_LSYMS (0x0008)
39 #define F_AR16WR (0x0080)
40 #define F_AR32WR (0x0100)
41 #define F_AR32W (0x0200)
42 #define F_DYNLOAD (0x1000)
43 #define F_SHROBJ (0x2000)
44
45 /********************** AOUT "OPTIONAL HEADER" **********************/
46 struct internal_aouthdr
47 {
48 short magic; /* type of file */
49 short vstamp; /* version stamp */
50 bfd_vma tsize; /* text size in bytes, padded to FW bdry*/
51 bfd_vma dsize; /* initialized data " " */
52 bfd_vma bsize; /* uninitialized data " " */
53 bfd_vma entry; /* entry pt. */
54 bfd_vma text_start; /* base of text used for this file */
55 bfd_vma data_start; /* base of data used for this file */
56
57 /* i960 stuff */
58 unsigned long tagentries; /* number of tag entries to follow */
59
60 /* RS/6000 stuff */
61 unsigned long o_toc; /* address of TOC */
62 short o_snentry; /* section number for entry point */
63 short o_sntext; /* section number for text */
64 short o_sndata; /* section number for data */
65 short o_sntoc; /* section number for toc */
66 short o_snloader; /* section number for loader section */
67 short o_snbss; /* section number for bss */
68 short o_algntext; /* max alignment for text */
69 short o_algndata; /* max alignment for data */
70 short o_modtype; /* Module type field, 1R,RE,RO */
71 unsigned long o_maxstack; /* max stack size allowed. */
72
73 /* ECOFF stuff */
74 bfd_vma bss_start; /* Base of bss section. */
75 bfd_vma gp_value; /* GP register value. */
76 unsigned long gprmask; /* General registers used. */
77 unsigned long cprmask[4]; /* Coprocessor registers used. */
78 unsigned long fprmask; /* Floating pointer registers used. */
79
80 /* Apollo stuff */
81 long o_inlib;
82 long o_sri;
83 long vid[2];
84 };
85
86 /********************** STORAGE CLASSES **********************/
87
88 /* This used to be defined as -1, but now n_sclass is unsigned. */
89 #define C_EFCN 0xff /* physical end of function */
90 #define C_NULL 0
91 #define C_AUTO 1 /* automatic variable */
92 #define C_EXT 2 /* external symbol */
93 #define C_STAT 3 /* static */
94 #define C_REG 4 /* register variable */
95 #define C_EXTDEF 5 /* external definition */
96 #define C_LABEL 6 /* label */
97 #define C_ULABEL 7 /* undefined label */
98 #define C_MOS 8 /* member of structure */
99 #define C_ARG 9 /* function argument */
100 #define C_STRTAG 10 /* structure tag */
101 #define C_MOU 11 /* member of union */
102 #define C_UNTAG 12 /* union tag */
103 #define C_TPDEF 13 /* type definition */
104 #define C_USTATIC 14 /* undefined static */
105 #define C_ENTAG 15 /* enumeration tag */
106 #define C_MOE 16 /* member of enumeration */
107 #define C_REGPARM 17 /* register parameter */
108 #define C_FIELD 18 /* bit field */
109 #define C_AUTOARG 19 /* auto argument */
110 #define C_LASTENT 20 /* dummy entry (end of block) */
111 #define C_BLOCK 100 /* ".bb" or ".eb" */
112 #define C_FCN 101 /* ".bf" or ".ef" */
113 #define C_EOS 102 /* end of structure */
114 #define C_FILE 103 /* file name */
115 #define C_LINE 104 /* line # reformatted as symbol table entry */
116 #define C_ALIAS 105 /* duplicate tag */
117 #define C_HIDDEN 106 /* ext symbol in dmert public lib */
118
119 /* New storage classes for 80960 */
120
121 /* C_LEAFPROC is obsolete. Use C_LEAFEXT or C_LEAFSTAT */
122 #define C_LEAFPROC 108 /* Leaf procedure, "call" via BAL */
123
124 #define C_SCALL 107 /* Procedure reachable via system call */
125 #define C_LEAFEXT 108 /* External leaf */
126 #define C_LEAFSTAT 113 /* Static leaf */
127 #define C_OPTVAR 109 /* Optimized variable */
128 #define C_DEFINE 110 /* Preprocessor #define */
129 #define C_PRAGMA 111 /* Advice to compiler or linker */
130 #define C_SEGMENT 112 /* 80960 segment name */
131
132 /* Storage classes for m88k */
133 #define C_SHADOW 107 /* shadow symbol */
134 #define C_VERSION 108 /* coff version symbol */
135
136 /* New storage classes for RS/6000 */
137 #define C_HIDEXT 107 /* Un-named external symbol */
138 #define C_BINCL 108 /* Marks beginning of include file */
139 #define C_EINCL 109 /* Marks ending of include file */
140
141 /* storage classes for stab symbols for RS/6000 */
142 #define C_GSYM (0x80)
143 #define C_LSYM (0x81)
144 #define C_PSYM (0x82)
145 #define C_RSYM (0x83)
146 #define C_RPSYM (0x84)
147 #define C_STSYM (0x85)
148 #define C_TCSYM (0x86)
149 #define C_BCOMM (0x87)
150 #define C_ECOML (0x88)
151 #define C_ECOMM (0x89)
152 #define C_DECL (0x8c)
153 #define C_ENTRY (0x8d)
154 #define C_FUN (0x8e)
155 #define C_BSTAT (0x8f)
156 #define C_ESTAT (0x90)
157
158 /********************** SECTION HEADER **********************/
159 struct internal_scnhdr
160 {
161 char s_name[8]; /* section name */
162 bfd_vma s_paddr; /* physical address, aliased s_nlib */
163 bfd_vma s_vaddr; /* virtual address */
164 bfd_vma s_size; /* section size */
165 bfd_vma s_scnptr; /* file ptr to raw data for section */
166 bfd_vma s_relptr; /* file ptr to relocation */
167 bfd_vma s_lnnoptr; /* file ptr to line numbers */
168 unsigned long s_nreloc; /* number of relocation entries */
169 unsigned long s_nlnno; /* number of line number entries*/
170 long s_flags; /* flags */
171 long s_align; /* used on I960 */
172 };
173
174 /*
175 * s_flags "type"
176 */
177 #define STYP_REG (0x0000) /* "regular": allocated, relocated, loaded */
178 #define STYP_DSECT (0x0001) /* "dummy": relocated only*/
179 #define STYP_NOLOAD (0x0002) /* "noload": allocated, relocated, not loaded */
180 #define STYP_GROUP (0x0004) /* "grouped": formed of input sections */
181 #define STYP_PAD (0x0008) /* "padding": not allocated, not relocated, loaded */
182 #define STYP_COPY (0x0010) /* "copy": for decision function used by field update; not allocated, not relocated,
183 loaded; reloc & lineno entries processed normally */
184 #define STYP_TEXT (0x0020) /* section contains text only */
185 #define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile
186 will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will
187 update all process invocations. */
188 #define STYP_DATA (0x0040) /* section contains data only */
189 #define STYP_BSS (0x0080) /* section contains bss only */
190 #define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */
191 #define STYP_INFO (0x0200) /* comment: not allocated not relocated, not loaded */
192 #define STYP_OVER (0x0400) /* overlay: relocated not allocated or loaded */
193 #define STYP_LIB (0x0800) /* for .lib: same as INFO */
194 #define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */
195 #define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions wherever padding is necessary and there is a
196
197 word of contiguous bytes
198 beginning on a word boundary. */
199
200 #define STYP_LIT 0x8020 /* Literal data (like STYP_TEXT) */
201 /********************** LINE NUMBERS **********************/
202
203 /* 1 line number entry for every "breakpointable" source line in a section.
204 * Line numbers are grouped on a per function basis; first entry in a function
205 * grouping will have l_lnno = 0 and in place of physical address will be the
206 * symbol table index of the function name.
207 */
208
209 struct internal_lineno
210 {
211 union
212 {
213 long l_symndx; /* function name symbol index, iff l_lnno == 0*/
214 long l_paddr; /* (physical) address of line number */
215 } l_addr;
216 unsigned long l_lnno; /* line number */
217 };
218
219 /********************** SYMBOLS **********************/
220
221 #define SYMNMLEN 8 /* # characters in a symbol name */
222 #define FILNMLEN 14 /* # characters in a file name */
223 #define DIMNUM 4 /* # array dimensions in auxiliary entry */
224
225 struct internal_syment
226 {
227 union
228 {
229 char _n_name[SYMNMLEN]; /* old COFF version */
230 struct
231 {
232 long _n_zeroes; /* new == 0 */
233 long _n_offset; /* offset into string table */
234 } _n_n;
235 char *_n_nptr[2]; /* allows for overlaying */
236 } _n;
237 long n_value; /* value of symbol */
238 short n_scnum; /* section number */
239 unsigned short n_flags; /* copy of flags from filhdr */
240 unsigned short n_type; /* type and derived type */
241 unsigned char n_sclass; /* storage class */
242 char n_numaux; /* number of aux. entries */
243 };
244
245 #define n_name _n._n_name
246 #define n_zeroes _n._n_n._n_zeroes
247 #define n_offset _n._n_n._n_offset
248
249
250 /* Relocatable symbols have number of the section in which they are defined,
251 or one of the following: */
252
253 #define N_UNDEF ((short)0) /* undefined symbol */
254 #define N_ABS ((short)-1) /* value of symbol is absolute */
255 #define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */
256 #define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */
257 #define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/
258
259 /*
260 * Type of a symbol, in low N bits of the word
261 */
262 #define T_NULL 0
263 #define T_VOID 1 /* function argument (only used by compiler) */
264 #define T_CHAR 2 /* character */
265 #define T_SHORT 3 /* short integer */
266 #define T_INT 4 /* integer */
267 #define T_LONG 5 /* long integer */
268 #define T_FLOAT 6 /* floating point */
269 #define T_DOUBLE 7 /* double word */
270 #define T_STRUCT 8 /* structure */
271 #define T_UNION 9 /* union */
272 #define T_ENUM 10 /* enumeration */
273 #define T_MOE 11 /* member of enumeration*/
274 #define T_UCHAR 12 /* unsigned character */
275 #define T_USHORT 13 /* unsigned short */
276 #define T_UINT 14 /* unsigned integer */
277 #define T_ULONG 15 /* unsigned long */
278 #define T_LNGDBL 16 /* long double */
279
280 /*
281 * derived types, in n_type
282 */
283 #define DT_NON (0) /* no derived type */
284 #define DT_PTR (1) /* pointer */
285 #define DT_FCN (2) /* function */
286 #define DT_ARY (3) /* array */
287
288 #define BTYPE(x) ((x) & N_BTMASK)
289
290 #define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
291 #define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
292 #define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
293 #define ISTAG(x) ((x)==C_STRTAG||(x)==C_UNTAG||(x)==C_ENTAG)
294 #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
295
296
297 union internal_auxent
298 {
299 struct
300 {
301
302 union
303 {
304 long l; /* str, un, or enum tag indx */
305 struct coff_ptr_struct *p;
306 } x_tagndx;
307
308 union
309 {
310 struct
311 {
312 unsigned short x_lnno; /* declaration line number */
313 unsigned short x_size; /* str/union/array size */
314 } x_lnsz;
315 long x_fsize; /* size of function */
316 } x_misc;
317
318 union
319 {
320 struct
321 { /* if ISFCN, tag, or .bb */
322 long x_lnnoptr; /* ptr to fcn line # */
323 union
324 { /* entry ndx past block end */
325 long l;
326 struct coff_ptr_struct *p;
327 } x_endndx;
328 } x_fcn;
329
330 struct
331 { /* if ISARY, up to 4 dimen. */
332 unsigned short x_dimen[DIMNUM];
333 } x_ary;
334 } x_fcnary;
335
336 unsigned short x_tvndx; /* tv index */
337 } x_sym;
338
339 union
340 {
341 char x_fname[FILNMLEN];
342 struct
343 {
344 long x_zeroes;
345 long x_offset;
346 } x_n;
347 } x_file;
348
349 struct
350 {
351 long x_scnlen; /* section length */
352 unsigned short x_nreloc; /* # relocation entries */
353 unsigned short x_nlinno; /* # line numbers */
354 } x_scn;
355
356 struct
357 {
358 long x_tvfill; /* tv fill value */
359 unsigned short x_tvlen; /* length of .tv */
360 unsigned short x_tvran[2]; /* tv range */
361 } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
362
363 /******************************************
364 * RS/6000-specific auxent - last auxent for every external symbol
365 ******************************************/
366 struct
367 {
368 long x_scnlen; /* csect length */
369 long x_parmhash; /* parm type hash index */
370 unsigned short x_snhash; /* sect num with parm hash */
371 unsigned char x_smtyp; /* symbol align and type */
372 /* 0-4 - Log 2 of alignment */
373 /* 5-7 - symbol type */
374 unsigned char x_smclas; /* storage mapping class */
375 long x_stab; /* dbx stab info index */
376 unsigned short x_snstab; /* sect num with dbx stab */
377 } x_csect; /* csect definition information */
378
379 /* x_smtyp values: */
380
381 #define SMTYP_ALIGN(x) ((x) >> 3) /* log2 of alignment */
382 #define SMTYP_SMTYP(x) ((x) & 0x7) /* symbol type */
383 /* Symbol type values: */
384 #define XTY_ER 0 /* External reference */
385 #define XTY_SD 1 /* Csect definition */
386 #define XTY_LD 2 /* Label definition */
387 #define XTY_CM 3 /* .BSS */
388 #define XTY_EM 4 /* Error message */
389 #define XTY_US 5 /* "Reserved for internal use" */
390
391 /* x_smclas values: */
392
393 #define XMC_PR 0 /* Read-only program code */
394 #define XMC_RO 1 /* Read-only constant */
395 #define XMC_DB 2 /* Read-only debug dictionary table */
396 #define XMC_TC 3 /* Read-write general TOC entry */
397 #define XMC_UA 4 /* Read-write unclassified */
398 #define XMC_RW 5 /* Read-write data */
399 #define XMC_GL 6 /* Read-only global linkage */
400 #define XMC_XO 7 /* Read-only extended operation (simulated insn) */
401 #define XMC_SV 8 /* Read-only supervisor call */
402 #define XMC_BS 9 /* Read-write BSS */
403 #define XMC_DS 10 /* Read-write descriptor csect */
404 #define XMC_UC 11 /* Read-write unnamed Fortran common */
405 #define XMC_TI 12 /* Read-only traceback index csect */
406 #define XMC_TB 13 /* Read-only traceback table csect */
407 /* 14 ??? */
408 #define XMC_TC0 15 /* Read-write TOC anchor for TOC addressability */
409
410
411 /******************************************
412 * I960-specific *2nd* aux. entry formats
413 ******************************************/
414 struct
415 {
416 /* This is a very old typo that keeps getting propagated. */
417 #define x_stdindx x_stindx
418 long x_stindx; /* sys. table entry */
419 } x_sc; /* system call entry */
420
421 struct
422 {
423 unsigned long x_balntry; /* BAL entry point */
424 } x_bal; /* BAL-callable function */
425
426 struct
427 {
428 unsigned long x_timestamp; /* time stamp */
429 char x_idstring[20]; /* producer identity string */
430 } x_ident; /* Producer ident info */
431
432 };
433
434 /********************** RELOCATION DIRECTIVES **********************/
435
436 struct internal_reloc
437 {
438 bfd_vma r_vaddr; /* Virtual address of reference */
439 long r_symndx; /* Index into symbol table */
440 unsigned short r_type; /* Relocation type */
441 unsigned char r_size; /* Used by RS/6000 and ECOFF */
442 unsigned char r_extern; /* Used by ECOFF */
443 unsigned long r_offset; /* Used by Alpha ECOFF, SPARC, others */
444 };
445
446 #define R_RELBYTE 017
447 #define R_RELWORD 020
448 #define R_PCRBYTE 022
449 #define R_PCRWORD 023
450 #define R_PCRLONG 024
451
452 #define R_DIR16 01
453 #define R_DIR32 06
454 #define R_PCLONG 020
455 #define R_RELBYTE 017
456 #define R_RELWORD 020
457
458
459
460 #define R_PCR16L 128
461 #define R_PCR26L 129
462 #define R_VRT16 130
463 #define R_HVRT16 131
464 #define R_LVRT16 132
465 #define R_VRT32 133
466 #define R_RELLONG (0x11) /* Direct 32-bit relocation */
467 #define R_IPRSHORT (0x18)
468 #define R_IPRMED (0x19) /* 24-bit ip-relative relocation */
469 #define R_IPRLONG (0x1a)
470 #define R_OPTCALL (0x1b) /* 32-bit optimizable call (leafproc/sysproc) */
471 #define R_OPTCALLX (0x1c) /* 64-bit optimizable call (leafproc/sysproc) */
472 #define R_GETSEG (0x1d)
473 #define R_GETPA (0x1e)
474 #define R_TAGWORD (0x1f)
475 #define R_JUMPTARG 0x20 /* strange 29k 00xx00xx reloc */
476
477
478 #define R_MOVB1 0x41 /* Special h8 16bit or 8 bit reloc for mov.b */
479 #define R_MOVB2 0x42 /* Special h8 opcode for 8bit which could be 16 */
480 #define R_JMP1 0x43 /* Special h8 16bit jmp which could be pcrel */
481 #define R_JMP2 0x44 /* a branch which used to be a jmp */
482 #define R_RELLONG_NEG 0x45
483
484 #define R_JMPL1 0x46 /* Special h8 24bit jmp which could be pcrel */
485 #define R_JMPL_B8 0x47 /* a 8 bit pcrel which used to be a jmp */
486
487 #define R_MOVLB1 0x48 /* Special h8 24bit or 8 bit reloc for mov.b */
488 #define R_MOVLB2 0x49 /* Special h8 opcode for 8bit which could be 24 */
489
490 /* Z8k modes */
491 #define R_IMM16 0x01 /* 16 bit abs */
492 #define R_JR 0x02 /* jr 8 bit disp */
493 #define R_IMM4L 0x23 /* low nibble */
494 #define R_IMM8 0x22 /* 8 bit abs */
495 #define R_IMM32 R_RELLONG /* 32 bit abs */
496 #define R_CALL R_DA /* Absolute address which could be a callr */
497 #define R_JP R_DA /* Absolute address which could be a jp */
498 #define R_REL16 0x04 /* 16 bit PC rel */
499 #define R_CALLR 0x05 /* callr 12 bit disp */
500 #define R_SEG 0x10 /* set if in segmented mode */
501 #define R_IMM4H 0x24 /* high nibble */
502 #define R_DISP7 0x25 /* djnz displacement */
503
504 /* H8500 modes */
505
506 #define R_H8500_IMM8 1 /* 8 bit immediate */
507 #define R_H8500_IMM16 2 /* 16 bit immediate */
508 #define R_H8500_PCREL8 3 /* 8 bit pcrel */
509 #define R_H8500_PCREL16 4 /* 16 bit pcrel */
510 #define R_H8500_HIGH8 5 /* high 8 bits of 24 bit address */
511 #define R_H8500_LOW16 7 /* low 16 bits of 24 bit immediate */
512 #define R_H8500_IMM24 6 /* 24 bit immediate */
513 #define R_H8500_IMM32 8 /* 32 bit immediate */
514 #define R_H8500_HIGH16 9 /* high 16 bits of 32 bit immediate */
515
516 /* SH modes */
517
518 #define R_SH_PCREL8 3 /* 8 bit pcrel */
519 #define R_SH_PCREL16 4 /* 16 bit pcrel */
520 #define R_SH_HIGH8 5 /* high 8 bits of 24 bit address */
521 #define R_SH_LOW16 7 /* low 16 bits of 24 bit immediate */
522 #define R_SH_IMM24 6 /* 24 bit immediate */
523 #define R_SH_PCDISP8BY4 9 /* PC rel 8 bits *4 +ve */
524 #define R_SH_PCDISP8BY2 10 /* PC rel 8 bits *2 +ve */
525 #define R_SH_PCDISP8 11 /* 8 bit branch */
526 #define R_SH_PCDISP 12 /* 12 bit branch */
527 #define R_SH_IMM32 14 /* 32 bit immediate */
528 #define R_SH_IMM8 16
529 #define R_SH_IMM8BY2 17
530 #define R_SH_IMM8BY4 18
531 #define R_SH_IMM4 19
532 #define R_SH_IMM4BY2 20
533 #define R_SH_IMM4BY4 21
534 #define R_SH_PCRELIMM8BY2 22
535 #define R_SH_PCRELIMM8BY4 23
536 #define R_SH_IMM16 24 /* 16 bit immediate */
537
538
This page took 0.040378 seconds and 5 git commands to generate.