*** empty log message ***
[deliverable/binutils-gdb.git] / bfd / elf32-mips.c
1 /* MIPS-specific support for 32-bit ELF
2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 2003, 2004, 2005 Free Software Foundation, Inc.
4
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>
11
12 This file is part of BFD, the Binary File Descriptor library.
13
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.
18
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.
23
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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
27
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. */
31
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"
40 #include "elf-vxworks.h"
41
42 /* Get the ECOFF swapping routines. */
43 #include "coff/sym.h"
44 #include "coff/symconst.h"
45 #include "coff/internal.h"
46 #include "coff/ecoff.h"
47 #include "coff/mips.h"
48 #define ECOFF_SIGNED_32
49 #include "ecoffswap.h"
50
51 static bfd_reloc_status_type gprel32_with_gp
52 (bfd *, asymbol *, arelent *, asection *, bfd_boolean, void *, bfd_vma);
53 static bfd_reloc_status_type mips_elf_gprel32_reloc
54 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
55 static bfd_reloc_status_type mips32_64bit_reloc
56 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
57 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
58 (bfd *, bfd_reloc_code_real_type);
59 static reloc_howto_type *mips_elf32_rtype_to_howto
60 (unsigned int, bfd_boolean);
61 static void mips_info_to_howto_rel
62 (bfd *, arelent *, Elf_Internal_Rela *);
63 static void mips_info_to_howto_rela
64 (bfd *, arelent *, Elf_Internal_Rela *);
65 static bfd_boolean mips_elf_sym_is_global
66 (bfd *, asymbol *);
67 static bfd_boolean mips_elf32_object_p
68 (bfd *);
69 static bfd_boolean mips_elf_is_local_label_name
70 (bfd *, const char *);
71 static bfd_reloc_status_type mips16_gprel_reloc
72 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
73 static bfd_reloc_status_type mips_elf_final_gp
74 (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *);
75 static bfd_boolean mips_elf_assign_gp
76 (bfd *, bfd_vma *);
77 static bfd_boolean elf32_mips_grok_prstatus
78 (bfd *, Elf_Internal_Note *);
79 static bfd_boolean elf32_mips_grok_psinfo
80 (bfd *, Elf_Internal_Note *);
81 static irix_compat_t elf32_mips_irix_compat
82 (bfd *);
83
84 extern const bfd_target bfd_elf32_bigmips_vec;
85 extern const bfd_target bfd_elf32_littlemips_vec;
86
87 /* Nonzero if ABFD is using the N32 ABI. */
88 #define ABI_N32_P(abfd) \
89 ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
90
91 /* Whether we are trying to be compatible with IRIX at all. */
92 #define SGI_COMPAT(abfd) \
93 (elf32_mips_irix_compat (abfd) != ict_none)
94
95 /* The number of local .got entries we reserve. */
96 #define MIPS_RESERVED_GOTNO (2)
97
98 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
99 from smaller values. Start with zero, widen, *then* decrement. */
100 #define MINUS_ONE (((bfd_vma)0) - 1)
101
102 /* The relocation table used for SHT_REL sections. */
103
104 static reloc_howto_type elf_mips_howto_table_rel[] =
105 {
106 /* No relocation. */
107 HOWTO (R_MIPS_NONE, /* type */
108 0, /* rightshift */
109 0, /* size (0 = byte, 1 = short, 2 = long) */
110 0, /* bitsize */
111 FALSE, /* pc_relative */
112 0, /* bitpos */
113 complain_overflow_dont, /* complain_on_overflow */
114 _bfd_mips_elf_generic_reloc, /* special_function */
115 "R_MIPS_NONE", /* name */
116 FALSE, /* partial_inplace */
117 0, /* src_mask */
118 0, /* dst_mask */
119 FALSE), /* pcrel_offset */
120
121 /* 16 bit relocation. */
122 HOWTO (R_MIPS_16, /* type */
123 0, /* rightshift */
124 2, /* size (0 = byte, 1 = short, 2 = long) */
125 16, /* bitsize */
126 FALSE, /* pc_relative */
127 0, /* bitpos */
128 complain_overflow_signed, /* complain_on_overflow */
129 _bfd_mips_elf_generic_reloc, /* special_function */
130 "R_MIPS_16", /* name */
131 TRUE, /* partial_inplace */
132 0x0000ffff, /* src_mask */
133 0x0000ffff, /* dst_mask */
134 FALSE), /* pcrel_offset */
135
136 /* 32 bit relocation. */
137 HOWTO (R_MIPS_32, /* type */
138 0, /* rightshift */
139 2, /* size (0 = byte, 1 = short, 2 = long) */
140 32, /* bitsize */
141 FALSE, /* pc_relative */
142 0, /* bitpos */
143 complain_overflow_dont, /* complain_on_overflow */
144 _bfd_mips_elf_generic_reloc, /* special_function */
145 "R_MIPS_32", /* name */
146 TRUE, /* partial_inplace */
147 0xffffffff, /* src_mask */
148 0xffffffff, /* dst_mask */
149 FALSE), /* pcrel_offset */
150
151 /* 32 bit symbol relative relocation. */
152 HOWTO (R_MIPS_REL32, /* type */
153 0, /* rightshift */
154 2, /* size (0 = byte, 1 = short, 2 = long) */
155 32, /* bitsize */
156 FALSE, /* pc_relative */
157 0, /* bitpos */
158 complain_overflow_dont, /* complain_on_overflow */
159 _bfd_mips_elf_generic_reloc, /* special_function */
160 "R_MIPS_REL32", /* name */
161 TRUE, /* partial_inplace */
162 0xffffffff, /* src_mask */
163 0xffffffff, /* dst_mask */
164 FALSE), /* pcrel_offset */
165
166 /* 26 bit jump address. */
167 HOWTO (R_MIPS_26, /* type */
168 2, /* rightshift */
169 2, /* size (0 = byte, 1 = short, 2 = long) */
170 26, /* bitsize */
171 FALSE, /* pc_relative */
172 0, /* bitpos */
173 complain_overflow_dont, /* complain_on_overflow */
174 /* This needs complex overflow
175 detection, because the upper four
176 bits must match the PC + 4. */
177 _bfd_mips_elf_generic_reloc, /* special_function */
178 "R_MIPS_26", /* name */
179 TRUE, /* partial_inplace */
180 0x03ffffff, /* src_mask */
181 0x03ffffff, /* dst_mask */
182 FALSE), /* pcrel_offset */
183
184 /* High 16 bits of symbol value. */
185 HOWTO (R_MIPS_HI16, /* type */
186 16, /* rightshift */
187 2, /* size (0 = byte, 1 = short, 2 = long) */
188 16, /* bitsize */
189 FALSE, /* pc_relative */
190 0, /* bitpos */
191 complain_overflow_dont, /* complain_on_overflow */
192 _bfd_mips_elf_hi16_reloc, /* special_function */
193 "R_MIPS_HI16", /* name */
194 TRUE, /* partial_inplace */
195 0x0000ffff, /* src_mask */
196 0x0000ffff, /* dst_mask */
197 FALSE), /* pcrel_offset */
198
199 /* Low 16 bits of symbol value. */
200 HOWTO (R_MIPS_LO16, /* type */
201 0, /* rightshift */
202 2, /* size (0 = byte, 1 = short, 2 = long) */
203 16, /* bitsize */
204 FALSE, /* pc_relative */
205 0, /* bitpos */
206 complain_overflow_dont, /* complain_on_overflow */
207 _bfd_mips_elf_lo16_reloc, /* special_function */
208 "R_MIPS_LO16", /* name */
209 TRUE, /* partial_inplace */
210 0x0000ffff, /* src_mask */
211 0x0000ffff, /* dst_mask */
212 FALSE), /* pcrel_offset */
213
214 /* GP relative reference. */
215 HOWTO (R_MIPS_GPREL16, /* type */
216 0, /* rightshift */
217 2, /* size (0 = byte, 1 = short, 2 = long) */
218 16, /* bitsize */
219 FALSE, /* pc_relative */
220 0, /* bitpos */
221 complain_overflow_signed, /* complain_on_overflow */
222 _bfd_mips_elf32_gprel16_reloc, /* special_function */
223 "R_MIPS_GPREL16", /* name */
224 TRUE, /* partial_inplace */
225 0x0000ffff, /* src_mask */
226 0x0000ffff, /* dst_mask */
227 FALSE), /* pcrel_offset */
228
229 /* Reference to literal section. */
230 HOWTO (R_MIPS_LITERAL, /* type */
231 0, /* rightshift */
232 2, /* size (0 = byte, 1 = short, 2 = long) */
233 16, /* bitsize */
234 FALSE, /* pc_relative */
235 0, /* bitpos */
236 complain_overflow_signed, /* complain_on_overflow */
237 _bfd_mips_elf32_gprel16_reloc, /* special_function */
238 "R_MIPS_LITERAL", /* name */
239 TRUE, /* partial_inplace */
240 0x0000ffff, /* src_mask */
241 0x0000ffff, /* dst_mask */
242 FALSE), /* pcrel_offset */
243
244 /* Reference to global offset table. */
245 HOWTO (R_MIPS_GOT16, /* type */
246 0, /* rightshift */
247 2, /* size (0 = byte, 1 = short, 2 = long) */
248 16, /* bitsize */
249 FALSE, /* pc_relative */
250 0, /* bitpos */
251 complain_overflow_signed, /* complain_on_overflow */
252 _bfd_mips_elf_got16_reloc, /* special_function */
253 "R_MIPS_GOT16", /* name */
254 TRUE, /* partial_inplace */
255 0x0000ffff, /* src_mask */
256 0x0000ffff, /* dst_mask */
257 FALSE), /* pcrel_offset */
258
259 /* 16 bit PC relative reference. Note that the ABI document has a typo
260 and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
261 We do the right thing here. */
262 HOWTO (R_MIPS_PC16, /* type */
263 2, /* 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_mips_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 */
275
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_mips_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 */
290
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 */
305
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),
311
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_mips_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 */
326
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_mips_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 */
343
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 */
358
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_mips_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 */
373
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_mips_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 */
388
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_mips_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 */
403
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_mips_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 */
418
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_mips_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 */
433
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_mips_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 */
448
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),
453
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_mips_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 */
468
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_mips_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 */
483
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_mips_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 */
498
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_mips_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 */
513
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_mips_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 */
528
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),
533
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_mips_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 */
549
550 /* TLS GD/LD dynamic relocations. */
551 HOWTO (R_MIPS_TLS_DTPMOD32, /* type */
552 0, /* rightshift */
553 2, /* size (0 = byte, 1 = short, 2 = long) */
554 32, /* bitsize */
555 FALSE, /* pc_relative */
556 0, /* bitpos */
557 complain_overflow_dont, /* complain_on_overflow */
558 _bfd_mips_elf_generic_reloc, /* special_function */
559 "R_MIPS_TLS_DTPMOD32", /* name */
560 TRUE, /* partial_inplace */
561 0xffffffff, /* src_mask */
562 0xffffffff, /* dst_mask */
563 FALSE), /* pcrel_offset */
564
565 HOWTO (R_MIPS_TLS_DTPREL32, /* type */
566 0, /* rightshift */
567 2, /* size (0 = byte, 1 = short, 2 = long) */
568 32, /* bitsize */
569 FALSE, /* pc_relative */
570 0, /* bitpos */
571 complain_overflow_dont, /* complain_on_overflow */
572 _bfd_mips_elf_generic_reloc, /* special_function */
573 "R_MIPS_TLS_DTPREL32", /* name */
574 TRUE, /* partial_inplace */
575 0xffffffff, /* src_mask */
576 0xffffffff, /* dst_mask */
577 FALSE), /* pcrel_offset */
578
579 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
580 EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
581
582 /* TLS general dynamic variable reference. */
583 HOWTO (R_MIPS_TLS_GD, /* type */
584 0, /* rightshift */
585 2, /* size (0 = byte, 1 = short, 2 = long) */
586 16, /* bitsize */
587 FALSE, /* pc_relative */
588 0, /* bitpos */
589 complain_overflow_signed, /* complain_on_overflow */
590 _bfd_mips_elf_generic_reloc, /* special_function */
591 "R_MIPS_TLS_GD", /* name */
592 TRUE, /* partial_inplace */
593 0x0000ffff, /* src_mask */
594 0x0000ffff, /* dst_mask */
595 FALSE), /* pcrel_offset */
596
597 /* TLS local dynamic variable reference. */
598 HOWTO (R_MIPS_TLS_LDM, /* type */
599 0, /* rightshift */
600 2, /* size (0 = byte, 1 = short, 2 = long) */
601 16, /* bitsize */
602 FALSE, /* pc_relative */
603 0, /* bitpos */
604 complain_overflow_signed, /* complain_on_overflow */
605 _bfd_mips_elf_generic_reloc, /* special_function */
606 "R_MIPS_TLS_LDM", /* name */
607 TRUE, /* partial_inplace */
608 0x0000ffff, /* src_mask */
609 0x0000ffff, /* dst_mask */
610 FALSE), /* pcrel_offset */
611
612 /* TLS local dynamic offset. */
613 HOWTO (R_MIPS_TLS_DTPREL_HI16, /* type */
614 0, /* rightshift */
615 2, /* size (0 = byte, 1 = short, 2 = long) */
616 16, /* bitsize */
617 FALSE, /* pc_relative */
618 0, /* bitpos */
619 complain_overflow_signed, /* complain_on_overflow */
620 _bfd_mips_elf_generic_reloc, /* special_function */
621 "R_MIPS_TLS_DTPREL_HI16", /* name */
622 TRUE, /* partial_inplace */
623 0x0000ffff, /* src_mask */
624 0x0000ffff, /* dst_mask */
625 FALSE), /* pcrel_offset */
626
627 /* TLS local dynamic offset. */
628 HOWTO (R_MIPS_TLS_DTPREL_LO16, /* type */
629 0, /* rightshift */
630 2, /* size (0 = byte, 1 = short, 2 = long) */
631 16, /* bitsize */
632 FALSE, /* pc_relative */
633 0, /* bitpos */
634 complain_overflow_signed, /* complain_on_overflow */
635 _bfd_mips_elf_generic_reloc, /* special_function */
636 "R_MIPS_TLS_DTPREL_LO16", /* name */
637 TRUE, /* partial_inplace */
638 0x0000ffff, /* src_mask */
639 0x0000ffff, /* dst_mask */
640 FALSE), /* pcrel_offset */
641
642 /* TLS thread pointer offset. */
643 HOWTO (R_MIPS_TLS_GOTTPREL, /* type */
644 0, /* rightshift */
645 2, /* size (0 = byte, 1 = short, 2 = long) */
646 16, /* bitsize */
647 FALSE, /* pc_relative */
648 0, /* bitpos */
649 complain_overflow_signed, /* complain_on_overflow */
650 _bfd_mips_elf_generic_reloc, /* special_function */
651 "R_MIPS_TLS_GOTTPREL", /* name */
652 TRUE, /* partial_inplace */
653 0x0000ffff, /* src_mask */
654 0x0000ffff, /* dst_mask */
655 FALSE), /* pcrel_offset */
656
657 /* TLS IE dynamic relocations. */
658 HOWTO (R_MIPS_TLS_TPREL32, /* type */
659 0, /* rightshift */
660 2, /* size (0 = byte, 1 = short, 2 = long) */
661 32, /* bitsize */
662 FALSE, /* pc_relative */
663 0, /* bitpos */
664 complain_overflow_dont, /* complain_on_overflow */
665 _bfd_mips_elf_generic_reloc, /* special_function */
666 "R_MIPS_TLS_TPREL32", /* name */
667 TRUE, /* partial_inplace */
668 0xffffffff, /* src_mask */
669 0xffffffff, /* dst_mask */
670 FALSE), /* pcrel_offset */
671
672 EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
673
674 /* TLS thread pointer offset. */
675 HOWTO (R_MIPS_TLS_TPREL_HI16, /* type */
676 0, /* rightshift */
677 2, /* size (0 = byte, 1 = short, 2 = long) */
678 16, /* bitsize */
679 FALSE, /* pc_relative */
680 0, /* bitpos */
681 complain_overflow_signed, /* complain_on_overflow */
682 _bfd_mips_elf_generic_reloc, /* special_function */
683 "R_MIPS_TLS_TPREL_HI16", /* name */
684 TRUE, /* partial_inplace */
685 0x0000ffff, /* src_mask */
686 0x0000ffff, /* dst_mask */
687 FALSE), /* pcrel_offset */
688
689 /* TLS thread pointer offset. */
690 HOWTO (R_MIPS_TLS_TPREL_LO16, /* type */
691 0, /* rightshift */
692 2, /* size (0 = byte, 1 = short, 2 = long) */
693 16, /* bitsize */
694 FALSE, /* pc_relative */
695 0, /* bitpos */
696 complain_overflow_signed, /* complain_on_overflow */
697 _bfd_mips_elf_generic_reloc, /* special_function */
698 "R_MIPS_TLS_TPREL_LO16", /* name */
699 TRUE, /* partial_inplace */
700 0x0000ffff, /* src_mask */
701 0x0000ffff, /* dst_mask */
702 FALSE), /* pcrel_offset */
703 };
704
705 /* The reloc used for BFD_RELOC_CTOR when doing a 64 bit link. This
706 is a hack to make the linker think that we need 64 bit values. */
707 static reloc_howto_type elf_mips_ctor64_howto =
708 HOWTO (R_MIPS_64, /* type */
709 0, /* rightshift */
710 4, /* size (0 = byte, 1 = short, 2 = long) */
711 32, /* bitsize */
712 FALSE, /* pc_relative */
713 0, /* bitpos */
714 complain_overflow_signed, /* complain_on_overflow */
715 mips32_64bit_reloc, /* special_function */
716 "R_MIPS_64", /* name */
717 TRUE, /* partial_inplace */
718 0xffffffff, /* src_mask */
719 0xffffffff, /* dst_mask */
720 FALSE); /* pcrel_offset */
721
722 static reloc_howto_type elf_mips16_howto_table_rel[] =
723 {
724 /* The reloc used for the mips16 jump instruction. */
725 HOWTO (R_MIPS16_26, /* type */
726 2, /* rightshift */
727 2, /* size (0 = byte, 1 = short, 2 = long) */
728 26, /* bitsize */
729 FALSE, /* pc_relative */
730 0, /* bitpos */
731 complain_overflow_dont, /* complain_on_overflow */
732 /* This needs complex overflow
733 detection, because the upper four
734 bits must match the PC. */
735 _bfd_mips_elf_generic_reloc, /* special_function */
736 "R_MIPS16_26", /* name */
737 TRUE, /* partial_inplace */
738 0x3ffffff, /* src_mask */
739 0x3ffffff, /* dst_mask */
740 FALSE), /* pcrel_offset */
741
742 /* The reloc used for the mips16 gprel instruction. */
743 HOWTO (R_MIPS16_GPREL, /* type */
744 0, /* rightshift */
745 2, /* size (0 = byte, 1 = short, 2 = long) */
746 16, /* bitsize */
747 FALSE, /* pc_relative */
748 0, /* bitpos */
749 complain_overflow_signed, /* complain_on_overflow */
750 mips16_gprel_reloc, /* special_function */
751 "R_MIPS16_GPREL", /* name */
752 TRUE, /* partial_inplace */
753 0x0000ffff, /* src_mask */
754 0x0000ffff, /* dst_mask */
755 FALSE), /* pcrel_offset */
756
757 /* A placeholder for MIPS16 reference to global offset table. */
758 EMPTY_HOWTO (R_MIPS16_GOT16),
759
760 /* A placeholder for MIPS16 16 bit call through global offset table. */
761 EMPTY_HOWTO (R_MIPS16_CALL16),
762
763 /* MIPS16 high 16 bits of symbol value. */
764 HOWTO (R_MIPS16_HI16, /* type */
765 16, /* rightshift */
766 2, /* size (0 = byte, 1 = short, 2 = long) */
767 16, /* bitsize */
768 FALSE, /* pc_relative */
769 0, /* bitpos */
770 complain_overflow_dont, /* complain_on_overflow */
771 _bfd_mips_elf_hi16_reloc, /* special_function */
772 "R_MIPS16_HI16", /* name */
773 TRUE, /* partial_inplace */
774 0x0000ffff, /* src_mask */
775 0x0000ffff, /* dst_mask */
776 FALSE), /* pcrel_offset */
777
778 /* MIPS16 low 16 bits of symbol value. */
779 HOWTO (R_MIPS16_LO16, /* type */
780 0, /* rightshift */
781 2, /* size (0 = byte, 1 = short, 2 = long) */
782 16, /* bitsize */
783 FALSE, /* pc_relative */
784 0, /* bitpos */
785 complain_overflow_dont, /* complain_on_overflow */
786 _bfd_mips_elf_lo16_reloc, /* special_function */
787 "R_MIPS16_LO16", /* name */
788 TRUE, /* partial_inplace */
789 0x0000ffff, /* src_mask */
790 0x0000ffff, /* dst_mask */
791 FALSE), /* pcrel_offset */
792 };
793
794 /* 16 bit offset for pc-relative branches. */
795 static reloc_howto_type elf_mips_gnu_rel16_s2 =
796 HOWTO (R_MIPS_GNU_REL16_S2, /* type */
797 2, /* rightshift */
798 2, /* size (0 = byte, 1 = short, 2 = long) */
799 16, /* bitsize */
800 TRUE, /* pc_relative */
801 0, /* bitpos */
802 complain_overflow_signed, /* complain_on_overflow */
803 _bfd_mips_elf_generic_reloc, /* special_function */
804 "R_MIPS_GNU_REL16_S2", /* name */
805 TRUE, /* partial_inplace */
806 0xffff, /* src_mask */
807 0xffff, /* dst_mask */
808 TRUE); /* pcrel_offset */
809
810 /* 32 bit pc-relative. This was a GNU extension used by embedded-PIC.
811 It was co-opted by mips-linux for exception-handling data. It is no
812 longer used, but should continue to be supported by the linker for
813 backward compatibility. (GCC stopped using it in May, 2004.) */
814 static reloc_howto_type elf_mips_gnu_pcrel32 =
815 HOWTO (R_MIPS_PC32, /* type */
816 0, /* rightshift */
817 2, /* size (0 = byte, 1 = short, 2 = long) */
818 32, /* bitsize */
819 TRUE, /* pc_relative */
820 0, /* bitpos */
821 complain_overflow_signed, /* complain_on_overflow */
822 _bfd_mips_elf_generic_reloc, /* special_function */
823 "R_MIPS_PC32", /* name */
824 TRUE, /* partial_inplace */
825 0xffffffff, /* src_mask */
826 0xffffffff, /* dst_mask */
827 TRUE); /* pcrel_offset */
828
829 /* GNU extension to record C++ vtable hierarchy */
830 static reloc_howto_type elf_mips_gnu_vtinherit_howto =
831 HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
832 0, /* rightshift */
833 2, /* size (0 = byte, 1 = short, 2 = long) */
834 0, /* bitsize */
835 FALSE, /* pc_relative */
836 0, /* bitpos */
837 complain_overflow_dont, /* complain_on_overflow */
838 NULL, /* special_function */
839 "R_MIPS_GNU_VTINHERIT", /* name */
840 FALSE, /* partial_inplace */
841 0, /* src_mask */
842 0, /* dst_mask */
843 FALSE); /* pcrel_offset */
844
845 /* GNU extension to record C++ vtable member usage */
846 static reloc_howto_type elf_mips_gnu_vtentry_howto =
847 HOWTO (R_MIPS_GNU_VTENTRY, /* type */
848 0, /* rightshift */
849 2, /* size (0 = byte, 1 = short, 2 = long) */
850 0, /* bitsize */
851 FALSE, /* pc_relative */
852 0, /* bitpos */
853 complain_overflow_dont, /* complain_on_overflow */
854 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
855 "R_MIPS_GNU_VTENTRY", /* name */
856 FALSE, /* partial_inplace */
857 0, /* src_mask */
858 0, /* dst_mask */
859 FALSE); /* pcrel_offset */
860
861 /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
862 dangerous relocation. */
863
864 static bfd_boolean
865 mips_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
866 {
867 unsigned int count;
868 asymbol **sym;
869 unsigned int i;
870
871 /* If we've already figured out what GP will be, just return it. */
872 *pgp = _bfd_get_gp_value (output_bfd);
873 if (*pgp)
874 return TRUE;
875
876 count = bfd_get_symcount (output_bfd);
877 sym = bfd_get_outsymbols (output_bfd);
878
879 /* The linker script will have created a symbol named `_gp' with the
880 appropriate value. */
881 if (sym == NULL)
882 i = count;
883 else
884 {
885 for (i = 0; i < count; i++, sym++)
886 {
887 register const char *name;
888
889 name = bfd_asymbol_name (*sym);
890 if (*name == '_' && strcmp (name, "_gp") == 0)
891 {
892 *pgp = bfd_asymbol_value (*sym);
893 _bfd_set_gp_value (output_bfd, *pgp);
894 break;
895 }
896 }
897 }
898
899 if (i >= count)
900 {
901 /* Only get the error once. */
902 *pgp = 4;
903 _bfd_set_gp_value (output_bfd, *pgp);
904 return FALSE;
905 }
906
907 return TRUE;
908 }
909
910 /* We have to figure out the gp value, so that we can adjust the
911 symbol value correctly. We look up the symbol _gp in the output
912 BFD. If we can't find it, we're stuck. We cache it in the ELF
913 target data. We don't need to adjust the symbol value for an
914 external symbol if we are producing relocatable output. */
915
916 static bfd_reloc_status_type
917 mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
918 char **error_message, bfd_vma *pgp)
919 {
920 if (bfd_is_und_section (symbol->section)
921 && ! relocatable)
922 {
923 *pgp = 0;
924 return bfd_reloc_undefined;
925 }
926
927 *pgp = _bfd_get_gp_value (output_bfd);
928 if (*pgp == 0
929 && (! relocatable
930 || (symbol->flags & BSF_SECTION_SYM) != 0))
931 {
932 if (relocatable)
933 {
934 /* Make up a value. */
935 *pgp = symbol->section->output_section->vma + 0x4000;
936 _bfd_set_gp_value (output_bfd, *pgp);
937 }
938 else if (!mips_elf_assign_gp (output_bfd, pgp))
939 {
940 *error_message =
941 (char *) _("GP relative relocation when _gp not defined");
942 return bfd_reloc_dangerous;
943 }
944 }
945
946 return bfd_reloc_ok;
947 }
948
949 /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
950 become the offset from the gp register. This function also handles
951 R_MIPS_LITERAL relocations, although those can be handled more
952 cleverly because the entries in the .lit8 and .lit4 sections can be
953 merged. */
954
955 bfd_reloc_status_type
956 _bfd_mips_elf32_gprel16_reloc (bfd *abfd, arelent *reloc_entry,
957 asymbol *symbol, void *data,
958 asection *input_section, bfd *output_bfd,
959 char **error_message)
960 {
961 bfd_boolean relocatable;
962 bfd_reloc_status_type ret;
963 bfd_vma gp;
964
965 /* R_MIPS_LITERAL relocations are defined for local symbols only. */
966 if (reloc_entry->howto->type == R_MIPS_LITERAL
967 && output_bfd != NULL
968 && (symbol->flags & BSF_SECTION_SYM) == 0
969 && (symbol->flags & BSF_LOCAL) != 0)
970 {
971 *error_message = (char *)
972 _("literal relocation occurs for an external symbol");
973 return bfd_reloc_outofrange;
974 }
975
976 if (output_bfd != NULL)
977 relocatable = TRUE;
978 else
979 {
980 relocatable = FALSE;
981 output_bfd = symbol->section->output_section->owner;
982 }
983
984 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
985 &gp);
986 if (ret != bfd_reloc_ok)
987 return ret;
988
989 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
990 input_section, relocatable,
991 data, gp);
992 }
993
994 /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
995 become the offset from the gp register. */
996
997 static bfd_reloc_status_type
998 mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
999 void *data, asection *input_section, bfd *output_bfd,
1000 char **error_message)
1001 {
1002 bfd_boolean relocatable;
1003 bfd_reloc_status_type ret;
1004 bfd_vma gp;
1005
1006 /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
1007 if (output_bfd != NULL
1008 && (symbol->flags & BSF_SECTION_SYM) == 0
1009 && (symbol->flags & BSF_LOCAL) != 0)
1010 {
1011 *error_message = (char *)
1012 _("32bits gp relative relocation occurs for an external symbol");
1013 return bfd_reloc_outofrange;
1014 }
1015
1016 if (output_bfd != NULL)
1017 relocatable = TRUE;
1018 else
1019 {
1020 relocatable = FALSE;
1021 output_bfd = symbol->section->output_section->owner;
1022 }
1023
1024 ret = mips_elf_final_gp (output_bfd, symbol, relocatable,
1025 error_message, &gp);
1026 if (ret != bfd_reloc_ok)
1027 return ret;
1028
1029 return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
1030 relocatable, data, gp);
1031 }
1032
1033 static bfd_reloc_status_type
1034 gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
1035 asection *input_section, bfd_boolean relocatable,
1036 void *data, bfd_vma gp)
1037 {
1038 bfd_vma relocation;
1039 bfd_vma val;
1040
1041 if (bfd_is_com_section (symbol->section))
1042 relocation = 0;
1043 else
1044 relocation = symbol->value;
1045
1046 relocation += symbol->section->output_section->vma;
1047 relocation += symbol->section->output_offset;
1048
1049 if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
1050 return bfd_reloc_outofrange;
1051
1052 /* Set val to the offset into the section or symbol. */
1053 val = reloc_entry->addend;
1054
1055 if (reloc_entry->howto->partial_inplace)
1056 val += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
1057
1058 /* Adjust val for the final section location and GP value. If we
1059 are producing relocatable output, we don't want to do this for
1060 an external symbol. */
1061 if (! relocatable
1062 || (symbol->flags & BSF_SECTION_SYM) != 0)
1063 val += relocation - gp;
1064
1065 if (reloc_entry->howto->partial_inplace)
1066 bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
1067 else
1068 reloc_entry->addend = val;
1069
1070 if (relocatable)
1071 reloc_entry->address += input_section->output_offset;
1072
1073 return bfd_reloc_ok;
1074 }
1075
1076 /* Handle a 64 bit reloc in a 32 bit MIPS ELF file. These are
1077 generated when addresses are 64 bits. The upper 32 bits are a simple
1078 sign extension. */
1079
1080 static bfd_reloc_status_type
1081 mips32_64bit_reloc (bfd *abfd, arelent *reloc_entry,
1082 asymbol *symbol ATTRIBUTE_UNUSED,
1083 void *data, asection *input_section,
1084 bfd *output_bfd, char **error_message)
1085 {
1086 bfd_reloc_status_type r;
1087 arelent reloc32;
1088 unsigned long val;
1089 bfd_size_type addr;
1090
1091 /* Do a normal 32 bit relocation on the lower 32 bits. */
1092 reloc32 = *reloc_entry;
1093 if (bfd_big_endian (abfd))
1094 reloc32.address += 4;
1095 reloc32.howto = &elf_mips_howto_table_rel[R_MIPS_32];
1096 r = bfd_perform_relocation (abfd, &reloc32, data, input_section,
1097 output_bfd, error_message);
1098
1099 /* Sign extend into the upper 32 bits. */
1100 val = bfd_get_32 (abfd, (bfd_byte *) data + reloc32.address);
1101 if ((val & 0x80000000) != 0)
1102 val = 0xffffffff;
1103 else
1104 val = 0;
1105 addr = reloc_entry->address;
1106 if (bfd_little_endian (abfd))
1107 addr += 4;
1108 bfd_put_32 (abfd, val, (bfd_byte *) data + addr);
1109
1110 return r;
1111 }
1112
1113 /* Handle a mips16 GP relative reloc. */
1114
1115 static bfd_reloc_status_type
1116 mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
1117 void *data, asection *input_section, bfd *output_bfd,
1118 char **error_message)
1119 {
1120 bfd_boolean relocatable;
1121 bfd_reloc_status_type ret;
1122 bfd_byte *location;
1123 bfd_vma gp;
1124
1125 /* If we're relocating, and this is an external symbol, we don't want
1126 to change anything. */
1127 if (output_bfd != NULL
1128 && (symbol->flags & BSF_SECTION_SYM) == 0
1129 && (symbol->flags & BSF_LOCAL) != 0)
1130 {
1131 reloc_entry->address += input_section->output_offset;
1132 return bfd_reloc_ok;
1133 }
1134
1135 if (output_bfd != NULL)
1136 relocatable = TRUE;
1137 else
1138 {
1139 relocatable = FALSE;
1140 output_bfd = symbol->section->output_section->owner;
1141 }
1142
1143 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
1144 &gp);
1145 if (ret != bfd_reloc_ok)
1146 return ret;
1147
1148 location = (bfd_byte *) data + reloc_entry->address;
1149 _bfd_mips16_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE,
1150 location);
1151 ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1152 input_section, relocatable,
1153 data, gp);
1154 _bfd_mips16_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
1155 location);
1156
1157 return ret;
1158 }
1159
1160 /* A mapping from BFD reloc types to MIPS ELF reloc types. */
1161
1162 struct elf_reloc_map {
1163 bfd_reloc_code_real_type bfd_val;
1164 enum elf_mips_reloc_type elf_val;
1165 };
1166
1167 static const struct elf_reloc_map mips_reloc_map[] =
1168 {
1169 { BFD_RELOC_NONE, R_MIPS_NONE },
1170 { BFD_RELOC_16, R_MIPS_16 },
1171 { BFD_RELOC_32, R_MIPS_32 },
1172 /* There is no BFD reloc for R_MIPS_REL32. */
1173 { BFD_RELOC_64, R_MIPS_64 },
1174 { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
1175 { BFD_RELOC_HI16_S, R_MIPS_HI16 },
1176 { BFD_RELOC_LO16, R_MIPS_LO16 },
1177 { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
1178 { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
1179 { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
1180 { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
1181 { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
1182 { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
1183 { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
1184 { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
1185 { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
1186 { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
1187 { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
1188 { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
1189 { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
1190 { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
1191 { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
1192 { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
1193 { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
1194 { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 },
1195 { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD },
1196 { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM },
1197 { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 },
1198 { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 },
1199 { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL },
1200 { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 },
1201 { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 },
1202 { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 },
1203 { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 }
1204 };
1205
1206 static const struct elf_reloc_map mips16_reloc_map[] =
1207 {
1208 { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
1209 { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
1210 { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
1211 { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
1212 };
1213
1214 /* Given a BFD reloc type, return a howto structure. */
1215
1216 static reloc_howto_type *
1217 bfd_elf32_bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code)
1218 {
1219 unsigned int i;
1220 reloc_howto_type *howto_table = elf_mips_howto_table_rel;
1221 reloc_howto_type *howto16_table = elf_mips16_howto_table_rel;
1222
1223 for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
1224 i++)
1225 {
1226 if (mips_reloc_map[i].bfd_val == code)
1227 return &howto_table[(int) mips_reloc_map[i].elf_val];
1228 }
1229
1230 for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
1231 i++)
1232 {
1233 if (mips16_reloc_map[i].bfd_val == code)
1234 return &howto16_table[(int) mips16_reloc_map[i].elf_val];
1235 }
1236
1237 switch (code)
1238 {
1239 default:
1240 bfd_set_error (bfd_error_bad_value);
1241 return NULL;
1242
1243 case BFD_RELOC_CTOR:
1244 /* We need to handle BFD_RELOC_CTOR specially.
1245 Select the right relocation (R_MIPS_32 or R_MIPS_64) based on the
1246 size of addresses of the ABI. */
1247 if ((elf_elfheader (abfd)->e_flags & (E_MIPS_ABI_O64
1248 | E_MIPS_ABI_EABI64)) != 0)
1249 return &elf_mips_ctor64_howto;
1250 else
1251 return &howto_table[(int) R_MIPS_32];
1252
1253 case BFD_RELOC_VTABLE_INHERIT:
1254 return &elf_mips_gnu_vtinherit_howto;
1255 case BFD_RELOC_VTABLE_ENTRY:
1256 return &elf_mips_gnu_vtentry_howto;
1257 case BFD_RELOC_32_PCREL:
1258 return &elf_mips_gnu_pcrel32;
1259 }
1260 }
1261
1262 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
1263
1264 static reloc_howto_type *
1265 mips_elf32_rtype_to_howto (unsigned int r_type,
1266 bfd_boolean rela_p ATTRIBUTE_UNUSED)
1267 {
1268 switch (r_type)
1269 {
1270 case R_MIPS_GNU_VTINHERIT:
1271 return &elf_mips_gnu_vtinherit_howto;
1272 case R_MIPS_GNU_VTENTRY:
1273 return &elf_mips_gnu_vtentry_howto;
1274 case R_MIPS_GNU_REL16_S2:
1275 return &elf_mips_gnu_rel16_s2;
1276 case R_MIPS_PC32:
1277 return &elf_mips_gnu_pcrel32;
1278 default:
1279 if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
1280 return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
1281 BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
1282 return &elf_mips_howto_table_rel[r_type];
1283 }
1284 }
1285
1286 /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
1287
1288 static void
1289 mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
1290 {
1291 const struct elf_backend_data *bed;
1292 unsigned int r_type;
1293
1294 r_type = ELF32_R_TYPE (dst->r_info);
1295 bed = get_elf_backend_data (abfd);
1296 cache_ptr->howto = bed->elf_backend_mips_rtype_to_howto (r_type, FALSE);
1297
1298 /* The addend for a GPREL16 or LITERAL relocation comes from the GP
1299 value for the object file. We get the addend now, rather than
1300 when we do the relocation, because the symbol manipulations done
1301 by the linker may cause us to lose track of the input BFD. */
1302 if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
1303 && (r_type == (unsigned int) R_MIPS_GPREL16
1304 || r_type == (unsigned int) R_MIPS_LITERAL))
1305 cache_ptr->addend = elf_gp (abfd);
1306 }
1307
1308 /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */
1309
1310 static void
1311 mips_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
1312 {
1313 mips_info_to_howto_rel (abfd, cache_ptr, dst);
1314
1315 /* If we ever need to do any extra processing with dst->r_addend
1316 (the field omitted in an Elf_Internal_Rel) we can do it here. */
1317 }
1318 \f
1319 /* Determine whether a symbol is global for the purposes of splitting
1320 the symbol table into global symbols and local symbols. At least
1321 on Irix 5, this split must be between section symbols and all other
1322 symbols. On most ELF targets the split is between static symbols
1323 and externally visible symbols. */
1324
1325 static bfd_boolean
1326 mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
1327 {
1328 if (SGI_COMPAT (abfd))
1329 return (sym->flags & BSF_SECTION_SYM) == 0;
1330 else
1331 return ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
1332 || bfd_is_und_section (bfd_get_section (sym))
1333 || bfd_is_com_section (bfd_get_section (sym)));
1334 }
1335 \f
1336 /* Set the right machine number for a MIPS ELF file. */
1337
1338 static bfd_boolean
1339 mips_elf32_object_p (bfd *abfd)
1340 {
1341 unsigned long mach;
1342
1343 /* Irix 5 and 6 are broken. Object file symbol tables are not always
1344 sorted correctly such that local symbols precede global symbols,
1345 and the sh_info field in the symbol table is not always right. */
1346 if (SGI_COMPAT (abfd))
1347 elf_bad_symtab (abfd) = TRUE;
1348
1349 if (ABI_N32_P (abfd))
1350 return FALSE;
1351
1352 mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
1353 bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
1354
1355 return TRUE;
1356 }
1357 \f
1358 /* MIPS ELF local labels start with '$', not 'L'. */
1359
1360 static bfd_boolean
1361 mips_elf_is_local_label_name (bfd *abfd, const char *name)
1362 {
1363 if (name[0] == '$')
1364 return TRUE;
1365
1366 /* On Irix 6, the labels go back to starting with '.', so we accept
1367 the generic ELF local label syntax as well. */
1368 return _bfd_elf_is_local_label_name (abfd, name);
1369 }
1370 \f
1371 /* Support for core dump NOTE sections. */
1372 static bfd_boolean
1373 elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
1374 {
1375 int offset;
1376 unsigned int size;
1377
1378 switch (note->descsz)
1379 {
1380 default:
1381 return FALSE;
1382
1383 case 256: /* Linux/MIPS */
1384 /* pr_cursig */
1385 elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
1386
1387 /* pr_pid */
1388 elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
1389
1390 /* pr_reg */
1391 offset = 72;
1392 size = 180;
1393
1394 break;
1395 }
1396
1397 /* Make a ".reg/999" section. */
1398 return _bfd_elfcore_make_pseudosection (abfd, ".reg",
1399 size, note->descpos + offset);
1400 }
1401
1402 static bfd_boolean
1403 elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
1404 {
1405 switch (note->descsz)
1406 {
1407 default:
1408 return FALSE;
1409
1410 case 128: /* Linux/MIPS elf_prpsinfo */
1411 elf_tdata (abfd)->core_program
1412 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
1413 elf_tdata (abfd)->core_command
1414 = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
1415 }
1416
1417 /* Note that for some reason, a spurious space is tacked
1418 onto the end of the args in some (at least one anyway)
1419 implementations, so strip it off if it exists. */
1420
1421 {
1422 char *command = elf_tdata (abfd)->core_command;
1423 int n = strlen (command);
1424
1425 if (0 < n && command[n - 1] == ' ')
1426 command[n - 1] = '\0';
1427 }
1428
1429 return TRUE;
1430 }
1431 \f
1432 /* Depending on the target vector we generate some version of Irix
1433 executables or "normal" MIPS ELF ABI executables. */
1434 static irix_compat_t
1435 elf32_mips_irix_compat (bfd *abfd)
1436 {
1437 if ((abfd->xvec == &bfd_elf32_bigmips_vec)
1438 || (abfd->xvec == &bfd_elf32_littlemips_vec))
1439 return ict_irix5;
1440 else
1441 return ict_none;
1442 }
1443 \f
1444 /* ECOFF swapping routines. These are used when dealing with the
1445 .mdebug section, which is in the ECOFF debugging format. */
1446 static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
1447 /* Symbol table magic number. */
1448 magicSym,
1449 /* Alignment of debugging information. E.g., 4. */
1450 4,
1451 /* Sizes of external symbolic information. */
1452 sizeof (struct hdr_ext),
1453 sizeof (struct dnr_ext),
1454 sizeof (struct pdr_ext),
1455 sizeof (struct sym_ext),
1456 sizeof (struct opt_ext),
1457 sizeof (struct fdr_ext),
1458 sizeof (struct rfd_ext),
1459 sizeof (struct ext_ext),
1460 /* Functions to swap in external symbolic data. */
1461 ecoff_swap_hdr_in,
1462 ecoff_swap_dnr_in,
1463 ecoff_swap_pdr_in,
1464 ecoff_swap_sym_in,
1465 ecoff_swap_opt_in,
1466 ecoff_swap_fdr_in,
1467 ecoff_swap_rfd_in,
1468 ecoff_swap_ext_in,
1469 _bfd_ecoff_swap_tir_in,
1470 _bfd_ecoff_swap_rndx_in,
1471 /* Functions to swap out external symbolic data. */
1472 ecoff_swap_hdr_out,
1473 ecoff_swap_dnr_out,
1474 ecoff_swap_pdr_out,
1475 ecoff_swap_sym_out,
1476 ecoff_swap_opt_out,
1477 ecoff_swap_fdr_out,
1478 ecoff_swap_rfd_out,
1479 ecoff_swap_ext_out,
1480 _bfd_ecoff_swap_tir_out,
1481 _bfd_ecoff_swap_rndx_out,
1482 /* Function to read in symbolic data. */
1483 _bfd_mips_elf_read_ecoff_info
1484 };
1485 \f
1486 #define ELF_ARCH bfd_arch_mips
1487 #define ELF_MACHINE_CODE EM_MIPS
1488
1489 #define elf_backend_collect TRUE
1490 #define elf_backend_type_change_ok TRUE
1491 #define elf_backend_can_gc_sections TRUE
1492 #define elf_info_to_howto mips_info_to_howto_rela
1493 #define elf_info_to_howto_rel mips_info_to_howto_rel
1494 #define elf_backend_sym_is_global mips_elf_sym_is_global
1495 #define elf_backend_object_p mips_elf32_object_p
1496 #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
1497 #define elf_backend_section_processing _bfd_mips_elf_section_processing
1498 #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
1499 #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
1500 #define elf_backend_section_from_bfd_section \
1501 _bfd_mips_elf_section_from_bfd_section
1502 #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
1503 #define elf_backend_link_output_symbol_hook \
1504 _bfd_mips_elf_link_output_symbol_hook
1505 #define elf_backend_create_dynamic_sections \
1506 _bfd_mips_elf_create_dynamic_sections
1507 #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
1508 #define elf_backend_merge_symbol_attribute \
1509 _bfd_mips_elf_merge_symbol_attribute
1510 #define elf_backend_adjust_dynamic_symbol \
1511 _bfd_mips_elf_adjust_dynamic_symbol
1512 #define elf_backend_always_size_sections \
1513 _bfd_mips_elf_always_size_sections
1514 #define elf_backend_size_dynamic_sections \
1515 _bfd_mips_elf_size_dynamic_sections
1516 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
1517 #define elf_backend_finish_dynamic_symbol \
1518 _bfd_mips_elf_finish_dynamic_symbol
1519 #define elf_backend_finish_dynamic_sections \
1520 _bfd_mips_elf_finish_dynamic_sections
1521 #define elf_backend_final_write_processing \
1522 _bfd_mips_elf_final_write_processing
1523 #define elf_backend_additional_program_headers \
1524 _bfd_mips_elf_additional_program_headers
1525 #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
1526 #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
1527 #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
1528 #define elf_backend_copy_indirect_symbol \
1529 _bfd_mips_elf_copy_indirect_symbol
1530 #define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
1531 #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
1532 #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
1533 #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
1534
1535 #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
1536 #define elf_backend_may_use_rel_p 1
1537 #define elf_backend_may_use_rela_p 0
1538 #define elf_backend_default_use_rela_p 0
1539 #define elf_backend_sign_extend_vma TRUE
1540
1541 #define elf_backend_discard_info _bfd_mips_elf_discard_info
1542 #define elf_backend_ignore_discarded_relocs \
1543 _bfd_mips_elf_ignore_discarded_relocs
1544 #define elf_backend_mips_irix_compat elf32_mips_irix_compat
1545 #define elf_backend_mips_rtype_to_howto mips_elf32_rtype_to_howto
1546 #define bfd_elf32_bfd_is_local_label_name \
1547 mips_elf_is_local_label_name
1548 #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
1549 #define bfd_elf32_find_inliner_info _bfd_mips_elf_find_inliner_info
1550 #define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook
1551 #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
1552 #define bfd_elf32_bfd_get_relocated_section_contents \
1553 _bfd_elf_mips_get_relocated_section_contents
1554 #define bfd_elf32_bfd_link_hash_table_create \
1555 _bfd_mips_elf_link_hash_table_create
1556 #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
1557 #define bfd_elf32_bfd_merge_private_bfd_data \
1558 _bfd_mips_elf_merge_private_bfd_data
1559 #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
1560 #define bfd_elf32_bfd_print_private_bfd_data \
1561 _bfd_mips_elf_print_private_bfd_data
1562
1563 /* Support for SGI-ish mips targets. */
1564 #define TARGET_LITTLE_SYM bfd_elf32_littlemips_vec
1565 #define TARGET_LITTLE_NAME "elf32-littlemips"
1566 #define TARGET_BIG_SYM bfd_elf32_bigmips_vec
1567 #define TARGET_BIG_NAME "elf32-bigmips"
1568
1569 /* The SVR4 MIPS ABI says that this should be 0x10000, but Irix 5 uses
1570 a value of 0x1000, and we are compatible. */
1571 #define ELF_MAXPAGESIZE 0x1000
1572 #define ELF_COMMONPAGESIZE 0x1000
1573
1574 #include "elf32-target.h"
1575
1576 /* Support for traditional mips targets. */
1577 #undef TARGET_LITTLE_SYM
1578 #undef TARGET_LITTLE_NAME
1579 #undef TARGET_BIG_SYM
1580 #undef TARGET_BIG_NAME
1581
1582 #undef ELF_MAXPAGESIZE
1583 #undef ELF_COMMONPAGESIZE
1584
1585 #define TARGET_LITTLE_SYM bfd_elf32_tradlittlemips_vec
1586 #define TARGET_LITTLE_NAME "elf32-tradlittlemips"
1587 #define TARGET_BIG_SYM bfd_elf32_tradbigmips_vec
1588 #define TARGET_BIG_NAME "elf32-tradbigmips"
1589
1590 /* The MIPS ABI says at Page 5-1:
1591 Virtual addresses and file offsets for MIPS segments are congruent
1592 modulo 64 KByte (0x10000) or larger powers of 2. Because 64 KBytes
1593 is the maximum page size, the files are suitable for paging
1594 regardless of physical page size. */
1595 #define ELF_MAXPAGESIZE 0x10000
1596 #define ELF_COMMONPAGESIZE 0x1000
1597 #define elf32_bed elf32_tradbed
1598
1599 /* Include the target file again for this target. */
1600 #include "elf32-target.h"
1601
1602
1603 /* Specific to VxWorks. */
1604 static reloc_howto_type mips_vxworks_copy_howto_rela =
1605 HOWTO (R_MIPS_COPY, /* type */
1606 0, /* rightshift */
1607 2, /* size (0 = byte, 1 = short, 2 = long) */
1608 32, /* bitsize */
1609 FALSE, /* pc_relative */
1610 0, /* bitpos */
1611 complain_overflow_bitfield, /* complain_on_overflow */
1612 bfd_elf_generic_reloc, /* special_function */
1613 "R_MIPS_COPY", /* name */
1614 FALSE, /* partial_inplace */
1615 0x0, /* src_mask */
1616 0x0, /* dst_mask */
1617 FALSE); /* pcrel_offset */
1618
1619 /* Specific to VxWorks. */
1620 static reloc_howto_type mips_vxworks_jump_slot_howto_rela =
1621 HOWTO (R_MIPS_JUMP_SLOT, /* type */
1622 0, /* rightshift */
1623 2, /* size (0 = byte, 1 = short, 2 = long) */
1624 32, /* bitsize */
1625 FALSE, /* pc_relative */
1626 0, /* bitpos */
1627 complain_overflow_bitfield, /* complain_on_overflow */
1628 bfd_elf_generic_reloc, /* special_function */
1629 "R_MIPS_JUMP_SLOT", /* name */
1630 FALSE, /* partial_inplace */
1631 0x0, /* src_mask */
1632 0x0, /* dst_mask */
1633 FALSE); /* pcrel_offset */
1634
1635 /* Implement elf_backend_bfd_reloc_type_lookup for VxWorks. */
1636
1637 static reloc_howto_type *
1638 mips_vxworks_bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code)
1639 {
1640 switch (code)
1641 {
1642 case BFD_RELOC_MIPS_COPY:
1643 return &mips_vxworks_copy_howto_rela;
1644 case BFD_RELOC_MIPS_JUMP_SLOT:
1645 return &mips_vxworks_jump_slot_howto_rela;
1646 default:
1647 return bfd_elf32_bfd_reloc_type_lookup (abfd, code);
1648 }
1649 }
1650
1651 /* Implement elf_backend_mips_rtype_to_lookup for VxWorks. */
1652
1653 static reloc_howto_type *
1654 mips_vxworks_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p)
1655 {
1656 switch (r_type)
1657 {
1658 case R_MIPS_COPY:
1659 return &mips_vxworks_copy_howto_rela;
1660 case R_MIPS_JUMP_SLOT:
1661 return &mips_vxworks_jump_slot_howto_rela;
1662 default:
1663 return mips_elf32_rtype_to_howto (r_type, rela_p);
1664 }
1665 }
1666
1667 /* Implement elf_backend_final_write_processing for VxWorks. */
1668
1669 static void
1670 mips_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
1671 {
1672 _bfd_mips_elf_final_write_processing (abfd, linker);
1673 elf_vxworks_final_write_processing (abfd, linker);
1674 }
1675
1676 #undef TARGET_LITTLE_SYM
1677 #undef TARGET_LITTLE_NAME
1678 #undef TARGET_BIG_SYM
1679 #undef TARGET_BIG_NAME
1680
1681 #undef ELF_MAXPAGESIZE
1682 #undef ELF_COMMONPAGESIZE
1683
1684 #define TARGET_LITTLE_SYM bfd_elf32_littlemips_vxworks_vec
1685 #define TARGET_LITTLE_NAME "elf32-littlemips-vxworks"
1686 #define TARGET_BIG_SYM bfd_elf32_bigmips_vxworks_vec
1687 #define TARGET_BIG_NAME "elf32-bigmips-vxworks"
1688
1689 #undef elf32_bed
1690 #define elf32_bed elf32_mips_vxworks_bed
1691
1692 #define ELF_MAXPAGESIZE 0x1000
1693 #define ELF_COMMONPAGESIZE 0x1000
1694
1695 #undef elf_backend_want_got_plt
1696 #define elf_backend_want_got_plt 1
1697 #undef elf_backend_want_plt_sym
1698 #define elf_backend_want_plt_sym 1
1699 #undef elf_backend_got_symbol_offset
1700 #define elf_backend_got_symbol_offset 0
1701 #undef elf_backend_want_dynbss
1702 #define elf_backend_want_dynbss 1
1703 #undef elf_backend_may_use_rel_p
1704 #define elf_backend_may_use_rel_p 0
1705 #undef elf_backend_may_use_rela_p
1706 #define elf_backend_may_use_rela_p 1
1707 #undef elf_backend_default_use_rela_p
1708 #define elf_backend_default_use_rela_p 1
1709 #undef elf_backend_got_header_size
1710 #define elf_backend_got_header_size (4 * 3)
1711 #undef elf_backend_plt_readonly
1712 #define elf_backend_plt_readonly 1
1713
1714 #undef bfd_elf32_bfd_reloc_type_lookup
1715 #define bfd_elf32_bfd_reloc_type_lookup \
1716 mips_vxworks_bfd_reloc_type_lookup
1717 #undef elf_backend_mips_rtype_to_howto
1718 #define elf_backend_mips_rtype_to_howto \
1719 mips_vxworks_rtype_to_howto
1720 #undef elf_backend_adjust_dynamic_symbol
1721 #define elf_backend_adjust_dynamic_symbol \
1722 _bfd_mips_vxworks_adjust_dynamic_symbol
1723 #undef elf_backend_finish_dynamic_symbol
1724 #define elf_backend_finish_dynamic_symbol \
1725 _bfd_mips_vxworks_finish_dynamic_symbol
1726 #undef bfd_elf32_bfd_link_hash_table_create
1727 #define bfd_elf32_bfd_link_hash_table_create \
1728 _bfd_mips_vxworks_link_hash_table_create
1729 #undef elf_backend_add_symbol_hook
1730 #define elf_backend_add_symbol_hook \
1731 elf_vxworks_add_symbol_hook
1732 #undef elf_backend_link_output_symbol_hook
1733 #define elf_backend_link_output_symbol_hook \
1734 elf_vxworks_link_output_symbol_hook
1735 #undef elf_backend_emit_relocs
1736 #define elf_backend_emit_relocs \
1737 elf_vxworks_emit_relocs
1738 #undef elf_backend_final_write_processing
1739 #define elf_backend_final_write_processing \
1740 mips_vxworks_final_write_processing
1741
1742 #undef elf_backend_additional_program_headers
1743 #undef elf_backend_modify_segment_map
1744 #undef elf_backend_symbol_processing
1745 /* NOTE: elf_backend_rela_normal is not defined for MIPS. */
1746
1747 #include "elf32-target.h"
This page took 0.08416 seconds and 4 git commands to generate.