opcodes/
[binutils.git] / include / coff / external.h
blobe38fb1bab4ee7641cc358a704f22010a13ac87e4
1 /* external.h -- External COFF structures
3 Copyright 2001, 2006 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
19 #ifndef COFF_EXTERNAL_H
20 #define COFF_EXTERNAL_H
22 #ifndef DO_NOT_DEFINE_FILHDR
23 /********************** FILE HEADER **********************/
25 struct external_filehdr
27 char f_magic[2]; /* magic number */
28 char f_nscns[2]; /* number of sections */
29 char f_timdat[4]; /* time & date stamp */
30 char f_symptr[4]; /* file pointer to symtab */
31 char f_nsyms[4]; /* number of symtab entries */
32 char f_opthdr[2]; /* sizeof(optional hdr) */
33 char f_flags[2]; /* flags */
36 #define FILHDR struct external_filehdr
37 #define FILHSZ 20
38 #endif
40 #ifndef DO_NOT_DEFINE_AOUTHDR
41 /********************** AOUT "OPTIONAL HEADER" **********************/
43 typedef struct external_aouthdr
45 char magic[2]; /* type of file */
46 char vstamp[2]; /* version stamp */
47 char tsize[4]; /* text size in bytes, padded to FW bdry*/
48 char dsize[4]; /* initialized data " " */
49 char bsize[4]; /* uninitialized data " " */
50 char entry[4]; /* entry pt. */
51 char text_start[4]; /* base of text used for this file */
52 char data_start[4]; /* base of data used for this file */
54 AOUTHDR;
56 #define AOUTHDRSZ 28
57 #define AOUTSZ 28
59 typedef struct external_aouthdr64
61 char magic[2]; /* Type of file. */
62 char vstamp[2]; /* Version stamp. */
63 char tsize[4]; /* Text size in bytes, padded to FW bdry*/
64 char dsize[4]; /* Initialized data " ". */
65 char bsize[4]; /* Uninitialized data " ". */
66 char entry[4]; /* Entry pt. */
67 char text_start[4]; /* Base of text used for this file. */
69 AOUTHDR64;
70 #define AOUTHDRSZ64 24
72 #endif /* not DO_NOT_DEFINE_AOUTHDR */
74 #ifndef DO_NOT_DEFINE_SCNHDR
75 /********************** SECTION HEADER **********************/
77 struct external_scnhdr
79 char s_name[8]; /* section name */
80 char s_paddr[4]; /* physical address, aliased s_nlib */
81 char s_vaddr[4]; /* virtual address */
82 char s_size[4]; /* section size */
83 char s_scnptr[4]; /* file ptr to raw data for section */
84 char s_relptr[4]; /* file ptr to relocation */
85 char s_lnnoptr[4]; /* file ptr to line numbers */
86 char s_nreloc[2]; /* number of relocation entries */
87 char s_nlnno[2]; /* number of line number entries */
88 char s_flags[4]; /* flags */
91 #define SCNHDR struct external_scnhdr
92 #define SCNHSZ 40
94 /* Names of "special" sections. */
96 #define _TEXT ".text"
97 #define _DATA ".data"
98 #define _BSS ".bss"
99 #define _COMMENT ".comment"
100 #define _LIB ".lib"
101 #endif /* not DO_NOT_DEFINE_SCNHDR */
103 #ifndef DO_NOT_DEFINE_LINENO
105 /********************** LINE NUMBERS **********************/
107 #ifndef L_LNNO_SIZE
108 #error L_LNNO_SIZE needs to be defined
109 #endif
111 /* 1 line number entry for every "breakpointable" source line in a section.
112 Line numbers are grouped on a per function basis; first entry in a function
113 grouping will have l_lnno = 0 and in place of physical address will be the
114 symbol table index of the function name. */
115 struct external_lineno
117 union
119 char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
120 char l_paddr[4]; /* (physical) address of line number */
121 } l_addr;
123 char l_lnno[L_LNNO_SIZE]; /* line number */
126 #define LINENO struct external_lineno
127 #define LINESZ (4 + L_LNNO_SIZE)
129 #if L_LNNO_SIZE == 4
130 #define GET_LINENO_LNNO(abfd, ext) H_GET_32 (abfd, (ext->l_lnno))
131 #define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_32 (abfd, val, (ext->l_lnno))
132 #endif
133 #if L_LNNO_SIZE == 2
134 #define GET_LINENO_LNNO(abfd, ext) H_GET_16 (abfd, (ext->l_lnno))
135 #define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_16 (abfd, val, (ext->l_lnno))
136 #endif
138 #endif /* not DO_NOT_DEFINE_LINENO */
140 #ifndef DO_NOT_DEFINE_SYMENT
141 /********************** SYMBOLS **********************/
143 #define E_SYMNMLEN 8 /* # characters in a symbol name */
144 #ifndef E_FILNMLEN
145 #define E_FILNMLEN 14
146 #endif
147 #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
149 struct external_syment
151 union
153 char e_name[E_SYMNMLEN];
155 struct
157 char e_zeroes[4];
158 char e_offset[4];
159 } e;
160 } e;
162 char e_value[4];
163 char e_scnum[2];
164 char e_type[2];
165 char e_sclass[1];
166 char e_numaux[1];
169 #define SYMENT struct external_syment
170 #define SYMESZ 18
172 #ifndef N_BTMASK
173 #define N_BTMASK 0xf
174 #endif
176 #ifndef N_TMASK
177 #define N_TMASK 0x30
178 #endif
180 #ifndef N_BTSHFT
181 #define N_BTSHFT 4
182 #endif
184 #ifndef N_TSHIFT
185 #define N_TSHIFT 2
186 #endif
188 #endif /* not DO_NOT_DEFINE_SYMENT */
190 #ifndef DO_NOT_DEFINE_AUXENT
192 union external_auxent
194 struct
196 char x_tagndx[4]; /* str, un, or enum tag indx */
198 union
200 struct
202 char x_lnno[2]; /* declaration line number */
203 char x_size[2]; /* str/union/array size */
204 } x_lnsz;
206 char x_fsize[4]; /* size of function */
208 } x_misc;
210 union
212 struct /* if ISFCN, tag, or .bb */
214 char x_lnnoptr[4]; /* ptr to fcn line # */
215 char x_endndx[4]; /* entry ndx past block end */
216 } x_fcn;
218 struct /* if ISARY, up to 4 dimen. */
220 char x_dimen[E_DIMNUM][2];
221 } x_ary;
223 } x_fcnary;
225 char x_tvndx[2]; /* tv index */
227 } x_sym;
229 union
231 char x_fname[E_FILNMLEN];
233 struct
235 char x_zeroes[4];
236 char x_offset[4];
237 } x_n;
239 } x_file;
241 struct
243 char x_scnlen[4]; /* section length */
244 char x_nreloc[2]; /* # relocation entries */
245 char x_nlinno[2]; /* # line numbers */
246 #ifdef INCLUDE_COMDAT_FIELDS_IN_AUXENT
247 char x_checksum[4]; /* section COMDAT checksum */
248 char x_associated[2]; /* COMDAT associated section index */
249 char x_comdat[1]; /* COMDAT selection number */
250 #endif
251 } x_scn;
253 struct
255 char x_tvfill[4]; /* tv fill value */
256 char x_tvlen[2]; /* length of .tv */
257 char x_tvran[2][2]; /* tv range */
258 } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
261 #define AUXENT union external_auxent
262 #define AUXESZ 18
264 #define _ETEXT "etext"
266 #endif /* not DO_NOT_DEFINE_AUXENT */
268 #endif /* COFF_EXTERNAL_H */