Commit | Line | Data |
---|---|---|
4f1d9bd8 NC |
1 | /* external.h -- External COFF structures |
2 | ||
3 | Copyright 2001 Free Software Foundation, Inc. | |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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 | |
e172dbf8 | 17 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ |
4f1d9bd8 NC |
18 | |
19 | #ifndef COFF_EXTERNAL_H | |
20 | #define COFF_EXTERNAL_H | |
21 | ||
22 | #ifndef DO_NOT_DEFINE_FILHDR | |
23 | /********************** FILE HEADER **********************/ | |
24 | ||
25 | struct external_filehdr | |
26 | { | |
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 */ | |
34 | }; | |
35 | ||
36 | #define FILHDR struct external_filehdr | |
37 | #define FILHSZ 20 | |
38 | #endif | |
39 | ||
40 | #ifndef DO_NOT_DEFINE_AOUTHDR | |
41 | /********************** AOUT "OPTIONAL HEADER" **********************/ | |
42 | ||
43 | typedef struct external_aouthdr | |
44 | { | |
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 */ | |
53 | } | |
54 | AOUTHDR; | |
55 | ||
56 | #define AOUTHDRSZ 28 | |
57 | #define AOUTSZ 28 | |
58 | #endif | |
59 | ||
60 | #ifndef DO_NOT_DEFINE_SCNHDR | |
61 | /********************** SECTION HEADER **********************/ | |
62 | ||
63 | struct external_scnhdr | |
64 | { | |
65 | char s_name[8]; /* section name */ | |
66 | char s_paddr[4]; /* physical address, aliased s_nlib */ | |
67 | char s_vaddr[4]; /* virtual address */ | |
68 | char s_size[4]; /* section size */ | |
69 | char s_scnptr[4]; /* file ptr to raw data for section */ | |
70 | char s_relptr[4]; /* file ptr to relocation */ | |
71 | char s_lnnoptr[4]; /* file ptr to line numbers */ | |
72 | char s_nreloc[2]; /* number of relocation entries */ | |
73 | char s_nlnno[2]; /* number of line number entries */ | |
74 | char s_flags[4]; /* flags */ | |
75 | }; | |
76 | ||
77 | #define SCNHDR struct external_scnhdr | |
78 | #define SCNHSZ 40 | |
79 | ||
80 | /* Names of "special" sections. */ | |
81 | ||
82 | #define _TEXT ".text" | |
83 | #define _DATA ".data" | |
84 | #define _BSS ".bss" | |
85 | #define _COMMENT ".comment" | |
86 | #define _LIB ".lib" | |
87 | #endif /* not DO_NOT_DEFINE_SCNHDR */ | |
88 | ||
89 | #ifndef DO_NOT_DEFINE_LINENO | |
90 | ||
91 | /********************** LINE NUMBERS **********************/ | |
92 | ||
93 | #ifndef L_LNNO_SIZE | |
94 | #error L_LNNO_SIZE needs to be defined | |
95 | #endif | |
96 | ||
97 | /* 1 line number entry for every "breakpointable" source line in a section. | |
98 | Line numbers are grouped on a per function basis; first entry in a function | |
99 | grouping will have l_lnno = 0 and in place of physical address will be the | |
100 | symbol table index of the function name. */ | |
101 | struct external_lineno | |
102 | { | |
103 | union | |
104 | { | |
105 | char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ | |
106 | char l_paddr[4]; /* (physical) address of line number */ | |
107 | } l_addr; | |
108 | ||
109 | char l_lnno[L_LNNO_SIZE]; /* line number */ | |
110 | }; | |
111 | ||
112 | #define LINENO struct external_lineno | |
113 | #define LINESZ (4 + L_LNNO_SIZE) | |
114 | ||
115 | #if L_LNNO_SIZE == 4 | |
a9306dbd NC |
116 | #define GET_LINENO_LNNO(abfd, ext) H_GET_32 (abfd, (ext->l_lnno)) |
117 | #define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_32 (abfd, val, (ext->l_lnno)) | |
4f1d9bd8 NC |
118 | #endif |
119 | #if L_LNNO_SIZE == 2 | |
a9306dbd NC |
120 | #define GET_LINENO_LNNO(abfd, ext) H_GET_16 (abfd, (ext->l_lnno)) |
121 | #define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_16 (abfd, val, (ext->l_lnno)) | |
4f1d9bd8 NC |
122 | #endif |
123 | ||
124 | #endif /* not DO_NOT_DEFINE_LINENO */ | |
125 | ||
126 | #ifndef DO_NOT_DEFINE_SYMENT | |
127 | /********************** SYMBOLS **********************/ | |
128 | ||
129 | #define E_SYMNMLEN 8 /* # characters in a symbol name */ | |
130 | #ifndef E_FILNMLEN | |
131 | #define E_FILNMLEN 14 | |
132 | #endif | |
133 | #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ | |
134 | ||
135 | struct external_syment | |
136 | { | |
137 | union | |
138 | { | |
139 | char e_name[E_SYMNMLEN]; | |
140 | ||
141 | struct | |
142 | { | |
143 | char e_zeroes[4]; | |
144 | char e_offset[4]; | |
145 | } e; | |
146 | } e; | |
147 | ||
148 | char e_value[4]; | |
149 | char e_scnum[2]; | |
150 | char e_type[2]; | |
151 | char e_sclass[1]; | |
152 | char e_numaux[1]; | |
153 | }; | |
154 | ||
155 | #define SYMENT struct external_syment | |
156 | #define SYMESZ 18 | |
157 | ||
158 | #ifndef N_BTMASK | |
159 | #define N_BTMASK 0xf | |
160 | #endif | |
161 | ||
162 | #ifndef N_TMASK | |
163 | #define N_TMASK 0x30 | |
164 | #endif | |
165 | ||
166 | #ifndef N_BTSHFT | |
167 | #define N_BTSHFT 4 | |
168 | #endif | |
169 | ||
170 | #ifndef N_TSHIFT | |
171 | #define N_TSHIFT 2 | |
172 | #endif | |
173 | ||
174 | #endif /* not DO_NOT_DEFINE_SYMENT */ | |
175 | ||
176 | #ifndef DO_NOT_DEFINE_AUXENT | |
177 | ||
178 | union external_auxent | |
179 | { | |
180 | struct | |
181 | { | |
182 | char x_tagndx[4]; /* str, un, or enum tag indx */ | |
183 | ||
184 | union | |
185 | { | |
186 | struct | |
187 | { | |
188 | char x_lnno[2]; /* declaration line number */ | |
189 | char x_size[2]; /* str/union/array size */ | |
190 | } x_lnsz; | |
191 | ||
192 | char x_fsize[4]; /* size of function */ | |
193 | ||
194 | } x_misc; | |
195 | ||
196 | union | |
197 | { | |
198 | struct /* if ISFCN, tag, or .bb */ | |
199 | { | |
200 | char x_lnnoptr[4]; /* ptr to fcn line # */ | |
201 | char x_endndx[4]; /* entry ndx past block end */ | |
202 | } x_fcn; | |
203 | ||
204 | struct /* if ISARY, up to 4 dimen. */ | |
205 | { | |
206 | char x_dimen[E_DIMNUM][2]; | |
207 | } x_ary; | |
208 | ||
209 | } x_fcnary; | |
210 | ||
211 | char x_tvndx[2]; /* tv index */ | |
212 | ||
213 | } x_sym; | |
214 | ||
215 | union | |
216 | { | |
217 | char x_fname[E_FILNMLEN]; | |
218 | ||
219 | struct | |
220 | { | |
221 | char x_zeroes[4]; | |
222 | char x_offset[4]; | |
223 | } x_n; | |
224 | ||
225 | } x_file; | |
226 | ||
227 | struct | |
228 | { | |
229 | char x_scnlen[4]; /* section length */ | |
230 | char x_nreloc[2]; /* # relocation entries */ | |
231 | char x_nlinno[2]; /* # line numbers */ | |
232 | #ifdef INCLUDE_COMDAT_FIELDS_IN_AUXENT | |
233 | char x_checksum[4]; /* section COMDAT checksum */ | |
234 | char x_associated[2]; /* COMDAT associated section index */ | |
235 | char x_comdat[1]; /* COMDAT selection number */ | |
236 | #endif | |
237 | } x_scn; | |
238 | ||
239 | struct | |
240 | { | |
241 | char x_tvfill[4]; /* tv fill value */ | |
242 | char x_tvlen[2]; /* length of .tv */ | |
243 | char x_tvran[2][2]; /* tv range */ | |
244 | } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ | |
245 | }; | |
246 | ||
247 | #define AUXENT union external_auxent | |
248 | #define AUXESZ 18 | |
249 | ||
250 | #define _ETEXT "etext" | |
251 | ||
252 | #endif /* not DO_NOT_DEFINE_AUXENT */ | |
253 | ||
254 | #endif /* COFF_EXTERNAL_H */ |