* emultempl/elf32.em (place_orphan): Don't put non-allocated .rel*
[binutils.git] / include / coff / mips.h
blobb9503bd5555ddf634db002497c4699c6e5b8fc99
1 /* ECOFF support on MIPS machines.
2 coff/ecoff.h must be included before this file.
4 Copyright 2001 Free Software Foundation, Inc.
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 2 of the License, or
9 (at your option) any later version.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 #define DO_NOT_DEFINE_AOUTHDR
21 #define L_LNNO_SIZE 4
22 #include "coff/external.h"
24 /* Magic numbers are defined in coff/ecoff.h. */
25 #define MIPS_ECOFF_BADMAG(x) (((x).f_magic!=MIPS_MAGIC_1) && \
26 ((x).f_magic!=MIPS_MAGIC_LITTLE) &&\
27 ((x).f_magic!=MIPS_MAGIC_BIG) && \
28 ((x).f_magic!=MIPS_MAGIC_LITTLE2) && \
29 ((x).f_magic!=MIPS_MAGIC_BIG2) && \
30 ((x).f_magic!=MIPS_MAGIC_LITTLE3) && \
31 ((x).f_magic!=MIPS_MAGIC_BIG3))
34 /********************** AOUT "OPTIONAL HEADER" **********************/
36 typedef struct external_aouthdr
38 unsigned char magic[2]; /* type of file */
39 unsigned char vstamp[2]; /* version stamp */
40 unsigned char tsize[4]; /* text size in bytes, padded to FW bdry*/
41 unsigned char dsize[4]; /* initialized data " " */
42 unsigned char bsize[4]; /* uninitialized data " " */
43 unsigned char entry[4]; /* entry pt. */
44 unsigned char text_start[4]; /* base of text used for this file */
45 unsigned char data_start[4]; /* base of data used for this file */
46 unsigned char bss_start[4]; /* base of bss used for this file */
47 unsigned char gprmask[4]; /* ?? */
48 unsigned char cprmask[4][4]; /* ?? */
49 unsigned char gp_value[4]; /* value for gp register */
50 } AOUTHDR;
52 /* compute size of a header */
54 #define AOUTSZ 56
55 #define AOUTHDRSZ 56
57 /********************** RELOCATION DIRECTIVES **********************/
59 struct external_reloc
61 unsigned char r_vaddr[4];
62 unsigned char r_bits[4];
65 #define RELOC struct external_reloc
66 #define RELSZ 8
68 /* MIPS ECOFF uses a packed 8 byte format for relocs. These constants
69 are used to unpack the r_bits field. */
71 #define RELOC_BITS0_SYMNDX_SH_LEFT_BIG 16
72 #define RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE 0
74 #define RELOC_BITS1_SYMNDX_SH_LEFT_BIG 8
75 #define RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE 8
77 #define RELOC_BITS2_SYMNDX_SH_LEFT_BIG 0
78 #define RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE 16
80 /* Originally, ECOFF used four bits for the reloc type and had three
81 reserved bits. Irix 4 added another bit for the reloc type, which
82 was easy because it was big endian and one of the spare bits became
83 the new most significant bit. To make this also work for little
84 endian ECOFF, we need to wrap one of the reserved bits around to
85 become the most significant bit of the reloc type. */
86 #define RELOC_BITS3_TYPE_BIG 0x3E
87 #define RELOC_BITS3_TYPE_SH_BIG 1
88 #define RELOC_BITS3_TYPE_LITTLE 0x78
89 #define RELOC_BITS3_TYPE_SH_LITTLE 3
90 #define RELOC_BITS3_TYPEHI_LITTLE 0x04
91 #define RELOC_BITS3_TYPEHI_SH_LITTLE 2
93 #define RELOC_BITS3_EXTERN_BIG 0x01
94 #define RELOC_BITS3_EXTERN_LITTLE 0x80
96 /* The r_type field in a reloc is one of the following values. I
97 don't know if any other values can appear. These seem to be all
98 that occur in the Ultrix 4.2 libraries. */
99 #define MIPS_R_IGNORE 0
100 #define MIPS_R_REFHALF 1
101 #define MIPS_R_REFWORD 2
102 #define MIPS_R_JMPADDR 3
103 #define MIPS_R_REFHI 4
104 #define MIPS_R_REFLO 5
105 #define MIPS_R_GPREL 6
106 #define MIPS_R_LITERAL 7
108 /* These reloc types are a Cygnus extension used when generating
109 position independent code for embedded systems. The numbers are
110 taken from Irix 4, but at least for internal relocs Irix 5 does not
111 give them the same meaning. For an internal reloc the symbol index
112 of RELHI and RELLO is modified as described below for
113 MIPS_R_SWITCH. */
114 #define MIPS_R_PCREL16 12
115 #define MIPS_R_RELHI 13
116 #define MIPS_R_RELLO 14
118 /* This reloc type is a Cygnus extension used when generating position
119 independent code for embedded systems. It is used for an entry in
120 a switch table, which looks like this:
121 .word $L3-$LS12
122 The object file will contain the correct difference, and does not
123 require adjustment. However, when the linker is relaxing PC
124 relative calls, it is possible for $L3 to move farther away. This
125 reloc always appears in the .text section, and is always against
126 the .text section. However, the symbol index is not
127 RELOC_SECTION_TEXT. It is, instead, the distance between this
128 switch table entry and $LS12. Thus, the original value of $L12 is
129 vaddr - symndx
130 and the original value of $L3 is
131 vaddr - symndx + addend
132 where addend is the value in the object file. Knowing this, the
133 linker can know whether the addend in the object file must be
134 adjusted. */
135 #define MIPS_R_SWITCH 22
137 /********************** STABS **********************/
139 #define MIPS_IS_STAB ECOFF_IS_STAB
140 #define MIPS_MARK_STAB ECOFF_MARK_STAB
141 #define MIPS_UNMARK_STAB ECOFF_UNMARK_STAB
143 /********************** SYMBOLIC INFORMATION **********************/
145 /* Written by John Gilmore. */
147 /* ECOFF uses COFF-like section structures, but its own symbol format.
148 This file defines the symbol format in fields whose size and alignment
149 will not vary on different host systems. */
151 /* File header as a set of bytes */
153 struct hdr_ext
155 unsigned char h_magic[2];
156 unsigned char h_vstamp[2];
157 unsigned char h_ilineMax[4];
158 unsigned char h_cbLine[4];
159 unsigned char h_cbLineOffset[4];
160 unsigned char h_idnMax[4];
161 unsigned char h_cbDnOffset[4];
162 unsigned char h_ipdMax[4];
163 unsigned char h_cbPdOffset[4];
164 unsigned char h_isymMax[4];
165 unsigned char h_cbSymOffset[4];
166 unsigned char h_ioptMax[4];
167 unsigned char h_cbOptOffset[4];
168 unsigned char h_iauxMax[4];
169 unsigned char h_cbAuxOffset[4];
170 unsigned char h_issMax[4];
171 unsigned char h_cbSsOffset[4];
172 unsigned char h_issExtMax[4];
173 unsigned char h_cbSsExtOffset[4];
174 unsigned char h_ifdMax[4];
175 unsigned char h_cbFdOffset[4];
176 unsigned char h_crfd[4];
177 unsigned char h_cbRfdOffset[4];
178 unsigned char h_iextMax[4];
179 unsigned char h_cbExtOffset[4];
182 /* File descriptor external record */
184 struct fdr_ext
186 unsigned char f_adr[4];
187 unsigned char f_rss[4];
188 unsigned char f_issBase[4];
189 unsigned char f_cbSs[4];
190 unsigned char f_isymBase[4];
191 unsigned char f_csym[4];
192 unsigned char f_ilineBase[4];
193 unsigned char f_cline[4];
194 unsigned char f_ioptBase[4];
195 unsigned char f_copt[4];
196 unsigned char f_ipdFirst[2];
197 unsigned char f_cpd[2];
198 unsigned char f_iauxBase[4];
199 unsigned char f_caux[4];
200 unsigned char f_rfdBase[4];
201 unsigned char f_crfd[4];
202 unsigned char f_bits1[1];
203 unsigned char f_bits2[3];
204 unsigned char f_cbLineOffset[4];
205 unsigned char f_cbLine[4];
208 #define FDR_BITS1_LANG_BIG 0xF8
209 #define FDR_BITS1_LANG_SH_BIG 3
210 #define FDR_BITS1_LANG_LITTLE 0x1F
211 #define FDR_BITS1_LANG_SH_LITTLE 0
213 #define FDR_BITS1_FMERGE_BIG 0x04
214 #define FDR_BITS1_FMERGE_LITTLE 0x20
216 #define FDR_BITS1_FREADIN_BIG 0x02
217 #define FDR_BITS1_FREADIN_LITTLE 0x40
219 #define FDR_BITS1_FBIGENDIAN_BIG 0x01
220 #define FDR_BITS1_FBIGENDIAN_LITTLE 0x80
222 #define FDR_BITS2_GLEVEL_BIG 0xC0
223 #define FDR_BITS2_GLEVEL_SH_BIG 6
224 #define FDR_BITS2_GLEVEL_LITTLE 0x03
225 #define FDR_BITS2_GLEVEL_SH_LITTLE 0
227 /* We ignore the `reserved' field in bits2. */
229 /* Procedure descriptor external record */
231 struct pdr_ext
233 unsigned char p_adr[4];
234 unsigned char p_isym[4];
235 unsigned char p_iline[4];
236 unsigned char p_regmask[4];
237 unsigned char p_regoffset[4];
238 unsigned char p_iopt[4];
239 unsigned char p_fregmask[4];
240 unsigned char p_fregoffset[4];
241 unsigned char p_frameoffset[4];
242 unsigned char p_framereg[2];
243 unsigned char p_pcreg[2];
244 unsigned char p_lnLow[4];
245 unsigned char p_lnHigh[4];
246 unsigned char p_cbLineOffset[4];
249 /* Runtime procedure table */
251 struct rpdr_ext
253 unsigned char p_adr[4];
254 unsigned char p_regmask[4];
255 unsigned char p_regoffset[4];
256 unsigned char p_fregmask[4];
257 unsigned char p_fregoffset[4];
258 unsigned char p_frameoffset[4];
259 unsigned char p_framereg[2];
260 unsigned char p_pcreg[2];
261 unsigned char p_irpss[4];
262 unsigned char p_reserved[4];
263 unsigned char p_exception_info[4];
266 /* Line numbers */
268 struct line_ext
270 unsigned char l_line[4];
273 /* Symbol external record */
275 struct sym_ext
277 unsigned char s_iss[4];
278 unsigned char s_value[4];
279 unsigned char s_bits1[1];
280 unsigned char s_bits2[1];
281 unsigned char s_bits3[1];
282 unsigned char s_bits4[1];
285 #define SYM_BITS1_ST_BIG 0xFC
286 #define SYM_BITS1_ST_SH_BIG 2
287 #define SYM_BITS1_ST_LITTLE 0x3F
288 #define SYM_BITS1_ST_SH_LITTLE 0
290 #define SYM_BITS1_SC_BIG 0x03
291 #define SYM_BITS1_SC_SH_LEFT_BIG 3
292 #define SYM_BITS1_SC_LITTLE 0xC0
293 #define SYM_BITS1_SC_SH_LITTLE 6
295 #define SYM_BITS2_SC_BIG 0xE0
296 #define SYM_BITS2_SC_SH_BIG 5
297 #define SYM_BITS2_SC_LITTLE 0x07
298 #define SYM_BITS2_SC_SH_LEFT_LITTLE 2
300 #define SYM_BITS2_RESERVED_BIG 0x10
301 #define SYM_BITS2_RESERVED_LITTLE 0x08
303 #define SYM_BITS2_INDEX_BIG 0x0F
304 #define SYM_BITS2_INDEX_SH_LEFT_BIG 16
305 #define SYM_BITS2_INDEX_LITTLE 0xF0
306 #define SYM_BITS2_INDEX_SH_LITTLE 4
308 #define SYM_BITS3_INDEX_SH_LEFT_BIG 8
309 #define SYM_BITS3_INDEX_SH_LEFT_LITTLE 4
311 #define SYM_BITS4_INDEX_SH_LEFT_BIG 0
312 #define SYM_BITS4_INDEX_SH_LEFT_LITTLE 12
314 /* External symbol external record */
316 struct ext_ext
318 unsigned char es_bits1[1];
319 unsigned char es_bits2[1];
320 unsigned char es_ifd[2];
321 struct sym_ext es_asym;
324 #define EXT_BITS1_JMPTBL_BIG 0x80
325 #define EXT_BITS1_JMPTBL_LITTLE 0x01
327 #define EXT_BITS1_COBOL_MAIN_BIG 0x40
328 #define EXT_BITS1_COBOL_MAIN_LITTLE 0x02
330 #define EXT_BITS1_WEAKEXT_BIG 0x20
331 #define EXT_BITS1_WEAKEXT_LITTLE 0x04
333 /* Dense numbers external record */
335 struct dnr_ext
337 unsigned char d_rfd[4];
338 unsigned char d_index[4];
341 /* Relative file descriptor */
343 struct rfd_ext
345 unsigned char rfd[4];
348 /* Optimizer symbol external record */
350 struct opt_ext
352 unsigned char o_bits1[1];
353 unsigned char o_bits2[1];
354 unsigned char o_bits3[1];
355 unsigned char o_bits4[1];
356 struct rndx_ext o_rndx;
357 unsigned char o_offset[4];
360 #define OPT_BITS2_VALUE_SH_LEFT_BIG 16
361 #define OPT_BITS2_VALUE_SH_LEFT_LITTLE 0
363 #define OPT_BITS3_VALUE_SH_LEFT_BIG 8
364 #define OPT_BITS3_VALUE_SH_LEFT_LITTLE 8
366 #define OPT_BITS4_VALUE_SH_LEFT_BIG 0
367 #define OPT_BITS4_VALUE_SH_LEFT_LITTLE 16