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