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