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