Rev 5191 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5191 | serge | 1 | /* ECOFF support on MIPS machines. |
2 | coff/ecoff.h must be included before this file. |
||
3 | |||
6324 | serge | 4 | Copyright (C) 1999-2015 Free Software Foundation, Inc. |
5191 | serge | 5 | |
6 | This program is free software; you can redistribute it and/or modify |
||
7 | it under the terms of the GNU General Public License as published by |
||
8 | the Free Software Foundation; either version 3 of the License, or |
||
9 | (at your option) any later version. |
||
10 | |||
11 | This program is distributed in the hope that it will be useful, |
||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
14 | GNU General Public License for more details. |
||
15 | |||
16 | You should have received a copy of the GNU General Public License |
||
17 | along with this program; if not, write to the Free Software |
||
18 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
||
19 | MA 02110-1301, USA. */ |
||
20 | |||
21 | #define DO_NOT_DEFINE_AOUTHDR |
||
22 | #define L_LNNO_SIZE 4 |
||
23 | #include "coff/external.h" |
||
24 | |||
25 | /* Magic numbers are defined in coff/ecoff.h. */ |
||
26 | #define MIPS_ECOFF_BADMAG(x) (((x).f_magic!=MIPS_MAGIC_1) && \ |
||
27 | ((x).f_magic!=MIPS_MAGIC_LITTLE) &&\ |
||
28 | ((x).f_magic!=MIPS_MAGIC_BIG) && \ |
||
29 | ((x).f_magic!=MIPS_MAGIC_LITTLE2) && \ |
||
30 | ((x).f_magic!=MIPS_MAGIC_BIG2) && \ |
||
31 | ((x).f_magic!=MIPS_MAGIC_LITTLE3) && \ |
||
32 | ((x).f_magic!=MIPS_MAGIC_BIG3)) |
||
33 | |||
34 | |||
35 | /********************** AOUT "OPTIONAL HEADER" **********************/ |
||
36 | |||
37 | typedef struct external_aouthdr |
||
38 | { |
||
39 | unsigned char magic[2]; /* type of file */ |
||
40 | unsigned char vstamp[2]; /* version stamp */ |
||
41 | unsigned char tsize[4]; /* text size in bytes, padded to FW bdry*/ |
||
42 | unsigned char dsize[4]; /* initialized data " " */ |
||
43 | unsigned char bsize[4]; /* uninitialized data " " */ |
||
44 | unsigned char entry[4]; /* entry pt. */ |
||
45 | unsigned char text_start[4]; /* base of text used for this file */ |
||
46 | unsigned char data_start[4]; /* base of data used for this file */ |
||
47 | unsigned char bss_start[4]; /* base of bss used for this file */ |
||
48 | unsigned char gprmask[4]; /* ?? */ |
||
49 | unsigned char cprmask[4][4]; /* ?? */ |
||
50 | unsigned char gp_value[4]; /* value for gp register */ |
||
51 | } AOUTHDR; |
||
52 | |||
53 | /* compute size of a header */ |
||
54 | |||
55 | #define AOUTSZ 56 |
||
56 | #define AOUTHDRSZ 56 |
||
57 | |||
58 | /********************** RELOCATION DIRECTIVES **********************/ |
||
59 | |||
60 | struct external_reloc |
||
61 | { |
||
62 | unsigned char r_vaddr[4]; |
||
63 | unsigned char r_bits[4]; |
||
64 | }; |
||
65 | |||
66 | #define RELOC struct external_reloc |
||
67 | #define RELSZ 8 |
||
68 | |||
69 | /* MIPS ECOFF uses a packed 8 byte format for relocs. These constants |
||
70 | are used to unpack the r_bits field. */ |
||
71 | |||
72 | #define RELOC_BITS0_SYMNDX_SH_LEFT_BIG 16 |
||
73 | #define RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE 0 |
||
74 | |||
75 | #define RELOC_BITS1_SYMNDX_SH_LEFT_BIG 8 |
||
76 | #define RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE 8 |
||
77 | |||
78 | #define RELOC_BITS2_SYMNDX_SH_LEFT_BIG 0 |
||
79 | #define RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE 16 |
||
80 | |||
81 | /* Originally, ECOFF used four bits for the reloc type and had three |
||
82 | reserved bits. Irix 4 added another bit for the reloc type, which |
||
83 | was easy because it was big endian and one of the spare bits became |
||
84 | the new most significant bit. To make this also work for little |
||
85 | endian ECOFF, we need to wrap one of the reserved bits around to |
||
86 | become the most significant bit of the reloc type. */ |
||
87 | #define RELOC_BITS3_TYPE_BIG 0x3E |
||
88 | #define RELOC_BITS3_TYPE_SH_BIG 1 |
||
89 | #define RELOC_BITS3_TYPE_LITTLE 0x78 |
||
90 | #define RELOC_BITS3_TYPE_SH_LITTLE 3 |
||
91 | #define RELOC_BITS3_TYPEHI_LITTLE 0x04 |
||
92 | #define RELOC_BITS3_TYPEHI_SH_LITTLE 2 |
||
93 | |||
94 | #define RELOC_BITS3_EXTERN_BIG 0x01 |
||
95 | #define RELOC_BITS3_EXTERN_LITTLE 0x80 |
||
96 | |||
97 | /* The r_type field in a reloc is one of the following values. I |
||
98 | don't know if any other values can appear. These seem to be all |
||
99 | that occur in the Ultrix 4.2 libraries. */ |
||
100 | #define MIPS_R_IGNORE 0 |
||
101 | #define MIPS_R_REFHALF 1 |
||
102 | #define MIPS_R_REFWORD 2 |
||
103 | #define MIPS_R_JMPADDR 3 |
||
104 | #define MIPS_R_REFHI 4 |
||
105 | #define MIPS_R_REFLO 5 |
||
106 | #define MIPS_R_GPREL 6 |
||
107 | #define MIPS_R_LITERAL 7 |
||
108 | |||
109 | /* FIXME: This relocation is used (internally only) to represent branches |
||
110 | when assembling. It should never appear in output files, and |
||
111 | be removed. (It used to be used for embedded-PIC support.) */ |
||
112 | #define MIPS_R_PCREL16 12 |
||
113 | |||
114 | /********************** STABS **********************/ |
||
115 | |||
116 | #define MIPS_IS_STAB ECOFF_IS_STAB |
||
117 | #define MIPS_MARK_STAB ECOFF_MARK_STAB |
||
118 | #define MIPS_UNMARK_STAB ECOFF_UNMARK_STAB |
||
119 | |||
120 | /********************** SYMBOLIC INFORMATION **********************/ |
||
121 | |||
122 | /* Written by John Gilmore. */ |
||
123 | |||
124 | /* ECOFF uses COFF-like section structures, but its own symbol format. |
||
125 | This file defines the symbol format in fields whose size and alignment |
||
126 | will not vary on different host systems. */ |
||
127 | |||
128 | /* File header as a set of bytes */ |
||
129 | |||
130 | struct hdr_ext |
||
131 | { |
||
132 | unsigned char h_magic[2]; |
||
133 | unsigned char h_vstamp[2]; |
||
134 | unsigned char h_ilineMax[4]; |
||
135 | unsigned char h_cbLine[4]; |
||
136 | unsigned char h_cbLineOffset[4]; |
||
137 | unsigned char h_idnMax[4]; |
||
138 | unsigned char h_cbDnOffset[4]; |
||
139 | unsigned char h_ipdMax[4]; |
||
140 | unsigned char h_cbPdOffset[4]; |
||
141 | unsigned char h_isymMax[4]; |
||
142 | unsigned char h_cbSymOffset[4]; |
||
143 | unsigned char h_ioptMax[4]; |
||
144 | unsigned char h_cbOptOffset[4]; |
||
145 | unsigned char h_iauxMax[4]; |
||
146 | unsigned char h_cbAuxOffset[4]; |
||
147 | unsigned char h_issMax[4]; |
||
148 | unsigned char h_cbSsOffset[4]; |
||
149 | unsigned char h_issExtMax[4]; |
||
150 | unsigned char h_cbSsExtOffset[4]; |
||
151 | unsigned char h_ifdMax[4]; |
||
152 | unsigned char h_cbFdOffset[4]; |
||
153 | unsigned char h_crfd[4]; |
||
154 | unsigned char h_cbRfdOffset[4]; |
||
155 | unsigned char h_iextMax[4]; |
||
156 | unsigned char h_cbExtOffset[4]; |
||
157 | }; |
||
158 | |||
159 | /* File descriptor external record */ |
||
160 | |||
161 | struct fdr_ext |
||
162 | { |
||
163 | unsigned char f_adr[4]; |
||
164 | unsigned char f_rss[4]; |
||
165 | unsigned char f_issBase[4]; |
||
166 | unsigned char f_cbSs[4]; |
||
167 | unsigned char f_isymBase[4]; |
||
168 | unsigned char f_csym[4]; |
||
169 | unsigned char f_ilineBase[4]; |
||
170 | unsigned char f_cline[4]; |
||
171 | unsigned char f_ioptBase[4]; |
||
172 | unsigned char f_copt[4]; |
||
173 | unsigned char f_ipdFirst[2]; |
||
174 | unsigned char f_cpd[2]; |
||
175 | unsigned char f_iauxBase[4]; |
||
176 | unsigned char f_caux[4]; |
||
177 | unsigned char f_rfdBase[4]; |
||
178 | unsigned char f_crfd[4]; |
||
179 | unsigned char f_bits1[1]; |
||
180 | unsigned char f_bits2[3]; |
||
181 | unsigned char f_cbLineOffset[4]; |
||
182 | unsigned char f_cbLine[4]; |
||
183 | }; |
||
184 | |||
185 | #define FDR_BITS1_LANG_BIG 0xF8 |
||
186 | #define FDR_BITS1_LANG_SH_BIG 3 |
||
187 | #define FDR_BITS1_LANG_LITTLE 0x1F |
||
188 | #define FDR_BITS1_LANG_SH_LITTLE 0 |
||
189 | |||
190 | #define FDR_BITS1_FMERGE_BIG 0x04 |
||
191 | #define FDR_BITS1_FMERGE_LITTLE 0x20 |
||
192 | |||
193 | #define FDR_BITS1_FREADIN_BIG 0x02 |
||
194 | #define FDR_BITS1_FREADIN_LITTLE 0x40 |
||
195 | |||
196 | #define FDR_BITS1_FBIGENDIAN_BIG 0x01 |
||
197 | #define FDR_BITS1_FBIGENDIAN_LITTLE 0x80 |
||
198 | |||
199 | #define FDR_BITS2_GLEVEL_BIG 0xC0 |
||
200 | #define FDR_BITS2_GLEVEL_SH_BIG 6 |
||
201 | #define FDR_BITS2_GLEVEL_LITTLE 0x03 |
||
202 | #define FDR_BITS2_GLEVEL_SH_LITTLE 0 |
||
203 | |||
204 | /* We ignore the `reserved' field in bits2. */ |
||
205 | |||
206 | /* Procedure descriptor external record */ |
||
207 | |||
208 | struct pdr_ext |
||
209 | { |
||
210 | unsigned char p_adr[4]; |
||
211 | unsigned char p_isym[4]; |
||
212 | unsigned char p_iline[4]; |
||
213 | unsigned char p_regmask[4]; |
||
214 | unsigned char p_regoffset[4]; |
||
215 | unsigned char p_iopt[4]; |
||
216 | unsigned char p_fregmask[4]; |
||
217 | unsigned char p_fregoffset[4]; |
||
218 | unsigned char p_frameoffset[4]; |
||
219 | unsigned char p_framereg[2]; |
||
220 | unsigned char p_pcreg[2]; |
||
221 | unsigned char p_lnLow[4]; |
||
222 | unsigned char p_lnHigh[4]; |
||
223 | unsigned char p_cbLineOffset[4]; |
||
224 | }; |
||
225 | |||
226 | /* Runtime procedure table */ |
||
227 | |||
228 | struct rpdr_ext |
||
229 | { |
||
230 | unsigned char p_adr[4]; |
||
231 | unsigned char p_regmask[4]; |
||
232 | unsigned char p_regoffset[4]; |
||
233 | unsigned char p_fregmask[4]; |
||
234 | unsigned char p_fregoffset[4]; |
||
235 | unsigned char p_frameoffset[4]; |
||
236 | unsigned char p_framereg[2]; |
||
237 | unsigned char p_pcreg[2]; |
||
238 | unsigned char p_irpss[4]; |
||
239 | unsigned char p_reserved[4]; |
||
240 | unsigned char p_exception_info[4]; |
||
241 | }; |
||
242 | |||
243 | /* Line numbers */ |
||
244 | |||
245 | struct line_ext |
||
246 | { |
||
247 | unsigned char l_line[4]; |
||
248 | }; |
||
249 | |||
250 | /* Symbol external record */ |
||
251 | |||
252 | struct sym_ext |
||
253 | { |
||
254 | unsigned char s_iss[4]; |
||
255 | unsigned char s_value[4]; |
||
256 | unsigned char s_bits1[1]; |
||
257 | unsigned char s_bits2[1]; |
||
258 | unsigned char s_bits3[1]; |
||
259 | unsigned char s_bits4[1]; |
||
260 | }; |
||
261 | |||
262 | #define SYM_BITS1_ST_BIG 0xFC |
||
263 | #define SYM_BITS1_ST_SH_BIG 2 |
||
264 | #define SYM_BITS1_ST_LITTLE 0x3F |
||
265 | #define SYM_BITS1_ST_SH_LITTLE 0 |
||
266 | |||
267 | #define SYM_BITS1_SC_BIG 0x03 |
||
268 | #define SYM_BITS1_SC_SH_LEFT_BIG 3 |
||
269 | #define SYM_BITS1_SC_LITTLE 0xC0 |
||
270 | #define SYM_BITS1_SC_SH_LITTLE 6 |
||
271 | |||
272 | #define SYM_BITS2_SC_BIG 0xE0 |
||
273 | #define SYM_BITS2_SC_SH_BIG 5 |
||
274 | #define SYM_BITS2_SC_LITTLE 0x07 |
||
275 | #define SYM_BITS2_SC_SH_LEFT_LITTLE 2 |
||
276 | |||
277 | #define SYM_BITS2_RESERVED_BIG 0x10 |
||
278 | #define SYM_BITS2_RESERVED_LITTLE 0x08 |
||
279 | |||
280 | #define SYM_BITS2_INDEX_BIG 0x0F |
||
281 | #define SYM_BITS2_INDEX_SH_LEFT_BIG 16 |
||
282 | #define SYM_BITS2_INDEX_LITTLE 0xF0 |
||
283 | #define SYM_BITS2_INDEX_SH_LITTLE 4 |
||
284 | |||
285 | #define SYM_BITS3_INDEX_SH_LEFT_BIG 8 |
||
286 | #define SYM_BITS3_INDEX_SH_LEFT_LITTLE 4 |
||
287 | |||
288 | #define SYM_BITS4_INDEX_SH_LEFT_BIG 0 |
||
289 | #define SYM_BITS4_INDEX_SH_LEFT_LITTLE 12 |
||
290 | |||
291 | /* External symbol external record */ |
||
292 | |||
293 | struct ext_ext |
||
294 | { |
||
295 | unsigned char es_bits1[1]; |
||
296 | unsigned char es_bits2[1]; |
||
297 | unsigned char es_ifd[2]; |
||
298 | struct sym_ext es_asym; |
||
299 | }; |
||
300 | |||
301 | #define EXT_BITS1_JMPTBL_BIG 0x80 |
||
302 | #define EXT_BITS1_JMPTBL_LITTLE 0x01 |
||
303 | |||
304 | #define EXT_BITS1_COBOL_MAIN_BIG 0x40 |
||
305 | #define EXT_BITS1_COBOL_MAIN_LITTLE 0x02 |
||
306 | |||
307 | #define EXT_BITS1_WEAKEXT_BIG 0x20 |
||
308 | #define EXT_BITS1_WEAKEXT_LITTLE 0x04 |
||
309 | |||
310 | /* Dense numbers external record */ |
||
311 | |||
312 | struct dnr_ext |
||
313 | { |
||
314 | unsigned char d_rfd[4]; |
||
315 | unsigned char d_index[4]; |
||
316 | }; |
||
317 | |||
318 | /* Relative file descriptor */ |
||
319 | |||
320 | struct rfd_ext |
||
321 | { |
||
322 | unsigned char rfd[4]; |
||
323 | }; |
||
324 | |||
325 | /* Optimizer symbol external record */ |
||
326 | |||
327 | struct opt_ext |
||
328 | { |
||
329 | unsigned char o_bits1[1]; |
||
330 | unsigned char o_bits2[1]; |
||
331 | unsigned char o_bits3[1]; |
||
332 | unsigned char o_bits4[1]; |
||
333 | struct rndx_ext o_rndx; |
||
334 | unsigned char o_offset[4]; |
||
335 | }; |
||
336 | |||
337 | #define OPT_BITS2_VALUE_SH_LEFT_BIG 16 |
||
338 | #define OPT_BITS2_VALUE_SH_LEFT_LITTLE 0 |
||
339 | |||
340 | #define OPT_BITS3_VALUE_SH_LEFT_BIG 8 |
||
341 | #define OPT_BITS3_VALUE_SH_LEFT_LITTLE 8 |
||
342 | |||
343 | #define OPT_BITS4_VALUE_SH_LEFT_BIG 0 |
||
344 | #define OPT_BITS4_VALUE_SH_LEFT_LITTLE 16 |