daily update
[binutils.git] / bfd / elf32-mips.c
blobf1667321025e18f3c87f0adb45f2f1bdac62fc22
1 /* MIPS-specific support for 32-bit ELF
2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
5 Most of the information added by Ian Lance Taylor, Cygnus Support,
6 <ian@cygnus.com>.
7 N32/64 ABI support added by Mark Mitchell, CodeSourcery, LLC.
8 <mark@codesourcery.com>
9 Traditional MIPS targets support added by Koundinya.K, Dansk Data
10 Elektronik & Operations Research Group. <kk@ddeorg.soft.net>
12 This file is part of BFD, the Binary File Descriptor library.
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
28 /* This file handles MIPS ELF targets. SGI Irix 5 uses a slightly
29 different MIPS ELF from other targets. This matters when linking.
30 This file supports both, switching at runtime. */
32 #include "bfd.h"
33 #include "sysdep.h"
34 #include "libbfd.h"
35 #include "bfdlink.h"
36 #include "genlink.h"
37 #include "elf-bfd.h"
38 #include "elfxx-mips.h"
39 #include "elf/mips.h"
41 /* Get the ECOFF swapping routines. */
42 #include "coff/sym.h"
43 #include "coff/symconst.h"
44 #include "coff/internal.h"
45 #include "coff/ecoff.h"
46 #include "coff/mips.h"
47 #define ECOFF_SIGNED_32
48 #include "ecoffswap.h"
50 static bfd_reloc_status_type mips_elf_hi16_reloc
51 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
52 static bfd_reloc_status_type mips_elf_lo16_reloc
53 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
54 static bfd_reloc_status_type mips_elf_got16_reloc
55 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
56 static bfd_reloc_status_type mips_elf_gprel32_reloc
57 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
58 static bfd_reloc_status_type mips32_64bit_reloc
59 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
60 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
61 PARAMS ((bfd *, bfd_reloc_code_real_type));
62 static reloc_howto_type *mips_elf32_rtype_to_howto
63 PARAMS ((unsigned int, boolean));
64 static void mips_info_to_howto_rel
65 PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
66 static void mips_info_to_howto_rela
67 PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
68 static boolean mips_elf_sym_is_global PARAMS ((bfd *, asymbol *));
69 static boolean mips_elf32_object_p PARAMS ((bfd *));
70 static boolean mips_elf_is_local_label_name
71 PARAMS ((bfd *, const char *));
72 static bfd_reloc_status_type mips16_jump_reloc
73 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
74 static bfd_reloc_status_type mips16_gprel_reloc
75 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
76 static bfd_reloc_status_type mips_elf_final_gp
77 PARAMS ((bfd *, asymbol *, boolean, char **, bfd_vma *));
78 static boolean mips_elf_assign_gp PARAMS ((bfd *, bfd_vma *));
79 static boolean elf32_mips_grok_prstatus
80 PARAMS ((bfd *, Elf_Internal_Note *));
81 static boolean elf32_mips_grok_psinfo
82 PARAMS ((bfd *, Elf_Internal_Note *));
83 static irix_compat_t elf32_mips_irix_compat
84 PARAMS ((bfd *));
86 extern const bfd_target bfd_elf32_bigmips_vec;
87 extern const bfd_target bfd_elf32_littlemips_vec;
89 /* Nonzero if ABFD is using the N32 ABI. */
90 #define ABI_N32_P(abfd) \
91 ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
93 /* Whether we are trying to be compatible with IRIX at all. */
94 #define SGI_COMPAT(abfd) \
95 (elf32_mips_irix_compat (abfd) != ict_none)
97 /* The number of local .got entries we reserve. */
98 #define MIPS_RESERVED_GOTNO (2)
100 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
101 from smaller values. Start with zero, widen, *then* decrement. */
102 #define MINUS_ONE (((bfd_vma)0) - 1)
104 /* The relocation table used for SHT_REL sections. */
106 static reloc_howto_type elf_mips_howto_table_rel[] =
108 /* No relocation. */
109 HOWTO (R_MIPS_NONE, /* type */
110 0, /* rightshift */
111 0, /* size (0 = byte, 1 = short, 2 = long) */
112 0, /* bitsize */
113 false, /* pc_relative */
114 0, /* bitpos */
115 complain_overflow_dont, /* complain_on_overflow */
116 bfd_elf_generic_reloc, /* special_function */
117 "R_MIPS_NONE", /* name */
118 false, /* partial_inplace */
119 0, /* src_mask */
120 0, /* dst_mask */
121 false), /* pcrel_offset */
123 /* 16 bit relocation. */
124 HOWTO (R_MIPS_16, /* type */
125 0, /* rightshift */
126 2, /* size (0 = byte, 1 = short, 2 = long) */
127 16, /* bitsize */
128 false, /* pc_relative */
129 0, /* bitpos */
130 complain_overflow_signed, /* complain_on_overflow */
131 bfd_elf_generic_reloc, /* special_function */
132 "R_MIPS_16", /* name */
133 true, /* partial_inplace */
134 0x0000ffff, /* src_mask */
135 0x0000ffff, /* dst_mask */
136 false), /* pcrel_offset */
138 /* 32 bit relocation. */
139 HOWTO (R_MIPS_32, /* type */
140 0, /* rightshift */
141 2, /* size (0 = byte, 1 = short, 2 = long) */
142 32, /* bitsize */
143 false, /* pc_relative */
144 0, /* bitpos */
145 complain_overflow_dont, /* complain_on_overflow */
146 bfd_elf_generic_reloc, /* special_function */
147 "R_MIPS_32", /* name */
148 true, /* partial_inplace */
149 0xffffffff, /* src_mask */
150 0xffffffff, /* dst_mask */
151 false), /* pcrel_offset */
153 /* 32 bit symbol relative relocation. */
154 HOWTO (R_MIPS_REL32, /* type */
155 0, /* rightshift */
156 2, /* size (0 = byte, 1 = short, 2 = long) */
157 32, /* bitsize */
158 false, /* pc_relative */
159 0, /* bitpos */
160 complain_overflow_dont, /* complain_on_overflow */
161 bfd_elf_generic_reloc, /* special_function */
162 "R_MIPS_REL32", /* name */
163 true, /* partial_inplace */
164 0xffffffff, /* src_mask */
165 0xffffffff, /* dst_mask */
166 false), /* pcrel_offset */
168 /* 26 bit jump address. */
169 HOWTO (R_MIPS_26, /* type */
170 2, /* rightshift */
171 2, /* size (0 = byte, 1 = short, 2 = long) */
172 26, /* bitsize */
173 false, /* pc_relative */
174 0, /* bitpos */
175 complain_overflow_dont, /* complain_on_overflow */
176 /* This needs complex overflow
177 detection, because the upper four
178 bits must match the PC + 4. */
179 bfd_elf_generic_reloc, /* special_function */
180 "R_MIPS_26", /* name */
181 true, /* partial_inplace */
182 0x03ffffff, /* src_mask */
183 0x03ffffff, /* dst_mask */
184 false), /* pcrel_offset */
186 /* High 16 bits of symbol value. */
187 HOWTO (R_MIPS_HI16, /* type */
188 0, /* rightshift */
189 2, /* size (0 = byte, 1 = short, 2 = long) */
190 16, /* bitsize */
191 false, /* pc_relative */
192 0, /* bitpos */
193 complain_overflow_dont, /* complain_on_overflow */
194 mips_elf_hi16_reloc, /* special_function */
195 "R_MIPS_HI16", /* name */
196 true, /* partial_inplace */
197 0x0000ffff, /* src_mask */
198 0x0000ffff, /* dst_mask */
199 false), /* pcrel_offset */
201 /* Low 16 bits of symbol value. */
202 HOWTO (R_MIPS_LO16, /* type */
203 0, /* rightshift */
204 2, /* size (0 = byte, 1 = short, 2 = long) */
205 16, /* bitsize */
206 false, /* pc_relative */
207 0, /* bitpos */
208 complain_overflow_dont, /* complain_on_overflow */
209 mips_elf_lo16_reloc, /* special_function */
210 "R_MIPS_LO16", /* name */
211 true, /* partial_inplace */
212 0x0000ffff, /* src_mask */
213 0x0000ffff, /* dst_mask */
214 false), /* pcrel_offset */
216 /* GP relative reference. */
217 HOWTO (R_MIPS_GPREL16, /* type */
218 0, /* rightshift */
219 2, /* size (0 = byte, 1 = short, 2 = long) */
220 16, /* bitsize */
221 false, /* pc_relative */
222 0, /* bitpos */
223 complain_overflow_signed, /* complain_on_overflow */
224 _bfd_mips_elf32_gprel16_reloc, /* special_function */
225 "R_MIPS_GPREL16", /* name */
226 true, /* partial_inplace */
227 0x0000ffff, /* src_mask */
228 0x0000ffff, /* dst_mask */
229 false), /* pcrel_offset */
231 /* Reference to literal section. */
232 HOWTO (R_MIPS_LITERAL, /* type */
233 0, /* rightshift */
234 2, /* size (0 = byte, 1 = short, 2 = long) */
235 16, /* bitsize */
236 false, /* pc_relative */
237 0, /* bitpos */
238 complain_overflow_signed, /* complain_on_overflow */
239 _bfd_mips_elf32_gprel16_reloc, /* special_function */
240 "R_MIPS_LITERAL", /* name */
241 true, /* partial_inplace */
242 0x0000ffff, /* src_mask */
243 0x0000ffff, /* dst_mask */
244 false), /* pcrel_offset */
246 /* Reference to global offset table. */
247 HOWTO (R_MIPS_GOT16, /* type */
248 0, /* rightshift */
249 2, /* size (0 = byte, 1 = short, 2 = long) */
250 16, /* bitsize */
251 false, /* pc_relative */
252 0, /* bitpos */
253 complain_overflow_signed, /* complain_on_overflow */
254 mips_elf_got16_reloc, /* special_function */
255 "R_MIPS_GOT16", /* name */
256 true, /* partial_inplace */
257 0x0000ffff, /* src_mask */
258 0x0000ffff, /* dst_mask */
259 false), /* pcrel_offset */
261 /* 16 bit PC relative reference. */
262 HOWTO (R_MIPS_PC16, /* type */
263 0, /* rightshift */
264 2, /* size (0 = byte, 1 = short, 2 = long) */
265 16, /* bitsize */
266 true, /* pc_relative */
267 0, /* bitpos */
268 complain_overflow_signed, /* complain_on_overflow */
269 bfd_elf_generic_reloc, /* special_function */
270 "R_MIPS_PC16", /* name */
271 true, /* partial_inplace */
272 0x0000ffff, /* src_mask */
273 0x0000ffff, /* dst_mask */
274 true), /* pcrel_offset */
276 /* 16 bit call through global offset table. */
277 HOWTO (R_MIPS_CALL16, /* type */
278 0, /* rightshift */
279 2, /* size (0 = byte, 1 = short, 2 = long) */
280 16, /* bitsize */
281 false, /* pc_relative */
282 0, /* bitpos */
283 complain_overflow_signed, /* complain_on_overflow */
284 bfd_elf_generic_reloc, /* special_function */
285 "R_MIPS_CALL16", /* name */
286 true, /* partial_inplace */
287 0x0000ffff, /* src_mask */
288 0x0000ffff, /* dst_mask */
289 false), /* pcrel_offset */
291 /* 32 bit GP relative reference. */
292 HOWTO (R_MIPS_GPREL32, /* type */
293 0, /* rightshift */
294 2, /* size (0 = byte, 1 = short, 2 = long) */
295 32, /* bitsize */
296 false, /* pc_relative */
297 0, /* bitpos */
298 complain_overflow_dont, /* complain_on_overflow */
299 mips_elf_gprel32_reloc, /* special_function */
300 "R_MIPS_GPREL32", /* name */
301 true, /* partial_inplace */
302 0xffffffff, /* src_mask */
303 0xffffffff, /* dst_mask */
304 false), /* pcrel_offset */
306 /* The remaining relocs are defined on Irix 5, although they are
307 not defined by the ABI. */
308 EMPTY_HOWTO (13),
309 EMPTY_HOWTO (14),
310 EMPTY_HOWTO (15),
312 /* A 5 bit shift field. */
313 HOWTO (R_MIPS_SHIFT5, /* type */
314 0, /* rightshift */
315 2, /* size (0 = byte, 1 = short, 2 = long) */
316 5, /* bitsize */
317 false, /* pc_relative */
318 6, /* bitpos */
319 complain_overflow_bitfield, /* complain_on_overflow */
320 bfd_elf_generic_reloc, /* special_function */
321 "R_MIPS_SHIFT5", /* name */
322 true, /* partial_inplace */
323 0x000007c0, /* src_mask */
324 0x000007c0, /* dst_mask */
325 false), /* pcrel_offset */
327 /* A 6 bit shift field. */
328 /* FIXME: This is not handled correctly; a special function is
329 needed to put the most significant bit in the right place. */
330 HOWTO (R_MIPS_SHIFT6, /* type */
331 0, /* rightshift */
332 2, /* size (0 = byte, 1 = short, 2 = long) */
333 6, /* bitsize */
334 false, /* pc_relative */
335 6, /* bitpos */
336 complain_overflow_bitfield, /* complain_on_overflow */
337 bfd_elf_generic_reloc, /* special_function */
338 "R_MIPS_SHIFT6", /* name */
339 true, /* partial_inplace */
340 0x000007c4, /* src_mask */
341 0x000007c4, /* dst_mask */
342 false), /* pcrel_offset */
344 /* A 64 bit relocation. */
345 HOWTO (R_MIPS_64, /* type */
346 0, /* rightshift */
347 4, /* size (0 = byte, 1 = short, 2 = long) */
348 64, /* bitsize */
349 false, /* pc_relative */
350 0, /* bitpos */
351 complain_overflow_dont, /* complain_on_overflow */
352 mips32_64bit_reloc, /* special_function */
353 "R_MIPS_64", /* name */
354 true, /* partial_inplace */
355 MINUS_ONE, /* src_mask */
356 MINUS_ONE, /* dst_mask */
357 false), /* pcrel_offset */
359 /* Displacement in the global offset table. */
360 HOWTO (R_MIPS_GOT_DISP, /* type */
361 0, /* rightshift */
362 2, /* size (0 = byte, 1 = short, 2 = long) */
363 16, /* bitsize */
364 false, /* pc_relative */
365 0, /* bitpos */
366 complain_overflow_signed, /* complain_on_overflow */
367 bfd_elf_generic_reloc, /* special_function */
368 "R_MIPS_GOT_DISP", /* name */
369 true, /* partial_inplace */
370 0x0000ffff, /* src_mask */
371 0x0000ffff, /* dst_mask */
372 false), /* pcrel_offset */
374 /* Displacement to page pointer in the global offset table. */
375 HOWTO (R_MIPS_GOT_PAGE, /* type */
376 0, /* rightshift */
377 2, /* size (0 = byte, 1 = short, 2 = long) */
378 16, /* bitsize */
379 false, /* pc_relative */
380 0, /* bitpos */
381 complain_overflow_signed, /* complain_on_overflow */
382 bfd_elf_generic_reloc, /* special_function */
383 "R_MIPS_GOT_PAGE", /* name */
384 true, /* partial_inplace */
385 0x0000ffff, /* src_mask */
386 0x0000ffff, /* dst_mask */
387 false), /* pcrel_offset */
389 /* Offset from page pointer in the global offset table. */
390 HOWTO (R_MIPS_GOT_OFST, /* type */
391 0, /* rightshift */
392 2, /* size (0 = byte, 1 = short, 2 = long) */
393 16, /* bitsize */
394 false, /* pc_relative */
395 0, /* bitpos */
396 complain_overflow_signed, /* complain_on_overflow */
397 bfd_elf_generic_reloc, /* special_function */
398 "R_MIPS_GOT_OFST", /* name */
399 true, /* partial_inplace */
400 0x0000ffff, /* src_mask */
401 0x0000ffff, /* dst_mask */
402 false), /* pcrel_offset */
404 /* High 16 bits of displacement in global offset table. */
405 HOWTO (R_MIPS_GOT_HI16, /* type */
406 0, /* rightshift */
407 2, /* size (0 = byte, 1 = short, 2 = long) */
408 16, /* bitsize */
409 false, /* pc_relative */
410 0, /* bitpos */
411 complain_overflow_dont, /* complain_on_overflow */
412 bfd_elf_generic_reloc, /* special_function */
413 "R_MIPS_GOT_HI16", /* name */
414 true, /* partial_inplace */
415 0x0000ffff, /* src_mask */
416 0x0000ffff, /* dst_mask */
417 false), /* pcrel_offset */
419 /* Low 16 bits of displacement in global offset table. */
420 HOWTO (R_MIPS_GOT_LO16, /* type */
421 0, /* rightshift */
422 2, /* size (0 = byte, 1 = short, 2 = long) */
423 16, /* bitsize */
424 false, /* pc_relative */
425 0, /* bitpos */
426 complain_overflow_dont, /* complain_on_overflow */
427 bfd_elf_generic_reloc, /* special_function */
428 "R_MIPS_GOT_LO16", /* name */
429 true, /* partial_inplace */
430 0x0000ffff, /* src_mask */
431 0x0000ffff, /* dst_mask */
432 false), /* pcrel_offset */
434 /* 64 bit subtraction. Used in the N32 ABI. */
435 HOWTO (R_MIPS_SUB, /* type */
436 0, /* rightshift */
437 4, /* size (0 = byte, 1 = short, 2 = long) */
438 64, /* bitsize */
439 false, /* pc_relative */
440 0, /* bitpos */
441 complain_overflow_dont, /* complain_on_overflow */
442 bfd_elf_generic_reloc, /* special_function */
443 "R_MIPS_SUB", /* name */
444 true, /* partial_inplace */
445 MINUS_ONE, /* src_mask */
446 MINUS_ONE, /* dst_mask */
447 false), /* pcrel_offset */
449 /* Used to cause the linker to insert and delete instructions? */
450 EMPTY_HOWTO (R_MIPS_INSERT_A),
451 EMPTY_HOWTO (R_MIPS_INSERT_B),
452 EMPTY_HOWTO (R_MIPS_DELETE),
454 /* Get the higher value of a 64 bit addend. */
455 HOWTO (R_MIPS_HIGHER, /* type */
456 0, /* rightshift */
457 2, /* size (0 = byte, 1 = short, 2 = long) */
458 16, /* bitsize */
459 false, /* pc_relative */
460 0, /* bitpos */
461 complain_overflow_dont, /* complain_on_overflow */
462 bfd_elf_generic_reloc, /* special_function */
463 "R_MIPS_HIGHER", /* name */
464 true, /* partial_inplace */
465 0x0000ffff, /* src_mask */
466 0x0000ffff, /* dst_mask */
467 false), /* pcrel_offset */
469 /* Get the highest value of a 64 bit addend. */
470 HOWTO (R_MIPS_HIGHEST, /* type */
471 0, /* rightshift */
472 2, /* size (0 = byte, 1 = short, 2 = long) */
473 16, /* bitsize */
474 false, /* pc_relative */
475 0, /* bitpos */
476 complain_overflow_dont, /* complain_on_overflow */
477 bfd_elf_generic_reloc, /* special_function */
478 "R_MIPS_HIGHEST", /* name */
479 true, /* partial_inplace */
480 0x0000ffff, /* src_mask */
481 0x0000ffff, /* dst_mask */
482 false), /* pcrel_offset */
484 /* High 16 bits of displacement in global offset table. */
485 HOWTO (R_MIPS_CALL_HI16, /* type */
486 0, /* rightshift */
487 2, /* size (0 = byte, 1 = short, 2 = long) */
488 16, /* bitsize */
489 false, /* pc_relative */
490 0, /* bitpos */
491 complain_overflow_dont, /* complain_on_overflow */
492 bfd_elf_generic_reloc, /* special_function */
493 "R_MIPS_CALL_HI16", /* name */
494 true, /* partial_inplace */
495 0x0000ffff, /* src_mask */
496 0x0000ffff, /* dst_mask */
497 false), /* pcrel_offset */
499 /* Low 16 bits of displacement in global offset table. */
500 HOWTO (R_MIPS_CALL_LO16, /* type */
501 0, /* rightshift */
502 2, /* size (0 = byte, 1 = short, 2 = long) */
503 16, /* bitsize */
504 false, /* pc_relative */
505 0, /* bitpos */
506 complain_overflow_dont, /* complain_on_overflow */
507 bfd_elf_generic_reloc, /* special_function */
508 "R_MIPS_CALL_LO16", /* name */
509 true, /* partial_inplace */
510 0x0000ffff, /* src_mask */
511 0x0000ffff, /* dst_mask */
512 false), /* pcrel_offset */
514 /* Section displacement. */
515 HOWTO (R_MIPS_SCN_DISP, /* type */
516 0, /* rightshift */
517 2, /* size (0 = byte, 1 = short, 2 = long) */
518 32, /* bitsize */
519 false, /* pc_relative */
520 0, /* bitpos */
521 complain_overflow_dont, /* complain_on_overflow */
522 bfd_elf_generic_reloc, /* special_function */
523 "R_MIPS_SCN_DISP", /* name */
524 true, /* partial_inplace */
525 0xffffffff, /* src_mask */
526 0xffffffff, /* dst_mask */
527 false), /* pcrel_offset */
529 EMPTY_HOWTO (R_MIPS_REL16),
530 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
531 EMPTY_HOWTO (R_MIPS_PJUMP),
532 EMPTY_HOWTO (R_MIPS_RELGOT),
534 /* Protected jump conversion. This is an optimization hint. No
535 relocation is required for correctness. */
536 HOWTO (R_MIPS_JALR, /* type */
537 0, /* rightshift */
538 2, /* size (0 = byte, 1 = short, 2 = long) */
539 32, /* bitsize */
540 false, /* pc_relative */
541 0, /* bitpos */
542 complain_overflow_dont, /* complain_on_overflow */
543 bfd_elf_generic_reloc, /* special_function */
544 "R_MIPS_JALR", /* name */
545 false, /* partial_inplace */
546 0x00000000, /* src_mask */
547 0x00000000, /* dst_mask */
548 false), /* pcrel_offset */
551 /* The reloc used for BFD_RELOC_CTOR when doing a 64 bit link. This
552 is a hack to make the linker think that we need 64 bit values. */
553 static reloc_howto_type elf_mips_ctor64_howto =
554 HOWTO (R_MIPS_64, /* type */
555 0, /* rightshift */
556 4, /* size (0 = byte, 1 = short, 2 = long) */
557 32, /* bitsize */
558 false, /* pc_relative */
559 0, /* bitpos */
560 complain_overflow_signed, /* complain_on_overflow */
561 mips32_64bit_reloc, /* special_function */
562 "R_MIPS_64", /* name */
563 true, /* partial_inplace */
564 0xffffffff, /* src_mask */
565 0xffffffff, /* dst_mask */
566 false); /* pcrel_offset */
568 /* The reloc used for the mips16 jump instruction. */
569 static reloc_howto_type elf_mips16_jump_howto =
570 HOWTO (R_MIPS16_26, /* type */
571 2, /* rightshift */
572 2, /* size (0 = byte, 1 = short, 2 = long) */
573 26, /* bitsize */
574 false, /* pc_relative */
575 0, /* bitpos */
576 complain_overflow_dont, /* complain_on_overflow */
577 /* This needs complex overflow
578 detection, because the upper four
579 bits must match the PC. */
580 mips16_jump_reloc, /* special_function */
581 "R_MIPS16_26", /* name */
582 true, /* partial_inplace */
583 0x3ffffff, /* src_mask */
584 0x3ffffff, /* dst_mask */
585 false); /* pcrel_offset */
587 /* The reloc used for the mips16 gprel instruction. */
588 static reloc_howto_type elf_mips16_gprel_howto =
589 HOWTO (R_MIPS16_GPREL, /* type */
590 0, /* rightshift */
591 2, /* size (0 = byte, 1 = short, 2 = long) */
592 16, /* bitsize */
593 false, /* pc_relative */
594 0, /* bitpos */
595 complain_overflow_signed, /* complain_on_overflow */
596 mips16_gprel_reloc, /* special_function */
597 "R_MIPS16_GPREL", /* name */
598 true, /* partial_inplace */
599 0x07ff001f, /* src_mask */
600 0x07ff001f, /* dst_mask */
601 false); /* pcrel_offset */
603 /* GNU extensions for embedded-pic. */
604 /* High 16 bits of symbol value, pc-relative. */
605 static reloc_howto_type elf_mips_gnu_rel_hi16 =
606 HOWTO (R_MIPS_GNU_REL_HI16, /* type */
607 0, /* rightshift */
608 2, /* size (0 = byte, 1 = short, 2 = long) */
609 16, /* bitsize */
610 true, /* pc_relative */
611 0, /* bitpos */
612 complain_overflow_dont, /* complain_on_overflow */
613 mips_elf_hi16_reloc, /* special_function */
614 "R_MIPS_GNU_REL_HI16", /* name */
615 true, /* partial_inplace */
616 0xffff, /* src_mask */
617 0xffff, /* dst_mask */
618 true); /* pcrel_offset */
620 /* Low 16 bits of symbol value, pc-relative. */
621 static reloc_howto_type elf_mips_gnu_rel_lo16 =
622 HOWTO (R_MIPS_GNU_REL_LO16, /* type */
623 0, /* rightshift */
624 2, /* size (0 = byte, 1 = short, 2 = long) */
625 16, /* bitsize */
626 true, /* pc_relative */
627 0, /* bitpos */
628 complain_overflow_dont, /* complain_on_overflow */
629 mips_elf_lo16_reloc, /* special_function */
630 "R_MIPS_GNU_REL_LO16", /* name */
631 true, /* partial_inplace */
632 0xffff, /* src_mask */
633 0xffff, /* dst_mask */
634 true); /* pcrel_offset */
636 /* 16 bit offset for pc-relative branches. */
637 static reloc_howto_type elf_mips_gnu_rel16_s2 =
638 HOWTO (R_MIPS_GNU_REL16_S2, /* type */
639 2, /* rightshift */
640 2, /* size (0 = byte, 1 = short, 2 = long) */
641 16, /* bitsize */
642 true, /* pc_relative */
643 0, /* bitpos */
644 complain_overflow_signed, /* complain_on_overflow */
645 bfd_elf_generic_reloc, /* special_function */
646 "R_MIPS_GNU_REL16_S2", /* name */
647 true, /* partial_inplace */
648 0xffff, /* src_mask */
649 0xffff, /* dst_mask */
650 true); /* pcrel_offset */
652 /* 64 bit pc-relative. */
653 static reloc_howto_type elf_mips_gnu_pcrel64 =
654 HOWTO (R_MIPS_PC64, /* type */
655 0, /* rightshift */
656 4, /* size (0 = byte, 1 = short, 2 = long) */
657 64, /* bitsize */
658 true, /* pc_relative */
659 0, /* bitpos */
660 complain_overflow_signed, /* complain_on_overflow */
661 bfd_elf_generic_reloc, /* special_function */
662 "R_MIPS_PC64", /* name */
663 true, /* partial_inplace */
664 MINUS_ONE, /* src_mask */
665 MINUS_ONE, /* dst_mask */
666 true); /* pcrel_offset */
668 /* 32 bit pc-relative. */
669 static reloc_howto_type elf_mips_gnu_pcrel32 =
670 HOWTO (R_MIPS_PC32, /* type */
671 0, /* rightshift */
672 2, /* size (0 = byte, 1 = short, 2 = long) */
673 32, /* bitsize */
674 true, /* pc_relative */
675 0, /* bitpos */
676 complain_overflow_signed, /* complain_on_overflow */
677 bfd_elf_generic_reloc, /* special_function */
678 "R_MIPS_PC32", /* name */
679 true, /* partial_inplace */
680 0xffffffff, /* src_mask */
681 0xffffffff, /* dst_mask */
682 true); /* pcrel_offset */
684 /* GNU extension to record C++ vtable hierarchy */
685 static reloc_howto_type elf_mips_gnu_vtinherit_howto =
686 HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
687 0, /* rightshift */
688 2, /* size (0 = byte, 1 = short, 2 = long) */
689 0, /* bitsize */
690 false, /* pc_relative */
691 0, /* bitpos */
692 complain_overflow_dont, /* complain_on_overflow */
693 NULL, /* special_function */
694 "R_MIPS_GNU_VTINHERIT", /* name */
695 false, /* partial_inplace */
696 0, /* src_mask */
697 0, /* dst_mask */
698 false); /* pcrel_offset */
700 /* GNU extension to record C++ vtable member usage */
701 static reloc_howto_type elf_mips_gnu_vtentry_howto =
702 HOWTO (R_MIPS_GNU_VTENTRY, /* type */
703 0, /* rightshift */
704 2, /* size (0 = byte, 1 = short, 2 = long) */
705 0, /* bitsize */
706 false, /* pc_relative */
707 0, /* bitpos */
708 complain_overflow_dont, /* complain_on_overflow */
709 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
710 "R_MIPS_GNU_VTENTRY", /* name */
711 false, /* partial_inplace */
712 0, /* src_mask */
713 0, /* dst_mask */
714 false); /* pcrel_offset */
716 /* Do a R_MIPS_HI16 relocation. This has to be done in combination
717 with a R_MIPS_LO16 reloc, because there is a carry from the LO16 to
718 the HI16. Here we just save the information we need; we do the
719 actual relocation when we see the LO16.
721 MIPS ELF requires that the LO16 immediately follow the HI16. As a
722 GNU extension, for non-pc-relative relocations, we permit an
723 arbitrary number of HI16 relocs to be associated with a single LO16
724 reloc. This extension permits gcc to output the HI and LO relocs
725 itself.
727 This cannot be done for PC-relative relocations because both the HI16
728 and LO16 parts of the relocations must be done relative to the LO16
729 part, and there can be carry to or borrow from the HI16 part. */
731 struct mips_hi16
733 struct mips_hi16 *next;
734 bfd_byte *addr;
735 bfd_vma addend;
738 /* FIXME: This should not be a static variable. */
740 static struct mips_hi16 *mips_hi16_list;
742 static bfd_reloc_status_type
743 mips_elf_hi16_reloc (abfd, reloc_entry, symbol, data, input_section,
744 output_bfd, error_message)
745 bfd *abfd ATTRIBUTE_UNUSED;
746 arelent *reloc_entry;
747 asymbol *symbol;
748 PTR data;
749 asection *input_section;
750 bfd *output_bfd;
751 char **error_message;
753 bfd_reloc_status_type ret;
754 bfd_vma relocation;
755 struct mips_hi16 *n;
757 /* If we're relocating, and this is an external symbol, we don't want
758 to change anything. */
759 if (output_bfd != (bfd *) NULL
760 && (symbol->flags & BSF_SECTION_SYM) == 0
761 && reloc_entry->addend == 0)
763 reloc_entry->address += input_section->output_offset;
764 return bfd_reloc_ok;
767 ret = bfd_reloc_ok;
769 if (strcmp (bfd_asymbol_name (symbol), "_gp_disp") == 0)
771 boolean relocateable;
772 bfd_vma gp;
774 if (ret == bfd_reloc_undefined)
775 abort ();
777 if (output_bfd != NULL)
778 relocateable = true;
779 else
781 relocateable = false;
782 output_bfd = symbol->section->output_section->owner;
785 ret = mips_elf_final_gp (output_bfd, symbol, relocateable,
786 error_message, &gp);
787 if (ret != bfd_reloc_ok)
788 return ret;
790 relocation = gp - reloc_entry->address;
792 else
794 if (bfd_is_und_section (symbol->section)
795 && output_bfd == (bfd *) NULL)
796 ret = bfd_reloc_undefined;
798 if (bfd_is_com_section (symbol->section))
799 relocation = 0;
800 else
801 relocation = symbol->value;
804 relocation += symbol->section->output_section->vma;
805 relocation += symbol->section->output_offset;
806 relocation += reloc_entry->addend;
808 if (reloc_entry->address > input_section->_cooked_size)
809 return bfd_reloc_outofrange;
811 /* Save the information, and let LO16 do the actual relocation. */
812 n = (struct mips_hi16 *) bfd_malloc ((bfd_size_type) sizeof *n);
813 if (n == NULL)
814 return bfd_reloc_outofrange;
815 n->addr = (bfd_byte *) data + reloc_entry->address;
816 n->addend = relocation;
817 n->next = mips_hi16_list;
818 mips_hi16_list = n;
820 if (output_bfd != (bfd *) NULL)
821 reloc_entry->address += input_section->output_offset;
823 return ret;
826 /* Do a R_MIPS_LO16 relocation. This is a straightforward 16 bit
827 inplace relocation; this function exists in order to do the
828 R_MIPS_HI16 relocation described above. */
830 static bfd_reloc_status_type
831 mips_elf_lo16_reloc (abfd, reloc_entry, symbol, data, input_section,
832 output_bfd, error_message)
833 bfd *abfd;
834 arelent *reloc_entry;
835 asymbol *symbol;
836 PTR data;
837 asection *input_section;
838 bfd *output_bfd;
839 char **error_message;
841 arelent gp_disp_relent;
843 if (mips_hi16_list != NULL)
845 struct mips_hi16 *l;
847 l = mips_hi16_list;
848 while (l != NULL)
850 unsigned long insn;
851 unsigned long val;
852 unsigned long vallo;
853 struct mips_hi16 *next;
855 /* Do the HI16 relocation. Note that we actually don't need
856 to know anything about the LO16 itself, except where to
857 find the low 16 bits of the addend needed by the LO16. */
858 insn = bfd_get_32 (abfd, l->addr);
859 vallo = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
861 /* The low order 16 bits are always treated as a signed
862 value. */
863 vallo = ((vallo & 0xffff) ^ 0x8000) - 0x8000;
864 val = ((insn & 0xffff) << 16) + vallo;
865 val += l->addend;
867 /* If PC-relative, we need to subtract out the address of the LO
868 half of the HI/LO. (The actual relocation is relative
869 to that instruction.) */
870 if (reloc_entry->howto->pc_relative)
871 val -= reloc_entry->address;
873 /* At this point, "val" has the value of the combined HI/LO
874 pair. If the low order 16 bits (which will be used for
875 the LO16 insn) are negative, then we will need an
876 adjustment for the high order 16 bits. */
877 val += 0x8000;
878 val = (val >> 16) & 0xffff;
880 insn &= ~ (bfd_vma) 0xffff;
881 insn |= val;
882 bfd_put_32 (abfd, (bfd_vma) insn, l->addr);
884 if (strcmp (bfd_asymbol_name (symbol), "_gp_disp") == 0)
886 gp_disp_relent = *reloc_entry;
887 reloc_entry = &gp_disp_relent;
888 reloc_entry->addend = l->addend;
891 next = l->next;
892 free (l);
893 l = next;
896 mips_hi16_list = NULL;
898 else if (strcmp (bfd_asymbol_name (symbol), "_gp_disp") == 0)
900 bfd_reloc_status_type ret;
901 bfd_vma gp, relocation;
903 /* FIXME: Does this case ever occur? */
905 ret = mips_elf_final_gp (output_bfd, symbol, true, error_message, &gp);
906 if (ret != bfd_reloc_ok)
907 return ret;
909 relocation = gp - reloc_entry->address;
910 relocation += symbol->section->output_section->vma;
911 relocation += symbol->section->output_offset;
912 relocation += reloc_entry->addend;
914 if (reloc_entry->address > input_section->_cooked_size)
915 return bfd_reloc_outofrange;
917 gp_disp_relent = *reloc_entry;
918 reloc_entry = &gp_disp_relent;
919 reloc_entry->addend = relocation - 4;
922 /* Now do the LO16 reloc in the usual way. */
923 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
924 input_section, output_bfd, error_message);
927 /* Do a R_MIPS_GOT16 reloc. This is a reloc against the global offset
928 table used for PIC code. If the symbol is an external symbol, the
929 instruction is modified to contain the offset of the appropriate
930 entry in the global offset table. If the symbol is a section
931 symbol, the next reloc is a R_MIPS_LO16 reloc. The two 16 bit
932 addends are combined to form the real addend against the section
933 symbol; the GOT16 is modified to contain the offset of an entry in
934 the global offset table, and the LO16 is modified to offset it
935 appropriately. Thus an offset larger than 16 bits requires a
936 modified value in the global offset table.
938 This implementation suffices for the assembler, but the linker does
939 not yet know how to create global offset tables. */
941 static bfd_reloc_status_type
942 mips_elf_got16_reloc (abfd, reloc_entry, symbol, data, input_section,
943 output_bfd, error_message)
944 bfd *abfd;
945 arelent *reloc_entry;
946 asymbol *symbol;
947 PTR data;
948 asection *input_section;
949 bfd *output_bfd;
950 char **error_message;
952 /* If we're relocating, and this is an external symbol, we don't want
953 to change anything. */
954 if (output_bfd != (bfd *) NULL
955 && (symbol->flags & BSF_SECTION_SYM) == 0
956 && reloc_entry->addend == 0)
958 reloc_entry->address += input_section->output_offset;
959 return bfd_reloc_ok;
962 /* If we're relocating, and this is a local symbol, we can handle it
963 just like HI16. */
964 if (output_bfd != (bfd *) NULL
965 && (symbol->flags & BSF_SECTION_SYM) != 0)
966 return mips_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
967 input_section, output_bfd, error_message);
969 abort ();
972 /* Set the GP value for OUTPUT_BFD. Returns false if this is a
973 dangerous relocation. */
975 static boolean
976 mips_elf_assign_gp (output_bfd, pgp)
977 bfd *output_bfd;
978 bfd_vma *pgp;
980 unsigned int count;
981 asymbol **sym;
982 unsigned int i;
984 /* If we've already figured out what GP will be, just return it. */
985 *pgp = _bfd_get_gp_value (output_bfd);
986 if (*pgp)
987 return true;
989 count = bfd_get_symcount (output_bfd);
990 sym = bfd_get_outsymbols (output_bfd);
992 /* The linker script will have created a symbol named `_gp' with the
993 appropriate value. */
994 if (sym == (asymbol **) NULL)
995 i = count;
996 else
998 for (i = 0; i < count; i++, sym++)
1000 register const char *name;
1002 name = bfd_asymbol_name (*sym);
1003 if (*name == '_' && strcmp (name, "_gp") == 0)
1005 *pgp = bfd_asymbol_value (*sym);
1006 _bfd_set_gp_value (output_bfd, *pgp);
1007 break;
1012 if (i >= count)
1014 /* Only get the error once. */
1015 *pgp = 4;
1016 _bfd_set_gp_value (output_bfd, *pgp);
1017 return false;
1020 return true;
1023 /* We have to figure out the gp value, so that we can adjust the
1024 symbol value correctly. We look up the symbol _gp in the output
1025 BFD. If we can't find it, we're stuck. We cache it in the ELF
1026 target data. We don't need to adjust the symbol value for an
1027 external symbol if we are producing relocateable output. */
1029 static bfd_reloc_status_type
1030 mips_elf_final_gp (output_bfd, symbol, relocateable, error_message, pgp)
1031 bfd *output_bfd;
1032 asymbol *symbol;
1033 boolean relocateable;
1034 char **error_message;
1035 bfd_vma *pgp;
1037 if (bfd_is_und_section (symbol->section)
1038 && ! relocateable)
1040 *pgp = 0;
1041 return bfd_reloc_undefined;
1044 *pgp = _bfd_get_gp_value (output_bfd);
1045 if (*pgp == 0
1046 && (! relocateable
1047 || (symbol->flags & BSF_SECTION_SYM) != 0))
1049 if (relocateable)
1051 /* Make up a value. */
1052 *pgp = symbol->section->output_section->vma + 0x4000;
1053 _bfd_set_gp_value (output_bfd, *pgp);
1055 else if (!mips_elf_assign_gp (output_bfd, pgp))
1057 *error_message =
1058 (char *) _("GP relative relocation when _gp not defined");
1059 return bfd_reloc_dangerous;
1063 return bfd_reloc_ok;
1066 /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
1067 become the offset from the gp register. This function also handles
1068 R_MIPS_LITERAL relocations, although those can be handled more
1069 cleverly because the entries in the .lit8 and .lit4 sections can be
1070 merged. */
1072 bfd_reloc_status_type
1073 _bfd_mips_elf32_gprel16_reloc (abfd, reloc_entry, symbol, data, input_section,
1074 output_bfd, error_message)
1075 bfd *abfd;
1076 arelent *reloc_entry;
1077 asymbol *symbol;
1078 PTR data;
1079 asection *input_section;
1080 bfd *output_bfd;
1081 char **error_message;
1083 boolean relocateable;
1084 bfd_reloc_status_type ret;
1085 bfd_vma gp;
1087 /* If we're relocating, and this is an external symbol with no
1088 addend, we don't want to change anything. We will only have an
1089 addend if this is a newly created reloc, not read from an ELF
1090 file. */
1091 if (output_bfd != (bfd *) NULL
1092 && (symbol->flags & BSF_SECTION_SYM) == 0
1093 && reloc_entry->addend == 0)
1095 reloc_entry->address += input_section->output_offset;
1096 return bfd_reloc_ok;
1099 if (output_bfd != (bfd *) NULL)
1100 relocateable = true;
1101 else
1103 relocateable = false;
1104 output_bfd = symbol->section->output_section->owner;
1107 ret = mips_elf_final_gp (output_bfd, symbol, relocateable, error_message,
1108 &gp);
1109 if (ret != bfd_reloc_ok)
1110 return ret;
1112 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1113 input_section, relocateable,
1114 data, gp);
1117 /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
1118 become the offset from the gp register. */
1120 static bfd_reloc_status_type gprel32_with_gp PARAMS ((bfd *, asymbol *,
1121 arelent *, asection *,
1122 boolean, PTR, bfd_vma));
1124 static bfd_reloc_status_type
1125 mips_elf_gprel32_reloc (abfd, reloc_entry, symbol, data, input_section,
1126 output_bfd, error_message)
1127 bfd *abfd;
1128 arelent *reloc_entry;
1129 asymbol *symbol;
1130 PTR data;
1131 asection *input_section;
1132 bfd *output_bfd;
1133 char **error_message;
1135 boolean relocateable;
1136 bfd_reloc_status_type ret;
1137 bfd_vma gp;
1139 /* If we're relocating, and this is an external symbol with no
1140 addend, we don't want to change anything. We will only have an
1141 addend if this is a newly created reloc, not read from an ELF
1142 file. */
1143 if (output_bfd != (bfd *) NULL
1144 && (symbol->flags & BSF_SECTION_SYM) == 0
1145 && reloc_entry->addend == 0)
1147 *error_message = (char *)
1148 _("32bits gp relative relocation occurs for an external symbol");
1149 return bfd_reloc_outofrange;
1152 if (output_bfd != (bfd *) NULL)
1154 relocateable = true;
1155 gp = _bfd_get_gp_value (output_bfd);
1157 else
1159 relocateable = false;
1160 output_bfd = symbol->section->output_section->owner;
1162 ret = mips_elf_final_gp (output_bfd, symbol, relocateable,
1163 error_message, &gp);
1164 if (ret != bfd_reloc_ok)
1165 return ret;
1168 return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
1169 relocateable, data, gp);
1172 static bfd_reloc_status_type
1173 gprel32_with_gp (abfd, symbol, reloc_entry, input_section, relocateable, data,
1175 bfd *abfd;
1176 asymbol *symbol;
1177 arelent *reloc_entry;
1178 asection *input_section;
1179 boolean relocateable;
1180 PTR data;
1181 bfd_vma gp;
1183 bfd_vma relocation;
1184 unsigned long val;
1186 if (bfd_is_com_section (symbol->section))
1187 relocation = 0;
1188 else
1189 relocation = symbol->value;
1191 relocation += symbol->section->output_section->vma;
1192 relocation += symbol->section->output_offset;
1194 if (reloc_entry->address > input_section->_cooked_size)
1195 return bfd_reloc_outofrange;
1197 if (reloc_entry->howto->src_mask == 0)
1199 /* This case arises with the 64-bit MIPS ELF ABI. */
1200 val = 0;
1202 else
1203 val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
1205 /* Set val to the offset into the section or symbol. */
1206 val += reloc_entry->addend;
1208 /* Adjust val for the final section location and GP value. If we
1209 are producing relocateable output, we don't want to do this for
1210 an external symbol. */
1211 if (! relocateable
1212 || (symbol->flags & BSF_SECTION_SYM) != 0)
1213 val += relocation - gp;
1215 bfd_put_32 (abfd, (bfd_vma) val, (bfd_byte *) data + reloc_entry->address);
1217 if (relocateable)
1218 reloc_entry->address += input_section->output_offset;
1220 return bfd_reloc_ok;
1223 /* Handle a 64 bit reloc in a 32 bit MIPS ELF file. These are
1224 generated when addresses are 64 bits. The upper 32 bits are a simple
1225 sign extension. */
1227 static bfd_reloc_status_type
1228 mips32_64bit_reloc (abfd, reloc_entry, symbol, data, input_section,
1229 output_bfd, error_message)
1230 bfd *abfd;
1231 arelent *reloc_entry;
1232 asymbol *symbol;
1233 PTR data;
1234 asection *input_section;
1235 bfd *output_bfd;
1236 char **error_message;
1238 bfd_reloc_status_type r;
1239 arelent reloc32;
1240 unsigned long val;
1241 bfd_size_type addr;
1243 r = bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
1244 input_section, output_bfd, error_message);
1245 if (r != bfd_reloc_continue)
1246 return r;
1248 /* Do a normal 32 bit relocation on the lower 32 bits. */
1249 reloc32 = *reloc_entry;
1250 if (bfd_big_endian (abfd))
1251 reloc32.address += 4;
1252 reloc32.howto = &elf_mips_howto_table_rel[R_MIPS_32];
1253 r = bfd_perform_relocation (abfd, &reloc32, data, input_section,
1254 output_bfd, error_message);
1256 /* Sign extend into the upper 32 bits. */
1257 val = bfd_get_32 (abfd, (bfd_byte *) data + reloc32.address);
1258 if ((val & 0x80000000) != 0)
1259 val = 0xffffffff;
1260 else
1261 val = 0;
1262 addr = reloc_entry->address;
1263 if (bfd_little_endian (abfd))
1264 addr += 4;
1265 bfd_put_32 (abfd, (bfd_vma) val, (bfd_byte *) data + addr);
1267 return r;
1270 /* Handle a mips16 jump. */
1272 static bfd_reloc_status_type
1273 mips16_jump_reloc (abfd, reloc_entry, symbol, data, input_section,
1274 output_bfd, error_message)
1275 bfd *abfd ATTRIBUTE_UNUSED;
1276 arelent *reloc_entry;
1277 asymbol *symbol;
1278 PTR data ATTRIBUTE_UNUSED;
1279 asection *input_section;
1280 bfd *output_bfd;
1281 char **error_message ATTRIBUTE_UNUSED;
1283 if (output_bfd != (bfd *) NULL
1284 && (symbol->flags & BSF_SECTION_SYM) == 0
1285 && reloc_entry->addend == 0)
1287 reloc_entry->address += input_section->output_offset;
1288 return bfd_reloc_ok;
1291 /* FIXME. */
1293 static boolean warned;
1295 if (! warned)
1296 (*_bfd_error_handler)
1297 (_("Linking mips16 objects into %s format is not supported"),
1298 bfd_get_target (input_section->output_section->owner));
1299 warned = true;
1302 return bfd_reloc_undefined;
1305 /* Handle a mips16 GP relative reloc. */
1307 static bfd_reloc_status_type
1308 mips16_gprel_reloc (abfd, reloc_entry, symbol, data, input_section,
1309 output_bfd, error_message)
1310 bfd *abfd;
1311 arelent *reloc_entry;
1312 asymbol *symbol;
1313 PTR data;
1314 asection *input_section;
1315 bfd *output_bfd;
1316 char **error_message;
1318 boolean relocateable;
1319 bfd_reloc_status_type ret;
1320 bfd_vma gp;
1321 unsigned short extend, insn;
1322 unsigned long final;
1324 /* If we're relocating, and this is an external symbol with no
1325 addend, we don't want to change anything. We will only have an
1326 addend if this is a newly created reloc, not read from an ELF
1327 file. */
1328 if (output_bfd != NULL
1329 && (symbol->flags & BSF_SECTION_SYM) == 0
1330 && reloc_entry->addend == 0)
1332 reloc_entry->address += input_section->output_offset;
1333 return bfd_reloc_ok;
1336 if (output_bfd != NULL)
1337 relocateable = true;
1338 else
1340 relocateable = false;
1341 output_bfd = symbol->section->output_section->owner;
1344 ret = mips_elf_final_gp (output_bfd, symbol, relocateable, error_message,
1345 &gp);
1346 if (ret != bfd_reloc_ok)
1347 return ret;
1349 if (reloc_entry->address > input_section->_cooked_size)
1350 return bfd_reloc_outofrange;
1352 /* Pick up the mips16 extend instruction and the real instruction. */
1353 extend = bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address);
1354 insn = bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address + 2);
1356 /* Stuff the current addend back as a 32 bit value, do the usual
1357 relocation, and then clean up. */
1358 bfd_put_32 (abfd,
1359 (bfd_vma) (((extend & 0x1f) << 11)
1360 | (extend & 0x7e0)
1361 | (insn & 0x1f)),
1362 (bfd_byte *) data + reloc_entry->address);
1364 ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1365 input_section, relocateable, data, gp);
1367 final = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
1368 bfd_put_16 (abfd,
1369 (bfd_vma) ((extend & 0xf800)
1370 | ((final >> 11) & 0x1f)
1371 | (final & 0x7e0)),
1372 (bfd_byte *) data + reloc_entry->address);
1373 bfd_put_16 (abfd,
1374 (bfd_vma) ((insn & 0xffe0)
1375 | (final & 0x1f)),
1376 (bfd_byte *) data + reloc_entry->address + 2);
1378 return ret;
1381 /* A mapping from BFD reloc types to MIPS ELF reloc types. */
1383 struct elf_reloc_map {
1384 bfd_reloc_code_real_type bfd_val;
1385 enum elf_mips_reloc_type elf_val;
1388 static const struct elf_reloc_map mips_reloc_map[] =
1390 { BFD_RELOC_NONE, R_MIPS_NONE },
1391 { BFD_RELOC_16, R_MIPS_16 },
1392 { BFD_RELOC_32, R_MIPS_32 },
1393 /* There is no BFD reloc for R_MIPS_REL32. */
1394 { BFD_RELOC_64, R_MIPS_64 },
1395 { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
1396 { BFD_RELOC_HI16_S, R_MIPS_HI16 },
1397 { BFD_RELOC_LO16, R_MIPS_LO16 },
1398 { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
1399 { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
1400 { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
1401 { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
1402 { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
1403 { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
1404 { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
1405 { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
1406 { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
1407 { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
1408 { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
1409 { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
1410 { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
1411 { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP }
1414 /* Given a BFD reloc type, return a howto structure. */
1416 static reloc_howto_type *
1417 bfd_elf32_bfd_reloc_type_lookup (abfd, code)
1418 bfd *abfd;
1419 bfd_reloc_code_real_type code;
1421 unsigned int i;
1422 reloc_howto_type *howto_table = elf_mips_howto_table_rel;
1424 for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
1425 i++)
1427 if (mips_reloc_map[i].bfd_val == code)
1428 return &howto_table[(int) mips_reloc_map[i].elf_val];
1431 switch (code)
1433 default:
1434 bfd_set_error (bfd_error_bad_value);
1435 return NULL;
1437 case BFD_RELOC_CTOR:
1438 /* We need to handle BFD_RELOC_CTOR specially.
1439 Select the right relocation (R_MIPS_32 or R_MIPS_64) based on the
1440 size of addresses on this architecture. */
1441 if (bfd_arch_bits_per_address (abfd) == 32)
1442 return &howto_table[(int) R_MIPS_32];
1443 else
1444 return &elf_mips_ctor64_howto;
1446 case BFD_RELOC_MIPS16_JMP:
1447 return &elf_mips16_jump_howto;
1448 case BFD_RELOC_MIPS16_GPREL:
1449 return &elf_mips16_gprel_howto;
1450 case BFD_RELOC_VTABLE_INHERIT:
1451 return &elf_mips_gnu_vtinherit_howto;
1452 case BFD_RELOC_VTABLE_ENTRY:
1453 return &elf_mips_gnu_vtentry_howto;
1454 case BFD_RELOC_PCREL_HI16_S:
1455 return &elf_mips_gnu_rel_hi16;
1456 case BFD_RELOC_PCREL_LO16:
1457 return &elf_mips_gnu_rel_lo16;
1458 case BFD_RELOC_16_PCREL_S2:
1459 return &elf_mips_gnu_rel16_s2;
1460 case BFD_RELOC_64_PCREL:
1461 return &elf_mips_gnu_pcrel64;
1462 case BFD_RELOC_32_PCREL:
1463 return &elf_mips_gnu_pcrel32;
1467 /* Given a MIPS Elf32_Internal_Rel, fill in an arelent structure. */
1469 static reloc_howto_type *
1470 mips_elf32_rtype_to_howto (r_type, rela_p)
1471 unsigned int r_type;
1472 boolean rela_p ATTRIBUTE_UNUSED;
1474 switch (r_type)
1476 case R_MIPS16_26:
1477 return &elf_mips16_jump_howto;
1478 case R_MIPS16_GPREL:
1479 return &elf_mips16_gprel_howto;
1480 case R_MIPS_GNU_VTINHERIT:
1481 return &elf_mips_gnu_vtinherit_howto;
1482 case R_MIPS_GNU_VTENTRY:
1483 return &elf_mips_gnu_vtentry_howto;
1484 case R_MIPS_GNU_REL_HI16:
1485 return &elf_mips_gnu_rel_hi16;
1486 case R_MIPS_GNU_REL_LO16:
1487 return &elf_mips_gnu_rel_lo16;
1488 case R_MIPS_GNU_REL16_S2:
1489 return &elf_mips_gnu_rel16_s2;
1490 case R_MIPS_PC64:
1491 return &elf_mips_gnu_pcrel64;
1492 case R_MIPS_PC32:
1493 return &elf_mips_gnu_pcrel32;
1494 default:
1495 BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
1496 return &elf_mips_howto_table_rel[r_type];
1500 /* Given a MIPS Elf32_Internal_Rel, fill in an arelent structure. */
1502 static void
1503 mips_info_to_howto_rel (abfd, cache_ptr, dst)
1504 bfd *abfd;
1505 arelent *cache_ptr;
1506 Elf32_Internal_Rel *dst;
1508 unsigned int r_type;
1510 r_type = ELF32_R_TYPE (dst->r_info);
1511 cache_ptr->howto = mips_elf32_rtype_to_howto (r_type, false);
1513 /* The addend for a GPREL16 or LITERAL relocation comes from the GP
1514 value for the object file. We get the addend now, rather than
1515 when we do the relocation, because the symbol manipulations done
1516 by the linker may cause us to lose track of the input BFD. */
1517 if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
1518 && (r_type == (unsigned int) R_MIPS_GPREL16
1519 || r_type == (unsigned int) R_MIPS_LITERAL))
1520 cache_ptr->addend = elf_gp (abfd);
1523 /* Given a MIPS Elf32_Internal_Rela, fill in an arelent structure. */
1525 static void
1526 mips_info_to_howto_rela (abfd, cache_ptr, dst)
1527 bfd *abfd;
1528 arelent *cache_ptr;
1529 Elf32_Internal_Rela *dst;
1531 /* Since an Elf32_Internal_Rel is an initial prefix of an
1532 Elf32_Internal_Rela, we can just use mips_info_to_howto_rel
1533 above. */
1534 mips_info_to_howto_rel (abfd, cache_ptr, (Elf32_Internal_Rel *) dst);
1536 /* If we ever need to do any extra processing with dst->r_addend
1537 (the field omitted in an Elf32_Internal_Rel) we can do it here. */
1540 /* Determine whether a symbol is global for the purposes of splitting
1541 the symbol table into global symbols and local symbols. At least
1542 on Irix 5, this split must be between section symbols and all other
1543 symbols. On most ELF targets the split is between static symbols
1544 and externally visible symbols. */
1546 static boolean
1547 mips_elf_sym_is_global (abfd, sym)
1548 bfd *abfd ATTRIBUTE_UNUSED;
1549 asymbol *sym;
1551 if (SGI_COMPAT (abfd))
1552 return (sym->flags & BSF_SECTION_SYM) == 0;
1553 else
1554 return ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
1555 || bfd_is_und_section (bfd_get_section (sym))
1556 || bfd_is_com_section (bfd_get_section (sym)));
1559 /* Set the right machine number for a MIPS ELF file. */
1561 static boolean
1562 mips_elf32_object_p (abfd)
1563 bfd *abfd;
1565 unsigned long mach;
1567 /* Irix 5 and 6 are broken. Object file symbol tables are not always
1568 sorted correctly such that local symbols precede global symbols,
1569 and the sh_info field in the symbol table is not always right. */
1570 if (SGI_COMPAT (abfd))
1571 elf_bad_symtab (abfd) = true;
1573 if (ABI_N32_P (abfd))
1574 return false;
1576 mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
1577 bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
1579 return true;
1582 /* MIPS ELF local labels start with '$', not 'L'. */
1584 static boolean
1585 mips_elf_is_local_label_name (abfd, name)
1586 bfd *abfd;
1587 const char *name;
1589 if (name[0] == '$')
1590 return true;
1592 /* On Irix 6, the labels go back to starting with '.', so we accept
1593 the generic ELF local label syntax as well. */
1594 return _bfd_elf_is_local_label_name (abfd, name);
1597 /* Support for core dump NOTE sections. */
1598 static boolean
1599 elf32_mips_grok_prstatus (abfd, note)
1600 bfd *abfd;
1601 Elf_Internal_Note *note;
1603 int offset;
1604 unsigned int raw_size;
1606 switch (note->descsz)
1608 default:
1609 return false;
1611 case 256: /* Linux/MIPS */
1612 /* pr_cursig */
1613 elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
1615 /* pr_pid */
1616 elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
1618 /* pr_reg */
1619 offset = 72;
1620 raw_size = 180;
1622 break;
1625 /* Make a ".reg/999" section. */
1626 return _bfd_elfcore_make_pseudosection (abfd, ".reg",
1627 raw_size, note->descpos + offset);
1630 static boolean
1631 elf32_mips_grok_psinfo (abfd, note)
1632 bfd *abfd;
1633 Elf_Internal_Note *note;
1635 switch (note->descsz)
1637 default:
1638 return false;
1640 case 128: /* Linux/MIPS elf_prpsinfo */
1641 elf_tdata (abfd)->core_program
1642 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
1643 elf_tdata (abfd)->core_command
1644 = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
1647 /* Note that for some reason, a spurious space is tacked
1648 onto the end of the args in some (at least one anyway)
1649 implementations, so strip it off if it exists. */
1652 char *command = elf_tdata (abfd)->core_command;
1653 int n = strlen (command);
1655 if (0 < n && command[n - 1] == ' ')
1656 command[n - 1] = '\0';
1659 return true;
1662 /* Depending on the target vector we generate some version of Irix
1663 executables or "normal" MIPS ELF ABI executables. */
1664 static irix_compat_t
1665 elf32_mips_irix_compat (abfd)
1666 bfd *abfd;
1668 if ((abfd->xvec == &bfd_elf32_bigmips_vec)
1669 || (abfd->xvec == &bfd_elf32_littlemips_vec))
1670 return ict_irix5;
1671 else
1672 return ict_none;
1675 /* Given a data section and an in-memory embedded reloc section, store
1676 relocation information into the embedded reloc section which can be
1677 used at runtime to relocate the data section. This is called by the
1678 linker when the --embedded-relocs switch is used. This is called
1679 after the add_symbols entry point has been called for all the
1680 objects, and before the final_link entry point is called. */
1682 boolean
1683 bfd_mips_elf32_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
1684 bfd *abfd;
1685 struct bfd_link_info *info;
1686 asection *datasec;
1687 asection *relsec;
1688 char **errmsg;
1690 Elf_Internal_Shdr *symtab_hdr;
1691 Elf_Internal_Sym *isymbuf = NULL;
1692 Elf_Internal_Rela *internal_relocs = NULL;
1693 Elf_Internal_Rela *irel, *irelend;
1694 bfd_byte *p;
1696 BFD_ASSERT (! info->relocateable);
1698 *errmsg = NULL;
1700 if (datasec->reloc_count == 0)
1701 return true;
1703 /* Read this BFD's symbols if we haven't done so already, or get the cached
1704 copy if it exists. */
1705 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
1706 if (symtab_hdr->sh_info != 0)
1708 isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
1709 if (isymbuf == NULL)
1710 isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
1711 symtab_hdr->sh_info, 0,
1712 NULL, NULL, NULL);
1713 if (isymbuf == NULL)
1714 goto error_return;
1717 /* Get a copy of the native relocations. */
1718 internal_relocs = (_bfd_elf32_link_read_relocs
1719 (abfd, datasec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
1720 info->keep_memory));
1721 if (internal_relocs == NULL)
1722 goto error_return;
1724 relsec->contents = (bfd_byte *) bfd_alloc (abfd, datasec->reloc_count * 12);
1725 if (relsec->contents == NULL)
1726 goto error_return;
1728 p = relsec->contents;
1730 irelend = internal_relocs + datasec->reloc_count;
1732 for (irel = internal_relocs; irel < irelend; irel++, p += 12)
1734 asection *targetsec;
1736 /* We are going to write a four byte longword into the runtime
1737 reloc section. The longword will be the address in the data
1738 section which must be relocated. It is followed by the name
1739 of the target section NUL-padded or truncated to 8
1740 characters. */
1742 /* We can only relocate absolute longword relocs at run time. */
1743 if ((ELF32_R_TYPE (irel->r_info) != (int) R_MIPS_32) &&
1744 (ELF32_R_TYPE (irel->r_info) != (int) R_MIPS_64))
1746 *errmsg = _("unsupported reloc type");
1747 bfd_set_error (bfd_error_bad_value);
1748 goto error_return;
1750 /* Get the target section referred to by the reloc. */
1751 if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
1753 Elf_Internal_Sym *isym;
1755 /* A local symbol. */
1756 isym = isymbuf + ELF32_R_SYM (irel->r_info);
1757 targetsec = bfd_section_from_elf_index (abfd, isym->st_shndx);
1759 else
1761 unsigned long indx;
1762 struct elf_link_hash_entry *h;
1764 /* An external symbol. */
1765 indx = ELF32_R_SYM (irel->r_info);
1766 h = elf_sym_hashes (abfd)[indx];
1767 targetsec = NULL;
1769 For some reason, in certain programs, the symbol will
1770 not be in the hash table. It seems to happen when you
1771 declare a static table of pointers to const external structures.
1772 In this case, the relocs are relative to data, not
1773 text, so just treating it like an undefined link
1774 should be sufficient. */
1775 BFD_ASSERT(h != NULL);
1776 if (h->root.type == bfd_link_hash_defined
1777 || h->root.type == bfd_link_hash_defweak)
1778 targetsec = h->root.u.def.section;
1783 Set the low bit of the relocation offset if it's a MIPS64 reloc.
1784 Relocations will always be on (at least) 32-bit boundaries. */
1786 bfd_put_32 (abfd, ((irel->r_offset + datasec->output_offset) +
1787 ((ELF32_R_TYPE (irel->r_info) == (int) R_MIPS_64) ? 1 : 0)),
1789 memset (p + 4, 0, 8);
1790 if (targetsec != NULL)
1791 strncpy (p + 4, targetsec->output_section->name, 8);
1794 if (internal_relocs != NULL
1795 && elf_section_data (datasec)->relocs != internal_relocs)
1796 free (internal_relocs);
1797 if (isymbuf != NULL
1798 && symtab_hdr->contents != (unsigned char *) isymbuf)
1799 free (isymbuf);
1800 return true;
1802 error_return:
1803 if (internal_relocs != NULL
1804 && elf_section_data (datasec)->relocs != internal_relocs)
1805 free (internal_relocs);
1806 if (isymbuf != NULL
1807 && symtab_hdr->contents != (unsigned char *) isymbuf)
1808 free (isymbuf);
1809 return false;
1812 /* ECOFF swapping routines. These are used when dealing with the
1813 .mdebug section, which is in the ECOFF debugging format. */
1814 static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
1815 /* Symbol table magic number. */
1816 magicSym,
1817 /* Alignment of debugging information. E.g., 4. */
1819 /* Sizes of external symbolic information. */
1820 sizeof (struct hdr_ext),
1821 sizeof (struct dnr_ext),
1822 sizeof (struct pdr_ext),
1823 sizeof (struct sym_ext),
1824 sizeof (struct opt_ext),
1825 sizeof (struct fdr_ext),
1826 sizeof (struct rfd_ext),
1827 sizeof (struct ext_ext),
1828 /* Functions to swap in external symbolic data. */
1829 ecoff_swap_hdr_in,
1830 ecoff_swap_dnr_in,
1831 ecoff_swap_pdr_in,
1832 ecoff_swap_sym_in,
1833 ecoff_swap_opt_in,
1834 ecoff_swap_fdr_in,
1835 ecoff_swap_rfd_in,
1836 ecoff_swap_ext_in,
1837 _bfd_ecoff_swap_tir_in,
1838 _bfd_ecoff_swap_rndx_in,
1839 /* Functions to swap out external symbolic data. */
1840 ecoff_swap_hdr_out,
1841 ecoff_swap_dnr_out,
1842 ecoff_swap_pdr_out,
1843 ecoff_swap_sym_out,
1844 ecoff_swap_opt_out,
1845 ecoff_swap_fdr_out,
1846 ecoff_swap_rfd_out,
1847 ecoff_swap_ext_out,
1848 _bfd_ecoff_swap_tir_out,
1849 _bfd_ecoff_swap_rndx_out,
1850 /* Function to read in symbolic data. */
1851 _bfd_mips_elf_read_ecoff_info
1854 #define ELF_ARCH bfd_arch_mips
1855 #define ELF_MACHINE_CODE EM_MIPS
1857 /* The SVR4 MIPS ABI says that this should be 0x10000, but Irix 5 uses
1858 a value of 0x1000, and we are compatible. */
1859 #define ELF_MAXPAGESIZE 0x1000
1861 #define elf_backend_collect true
1862 #define elf_backend_type_change_ok true
1863 #define elf_backend_can_gc_sections true
1864 #define elf_info_to_howto mips_info_to_howto_rela
1865 #define elf_info_to_howto_rel mips_info_to_howto_rel
1866 #define elf_backend_sym_is_global mips_elf_sym_is_global
1867 #define elf_backend_object_p mips_elf32_object_p
1868 #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
1869 #define elf_backend_section_processing _bfd_mips_elf_section_processing
1870 #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
1871 #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
1872 #define elf_backend_section_from_bfd_section \
1873 _bfd_mips_elf_section_from_bfd_section
1874 #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
1875 #define elf_backend_link_output_symbol_hook \
1876 _bfd_mips_elf_link_output_symbol_hook
1877 #define elf_backend_create_dynamic_sections \
1878 _bfd_mips_elf_create_dynamic_sections
1879 #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
1880 #define elf_backend_adjust_dynamic_symbol \
1881 _bfd_mips_elf_adjust_dynamic_symbol
1882 #define elf_backend_always_size_sections \
1883 _bfd_mips_elf_always_size_sections
1884 #define elf_backend_size_dynamic_sections \
1885 _bfd_mips_elf_size_dynamic_sections
1886 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
1887 #define elf_backend_finish_dynamic_symbol \
1888 _bfd_mips_elf_finish_dynamic_symbol
1889 #define elf_backend_finish_dynamic_sections \
1890 _bfd_mips_elf_finish_dynamic_sections
1891 #define elf_backend_final_write_processing \
1892 _bfd_mips_elf_final_write_processing
1893 #define elf_backend_additional_program_headers \
1894 _bfd_mips_elf_additional_program_headers
1895 #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
1896 #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
1897 #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
1898 #define elf_backend_copy_indirect_symbol \
1899 _bfd_mips_elf_copy_indirect_symbol
1900 #define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
1901 #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
1902 #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
1903 #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
1905 #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
1906 #define elf_backend_plt_header_size 0
1907 #define elf_backend_may_use_rel_p 1
1908 #define elf_backend_may_use_rela_p 0
1909 #define elf_backend_default_use_rela_p 0
1910 #define elf_backend_sign_extend_vma true
1912 #define elf_backend_discard_info _bfd_mips_elf_discard_info
1913 #define elf_backend_ignore_discarded_relocs \
1914 _bfd_mips_elf_ignore_discarded_relocs
1915 #define elf_backend_mips_irix_compat elf32_mips_irix_compat
1916 #define elf_backend_mips_rtype_to_howto mips_elf32_rtype_to_howto
1917 #define bfd_elf32_bfd_is_local_label_name \
1918 mips_elf_is_local_label_name
1919 #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
1920 #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
1921 #define bfd_elf32_bfd_get_relocated_section_contents \
1922 _bfd_elf_mips_get_relocated_section_contents
1923 #define bfd_elf32_bfd_link_hash_table_create \
1924 _bfd_mips_elf_link_hash_table_create
1925 #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
1926 #define bfd_elf32_bfd_merge_private_bfd_data \
1927 _bfd_mips_elf_merge_private_bfd_data
1928 #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
1929 #define bfd_elf32_bfd_print_private_bfd_data \
1930 _bfd_mips_elf_print_private_bfd_data
1932 /* Support for SGI-ish mips targets. */
1933 #define TARGET_LITTLE_SYM bfd_elf32_littlemips_vec
1934 #define TARGET_LITTLE_NAME "elf32-littlemips"
1935 #define TARGET_BIG_SYM bfd_elf32_bigmips_vec
1936 #define TARGET_BIG_NAME "elf32-bigmips"
1938 #include "elf32-target.h"
1940 /* Support for traditional mips targets. */
1941 #define INCLUDED_TARGET_FILE /* More a type of flag. */
1943 #undef TARGET_LITTLE_SYM
1944 #undef TARGET_LITTLE_NAME
1945 #undef TARGET_BIG_SYM
1946 #undef TARGET_BIG_NAME
1948 #define TARGET_LITTLE_SYM bfd_elf32_tradlittlemips_vec
1949 #define TARGET_LITTLE_NAME "elf32-tradlittlemips"
1950 #define TARGET_BIG_SYM bfd_elf32_tradbigmips_vec
1951 #define TARGET_BIG_NAME "elf32-tradbigmips"
1953 /* Include the target file again for this target. */
1954 #include "elf32-target.h"