include/
[deliverable/binutils-gdb.git] / bfd / elfn32-mips.c
CommitLineData
8a397dad 1/* MIPS-specific support for 32-bit ELF
ab7d0aa0 2 Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
eea6121a 3 2003, 2004 Free Software Foundation, Inc.
8a397dad
TS
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
12This file is part of BFD, the Binary File Descriptor library.
13
14This program is free software; you can redistribute it and/or modify
15it under the terms of the GNU General Public License as published by
16the Free Software Foundation; either version 2 of the License, or
17(at your option) any later version.
18
19This program is distributed in the hope that it will be useful,
20but WITHOUT ANY WARRANTY; without even the implied warranty of
21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22GNU General Public License for more details.
23
24You should have received a copy of the GNU General Public License
25along with this program; if not, write to the Free Software
26Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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
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"
49
b34976b6 50static bfd_boolean mips_elf_assign_gp
11a2be4d 51 (bfd *, bfd_vma *);
8a397dad 52static bfd_reloc_status_type mips_elf_final_gp
11a2be4d 53 (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *);
8a397dad 54static bfd_reloc_status_type mips_elf_gprel16_reloc
11a2be4d 55 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
8a397dad 56static bfd_reloc_status_type mips_elf_literal_reloc
11a2be4d 57 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
8a397dad 58static bfd_reloc_status_type mips_elf_gprel32_reloc
11a2be4d 59 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
8a397dad 60static bfd_reloc_status_type gprel32_with_gp
11a2be4d 61 (bfd *, asymbol *, arelent *, asection *, bfd_boolean, void *, bfd_vma);
8a397dad 62static bfd_reloc_status_type mips_elf_shift6_reloc
11a2be4d 63 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
8a397dad 64static bfd_reloc_status_type mips16_jump_reloc
11a2be4d 65 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
8a397dad 66static bfd_reloc_status_type mips16_gprel_reloc
11a2be4d 67 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
8a397dad 68static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
11a2be4d 69 (bfd *, bfd_reloc_code_real_type);
8a397dad 70static reloc_howto_type *mips_elf_n32_rtype_to_howto
11a2be4d 71 (unsigned int, bfd_boolean);
8a397dad 72static void mips_info_to_howto_rel
11a2be4d 73 (bfd *, arelent *, Elf_Internal_Rela *);
8a397dad 74static void mips_info_to_howto_rela
11a2be4d 75 (bfd *, arelent *, Elf_Internal_Rela *);
b34976b6 76static bfd_boolean mips_elf_sym_is_global
11a2be4d 77 (bfd *, asymbol *);
b34976b6 78static bfd_boolean mips_elf_n32_object_p
11a2be4d 79 (bfd *);
b34976b6 80static bfd_boolean elf32_mips_grok_prstatus
11a2be4d 81 (bfd *, Elf_Internal_Note *);
b34976b6 82static bfd_boolean elf32_mips_grok_psinfo
11a2be4d 83 (bfd *, Elf_Internal_Note *);
8a397dad 84static irix_compat_t elf_n32_mips_irix_compat
11a2be4d 85 (bfd *);
8a397dad
TS
86
87extern const bfd_target bfd_elf32_nbigmips_vec;
88extern const bfd_target bfd_elf32_nlittlemips_vec;
89
8a397dad
TS
90/* Nonzero if ABFD is using the N32 ABI. */
91#define ABI_N32_P(abfd) \
92 ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
93
94/* Whether we are trying to be compatible with IRIX at all. */
95#define SGI_COMPAT(abfd) \
96 (elf_n32_mips_irix_compat (abfd) != ict_none)
97
98/* The number of local .got entries we reserve. */
99#define MIPS_RESERVED_GOTNO (2)
100
101/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
102 from smaller values. Start with zero, widen, *then* decrement. */
103#define MINUS_ONE (((bfd_vma)0) - 1)
104
105/* The relocation table used for SHT_REL sections. */
106
107static reloc_howto_type elf_mips_howto_table_rel[] =
108{
109 /* No relocation. */
110 HOWTO (R_MIPS_NONE, /* type */
111 0, /* rightshift */
112 0, /* size (0 = byte, 1 = short, 2 = long) */
113 0, /* bitsize */
b34976b6 114 FALSE, /* pc_relative */
8a397dad
TS
115 0, /* bitpos */
116 complain_overflow_dont, /* complain_on_overflow */
30ac9238 117 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 118 "R_MIPS_NONE", /* name */
b34976b6 119 FALSE, /* partial_inplace */
8a397dad
TS
120 0, /* src_mask */
121 0, /* dst_mask */
b34976b6 122 FALSE), /* pcrel_offset */
8a397dad
TS
123
124 /* 16 bit relocation. */
125 HOWTO (R_MIPS_16, /* type */
126 0, /* rightshift */
127 2, /* size (0 = byte, 1 = short, 2 = long) */
128 16, /* bitsize */
b34976b6 129 FALSE, /* pc_relative */
8a397dad
TS
130 0, /* bitpos */
131 complain_overflow_signed, /* complain_on_overflow */
30ac9238 132 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 133 "R_MIPS_16", /* name */
b34976b6 134 TRUE, /* partial_inplace */
8a397dad
TS
135 0x0000ffff, /* src_mask */
136 0x0000ffff, /* dst_mask */
b34976b6 137 FALSE), /* pcrel_offset */
8a397dad
TS
138
139 /* 32 bit relocation. */
140 HOWTO (R_MIPS_32, /* type */
141 0, /* rightshift */
142 2, /* size (0 = byte, 1 = short, 2 = long) */
143 32, /* bitsize */
b34976b6 144 FALSE, /* pc_relative */
8a397dad
TS
145 0, /* bitpos */
146 complain_overflow_dont, /* complain_on_overflow */
30ac9238 147 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 148 "R_MIPS_32", /* name */
b34976b6 149 TRUE, /* partial_inplace */
8a397dad
TS
150 0xffffffff, /* src_mask */
151 0xffffffff, /* dst_mask */
b34976b6 152 FALSE), /* pcrel_offset */
8a397dad
TS
153
154 /* 32 bit symbol relative relocation. */
155 HOWTO (R_MIPS_REL32, /* type */
156 0, /* rightshift */
157 2, /* size (0 = byte, 1 = short, 2 = long) */
158 32, /* bitsize */
b34976b6 159 FALSE, /* pc_relative */
8a397dad
TS
160 0, /* bitpos */
161 complain_overflow_dont, /* complain_on_overflow */
30ac9238 162 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 163 "R_MIPS_REL32", /* name */
b34976b6 164 TRUE, /* partial_inplace */
8a397dad
TS
165 0xffffffff, /* src_mask */
166 0xffffffff, /* dst_mask */
b34976b6 167 FALSE), /* pcrel_offset */
8a397dad
TS
168
169 /* 26 bit jump address. */
170 HOWTO (R_MIPS_26, /* type */
171 2, /* rightshift */
172 2, /* size (0 = byte, 1 = short, 2 = long) */
173 26, /* bitsize */
b34976b6 174 FALSE, /* pc_relative */
8a397dad
TS
175 0, /* bitpos */
176 complain_overflow_dont, /* complain_on_overflow */
177 /* This needs complex overflow
178 detection, because the upper four
179 bits must match the PC + 4. */
30ac9238 180 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 181 "R_MIPS_26", /* name */
b34976b6 182 TRUE, /* partial_inplace */
8a397dad
TS
183 0x03ffffff, /* src_mask */
184 0x03ffffff, /* dst_mask */
b34976b6 185 FALSE), /* pcrel_offset */
8a397dad
TS
186
187 /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for NewABI REL.
188 However, the native IRIX6 tools use them, so we try our best. */
189
190 /* High 16 bits of symbol value. */
191 HOWTO (R_MIPS_HI16, /* type */
30ac9238 192 16, /* rightshift */
8a397dad
TS
193 2, /* size (0 = byte, 1 = short, 2 = long) */
194 16, /* bitsize */
b34976b6 195 FALSE, /* pc_relative */
8a397dad
TS
196 0, /* bitpos */
197 complain_overflow_dont, /* complain_on_overflow */
30ac9238 198 _bfd_mips_elf_hi16_reloc, /* special_function */
8a397dad 199 "R_MIPS_HI16", /* name */
b34976b6 200 TRUE, /* partial_inplace */
8a397dad
TS
201 0x0000ffff, /* src_mask */
202 0x0000ffff, /* dst_mask */
b34976b6 203 FALSE), /* pcrel_offset */
8a397dad
TS
204
205 /* Low 16 bits of symbol value. */
206 HOWTO (R_MIPS_LO16, /* type */
207 0, /* rightshift */
208 2, /* size (0 = byte, 1 = short, 2 = long) */
209 16, /* bitsize */
b34976b6 210 FALSE, /* pc_relative */
8a397dad
TS
211 0, /* bitpos */
212 complain_overflow_dont, /* complain_on_overflow */
30ac9238 213 _bfd_mips_elf_lo16_reloc, /* special_function */
8a397dad 214 "R_MIPS_LO16", /* name */
b34976b6 215 TRUE, /* partial_inplace */
8a397dad
TS
216 0x0000ffff, /* src_mask */
217 0x0000ffff, /* dst_mask */
b34976b6 218 FALSE), /* pcrel_offset */
8a397dad
TS
219
220 /* GP relative reference. */
221 HOWTO (R_MIPS_GPREL16, /* type */
222 0, /* rightshift */
223 2, /* size (0 = byte, 1 = short, 2 = long) */
224 16, /* bitsize */
b34976b6 225 FALSE, /* pc_relative */
8a397dad
TS
226 0, /* bitpos */
227 complain_overflow_signed, /* complain_on_overflow */
228 mips_elf_gprel16_reloc, /* special_function */
229 "R_MIPS_GPREL16", /* name */
b34976b6 230 TRUE, /* partial_inplace */
8a397dad
TS
231 0x0000ffff, /* src_mask */
232 0x0000ffff, /* dst_mask */
b34976b6 233 FALSE), /* pcrel_offset */
8a397dad
TS
234
235 /* Reference to literal section. */
236 HOWTO (R_MIPS_LITERAL, /* type */
237 0, /* rightshift */
238 2, /* size (0 = byte, 1 = short, 2 = long) */
239 16, /* bitsize */
b34976b6 240 FALSE, /* pc_relative */
8a397dad
TS
241 0, /* bitpos */
242 complain_overflow_signed, /* complain_on_overflow */
243 mips_elf_literal_reloc, /* special_function */
244 "R_MIPS_LITERAL", /* name */
b34976b6 245 TRUE, /* partial_inplace */
8a397dad
TS
246 0x0000ffff, /* src_mask */
247 0x0000ffff, /* dst_mask */
b34976b6 248 FALSE), /* pcrel_offset */
8a397dad
TS
249
250 /* Reference to global offset table. */
251 HOWTO (R_MIPS_GOT16, /* type */
252 0, /* rightshift */
253 2, /* size (0 = byte, 1 = short, 2 = long) */
254 16, /* bitsize */
b34976b6 255 FALSE, /* pc_relative */
8a397dad
TS
256 0, /* bitpos */
257 complain_overflow_signed, /* complain_on_overflow */
30ac9238 258 _bfd_mips_elf_got16_reloc, /* special_function */
8a397dad 259 "R_MIPS_GOT16", /* name */
b34976b6 260 TRUE, /* partial_inplace */
8a397dad
TS
261 0x0000ffff, /* src_mask */
262 0x0000ffff, /* dst_mask */
b34976b6 263 FALSE), /* pcrel_offset */
8a397dad 264
0b25d3e6 265 /* 16 bit PC relative reference. */
8a397dad 266 HOWTO (R_MIPS_PC16, /* type */
0b25d3e6 267 0, /* rightshift */
8a397dad
TS
268 2, /* size (0 = byte, 1 = short, 2 = long) */
269 16, /* bitsize */
b34976b6 270 TRUE, /* pc_relative */
8a397dad
TS
271 0, /* bitpos */
272 complain_overflow_signed, /* complain_on_overflow */
30ac9238 273 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 274 "R_MIPS_PC16", /* name */
b34976b6 275 TRUE, /* partial_inplace */
8a397dad
TS
276 0x0000ffff, /* src_mask */
277 0x0000ffff, /* dst_mask */
b34976b6 278 TRUE), /* pcrel_offset */
8a397dad
TS
279
280 /* 16 bit call through global offset table. */
281 HOWTO (R_MIPS_CALL16, /* type */
282 0, /* rightshift */
283 2, /* size (0 = byte, 1 = short, 2 = long) */
284 16, /* bitsize */
b34976b6 285 FALSE, /* pc_relative */
8a397dad
TS
286 0, /* bitpos */
287 complain_overflow_signed, /* complain_on_overflow */
30ac9238 288 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 289 "R_MIPS_CALL16", /* name */
b34976b6 290 TRUE, /* partial_inplace */
8a397dad
TS
291 0x0000ffff, /* src_mask */
292 0x0000ffff, /* dst_mask */
b34976b6 293 FALSE), /* pcrel_offset */
8a397dad
TS
294
295 /* 32 bit GP relative reference. */
296 HOWTO (R_MIPS_GPREL32, /* type */
297 0, /* rightshift */
298 2, /* size (0 = byte, 1 = short, 2 = long) */
299 32, /* bitsize */
b34976b6 300 FALSE, /* pc_relative */
8a397dad
TS
301 0, /* bitpos */
302 complain_overflow_dont, /* complain_on_overflow */
303 mips_elf_gprel32_reloc, /* special_function */
304 "R_MIPS_GPREL32", /* name */
b34976b6 305 TRUE, /* partial_inplace */
8a397dad
TS
306 0xffffffff, /* src_mask */
307 0xffffffff, /* dst_mask */
b34976b6 308 FALSE), /* pcrel_offset */
8a397dad
TS
309
310 /* The remaining relocs are defined on Irix 5, although they are
311 not defined by the ABI. */
312 EMPTY_HOWTO (13),
313 EMPTY_HOWTO (14),
314 EMPTY_HOWTO (15),
315
316 /* A 5 bit shift field. */
317 HOWTO (R_MIPS_SHIFT5, /* type */
318 0, /* rightshift */
319 2, /* size (0 = byte, 1 = short, 2 = long) */
320 5, /* bitsize */
b34976b6 321 FALSE, /* pc_relative */
8a397dad
TS
322 6, /* bitpos */
323 complain_overflow_bitfield, /* complain_on_overflow */
30ac9238 324 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 325 "R_MIPS_SHIFT5", /* name */
b34976b6 326 TRUE, /* partial_inplace */
8a397dad
TS
327 0x000007c0, /* src_mask */
328 0x000007c0, /* dst_mask */
b34976b6 329 FALSE), /* pcrel_offset */
8a397dad
TS
330
331 /* A 6 bit shift field. */
332 HOWTO (R_MIPS_SHIFT6, /* type */
333 0, /* rightshift */
334 2, /* size (0 = byte, 1 = short, 2 = long) */
335 6, /* bitsize */
b34976b6 336 FALSE, /* pc_relative */
8a397dad
TS
337 6, /* bitpos */
338 complain_overflow_bitfield, /* complain_on_overflow */
339 mips_elf_shift6_reloc, /* special_function */
340 "R_MIPS_SHIFT6", /* name */
b34976b6 341 TRUE, /* partial_inplace */
8a397dad
TS
342 0x000007c4, /* src_mask */
343 0x000007c4, /* dst_mask */
b34976b6 344 FALSE), /* pcrel_offset */
8a397dad
TS
345
346 /* A 64 bit relocation. */
347 HOWTO (R_MIPS_64, /* type */
348 0, /* rightshift */
349 4, /* size (0 = byte, 1 = short, 2 = long) */
350 64, /* bitsize */
b34976b6 351 FALSE, /* pc_relative */
8a397dad
TS
352 0, /* bitpos */
353 complain_overflow_dont, /* complain_on_overflow */
30ac9238 354 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 355 "R_MIPS_64", /* name */
b34976b6 356 TRUE, /* partial_inplace */
8a397dad
TS
357 MINUS_ONE, /* src_mask */
358 MINUS_ONE, /* dst_mask */
b34976b6 359 FALSE), /* pcrel_offset */
8a397dad
TS
360
361 /* Displacement in the global offset table. */
362 HOWTO (R_MIPS_GOT_DISP, /* type */
363 0, /* rightshift */
364 2, /* size (0 = byte, 1 = short, 2 = long) */
365 16, /* bitsize */
b34976b6 366 FALSE, /* pc_relative */
8a397dad
TS
367 0, /* bitpos */
368 complain_overflow_signed, /* complain_on_overflow */
30ac9238 369 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 370 "R_MIPS_GOT_DISP", /* name */
b34976b6 371 TRUE, /* partial_inplace */
8a397dad
TS
372 0x0000ffff, /* src_mask */
373 0x0000ffff, /* dst_mask */
b34976b6 374 FALSE), /* pcrel_offset */
8a397dad
TS
375
376 /* Displacement to page pointer in the global offset table. */
377 HOWTO (R_MIPS_GOT_PAGE, /* type */
378 0, /* rightshift */
379 2, /* size (0 = byte, 1 = short, 2 = long) */
380 16, /* bitsize */
b34976b6 381 FALSE, /* pc_relative */
8a397dad
TS
382 0, /* bitpos */
383 complain_overflow_signed, /* complain_on_overflow */
30ac9238 384 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 385 "R_MIPS_GOT_PAGE", /* name */
b34976b6 386 TRUE, /* partial_inplace */
8a397dad
TS
387 0x0000ffff, /* src_mask */
388 0x0000ffff, /* dst_mask */
b34976b6 389 FALSE), /* pcrel_offset */
8a397dad
TS
390
391 /* Offset from page pointer in the global offset table. */
392 HOWTO (R_MIPS_GOT_OFST, /* type */
393 0, /* rightshift */
394 2, /* size (0 = byte, 1 = short, 2 = long) */
395 16, /* bitsize */
b34976b6 396 FALSE, /* pc_relative */
8a397dad
TS
397 0, /* bitpos */
398 complain_overflow_signed, /* complain_on_overflow */
30ac9238 399 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 400 "R_MIPS_GOT_OFST", /* name */
b34976b6 401 TRUE, /* partial_inplace */
8a397dad
TS
402 0x0000ffff, /* src_mask */
403 0x0000ffff, /* dst_mask */
b34976b6 404 FALSE), /* pcrel_offset */
8a397dad
TS
405
406 /* High 16 bits of displacement in global offset table. */
407 HOWTO (R_MIPS_GOT_HI16, /* type */
408 0, /* rightshift */
409 2, /* size (0 = byte, 1 = short, 2 = long) */
410 16, /* bitsize */
b34976b6 411 FALSE, /* pc_relative */
8a397dad
TS
412 0, /* bitpos */
413 complain_overflow_dont, /* complain_on_overflow */
30ac9238 414 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 415 "R_MIPS_GOT_HI16", /* name */
b34976b6 416 TRUE, /* partial_inplace */
8a397dad
TS
417 0x0000ffff, /* src_mask */
418 0x0000ffff, /* dst_mask */
b34976b6 419 FALSE), /* pcrel_offset */
8a397dad
TS
420
421 /* Low 16 bits of displacement in global offset table. */
422 HOWTO (R_MIPS_GOT_LO16, /* type */
423 0, /* rightshift */
424 2, /* size (0 = byte, 1 = short, 2 = long) */
425 16, /* bitsize */
b34976b6 426 FALSE, /* pc_relative */
8a397dad
TS
427 0, /* bitpos */
428 complain_overflow_dont, /* complain_on_overflow */
30ac9238 429 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 430 "R_MIPS_GOT_LO16", /* name */
b34976b6 431 TRUE, /* partial_inplace */
8a397dad
TS
432 0x0000ffff, /* src_mask */
433 0x0000ffff, /* dst_mask */
b34976b6 434 FALSE), /* pcrel_offset */
8a397dad
TS
435
436 /* 64 bit subtraction. */
437 HOWTO (R_MIPS_SUB, /* type */
438 0, /* rightshift */
439 4, /* size (0 = byte, 1 = short, 2 = long) */
440 64, /* bitsize */
b34976b6 441 FALSE, /* pc_relative */
8a397dad
TS
442 0, /* bitpos */
443 complain_overflow_dont, /* complain_on_overflow */
30ac9238 444 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 445 "R_MIPS_SUB", /* name */
b34976b6 446 TRUE, /* partial_inplace */
8a397dad
TS
447 MINUS_ONE, /* src_mask */
448 MINUS_ONE, /* dst_mask */
b34976b6 449 FALSE), /* pcrel_offset */
8a397dad
TS
450
451 /* Insert the addend as an instruction. */
452 /* FIXME: Not handled correctly. */
453 HOWTO (R_MIPS_INSERT_A, /* type */
454 0, /* rightshift */
455 2, /* size (0 = byte, 1 = short, 2 = long) */
456 32, /* bitsize */
b34976b6 457 FALSE, /* pc_relative */
8a397dad
TS
458 0, /* bitpos */
459 complain_overflow_dont, /* complain_on_overflow */
30ac9238 460 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 461 "R_MIPS_INSERT_A", /* name */
b34976b6 462 TRUE, /* partial_inplace */
8a397dad
TS
463 0xffffffff, /* src_mask */
464 0xffffffff, /* dst_mask */
b34976b6 465 FALSE), /* pcrel_offset */
8a397dad
TS
466
467 /* Insert the addend as an instruction, and change all relocations
468 to refer to the old instruction at the address. */
469 /* FIXME: Not handled correctly. */
470 HOWTO (R_MIPS_INSERT_B, /* type */
471 0, /* rightshift */
472 2, /* size (0 = byte, 1 = short, 2 = long) */
473 32, /* bitsize */
b34976b6 474 FALSE, /* pc_relative */
8a397dad
TS
475 0, /* bitpos */
476 complain_overflow_dont, /* complain_on_overflow */
30ac9238 477 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 478 "R_MIPS_INSERT_B", /* name */
b34976b6 479 TRUE, /* partial_inplace */
8a397dad
TS
480 0xffffffff, /* src_mask */
481 0xffffffff, /* dst_mask */
b34976b6 482 FALSE), /* pcrel_offset */
8a397dad
TS
483
484 /* Delete a 32 bit instruction. */
485 /* FIXME: Not handled correctly. */
486 HOWTO (R_MIPS_DELETE, /* type */
487 0, /* rightshift */
488 2, /* size (0 = byte, 1 = short, 2 = long) */
489 32, /* bitsize */
b34976b6 490 FALSE, /* pc_relative */
8a397dad
TS
491 0, /* bitpos */
492 complain_overflow_dont, /* complain_on_overflow */
30ac9238 493 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 494 "R_MIPS_DELETE", /* name */
b34976b6 495 TRUE, /* partial_inplace */
8a397dad
TS
496 0xffffffff, /* src_mask */
497 0xffffffff, /* dst_mask */
b34976b6 498 FALSE), /* pcrel_offset */
8a397dad
TS
499
500 /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations.
501 We don't, because
502 a) It means building the addend from a R_MIPS_HIGHEST/R_MIPS_HIGHER/
503 R_MIPS_HI16/R_MIPS_LO16 sequence with varying ordering, using
504 fallable heuristics.
6422fbef 505 b) No other NewABI toolchain actually emits such relocations. */
8a397dad
TS
506 EMPTY_HOWTO (R_MIPS_HIGHER),
507 EMPTY_HOWTO (R_MIPS_HIGHEST),
508
509 /* High 16 bits of displacement in global offset table. */
510 HOWTO (R_MIPS_CALL_HI16, /* type */
511 0, /* rightshift */
512 2, /* size (0 = byte, 1 = short, 2 = long) */
513 16, /* bitsize */
b34976b6 514 FALSE, /* pc_relative */
8a397dad
TS
515 0, /* bitpos */
516 complain_overflow_dont, /* complain_on_overflow */
30ac9238 517 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 518 "R_MIPS_CALL_HI16", /* name */
b34976b6 519 TRUE, /* partial_inplace */
8a397dad
TS
520 0x0000ffff, /* src_mask */
521 0x0000ffff, /* dst_mask */
b34976b6 522 FALSE), /* pcrel_offset */
8a397dad
TS
523
524 /* Low 16 bits of displacement in global offset table. */
525 HOWTO (R_MIPS_CALL_LO16, /* type */
526 0, /* rightshift */
527 2, /* size (0 = byte, 1 = short, 2 = long) */
528 16, /* bitsize */
b34976b6 529 FALSE, /* pc_relative */
8a397dad
TS
530 0, /* bitpos */
531 complain_overflow_dont, /* complain_on_overflow */
30ac9238 532 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 533 "R_MIPS_CALL_LO16", /* name */
b34976b6 534 TRUE, /* partial_inplace */
8a397dad
TS
535 0x0000ffff, /* src_mask */
536 0x0000ffff, /* dst_mask */
b34976b6 537 FALSE), /* pcrel_offset */
8a397dad
TS
538
539 /* Section displacement. */
540 HOWTO (R_MIPS_SCN_DISP, /* type */
541 0, /* rightshift */
542 2, /* size (0 = byte, 1 = short, 2 = long) */
543 32, /* bitsize */
b34976b6 544 FALSE, /* pc_relative */
8a397dad
TS
545 0, /* bitpos */
546 complain_overflow_dont, /* complain_on_overflow */
30ac9238 547 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 548 "R_MIPS_SCN_DISP", /* name */
b34976b6 549 TRUE, /* partial_inplace */
8a397dad
TS
550 0xffffffff, /* src_mask */
551 0xffffffff, /* dst_mask */
b34976b6 552 FALSE), /* pcrel_offset */
8a397dad
TS
553
554 HOWTO (R_MIPS_REL16, /* type */
555 0, /* rightshift */
556 1, /* size (0 = byte, 1 = short, 2 = long) */
557 16, /* bitsize */
b34976b6 558 FALSE, /* pc_relative */
8a397dad
TS
559 0, /* bitpos */
560 complain_overflow_signed, /* complain_on_overflow */
30ac9238 561 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 562 "R_MIPS_REL16", /* name */
b34976b6 563 TRUE, /* partial_inplace */
8a397dad
TS
564 0xffff, /* src_mask */
565 0xffff, /* dst_mask */
b34976b6 566 FALSE), /* pcrel_offset */
8a397dad
TS
567
568 /* These two are obsolete. */
569 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
570 EMPTY_HOWTO (R_MIPS_PJUMP),
571
572 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
573 It must be used for multigot GOT's (and only there). */
574 HOWTO (R_MIPS_RELGOT, /* type */
575 0, /* rightshift */
576 2, /* size (0 = byte, 1 = short, 2 = long) */
577 32, /* bitsize */
b34976b6 578 FALSE, /* pc_relative */
8a397dad
TS
579 0, /* bitpos */
580 complain_overflow_dont, /* complain_on_overflow */
30ac9238 581 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 582 "R_MIPS_RELGOT", /* name */
b34976b6 583 TRUE, /* partial_inplace */
8a397dad
TS
584 0xffffffff, /* src_mask */
585 0xffffffff, /* dst_mask */
b34976b6 586 FALSE), /* pcrel_offset */
8a397dad
TS
587
588 /* Protected jump conversion. This is an optimization hint. No
589 relocation is required for correctness. */
590 HOWTO (R_MIPS_JALR, /* type */
591 0, /* rightshift */
592 2, /* size (0 = byte, 1 = short, 2 = long) */
593 32, /* bitsize */
b34976b6 594 FALSE, /* pc_relative */
8a397dad
TS
595 0, /* bitpos */
596 complain_overflow_dont, /* complain_on_overflow */
30ac9238 597 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 598 "R_MIPS_JALR", /* name */
b34976b6 599 FALSE, /* partial_inplace */
8a397dad
TS
600 0x00000000, /* src_mask */
601 0x00000000, /* dst_mask */
b34976b6 602 FALSE), /* pcrel_offset */
8a397dad
TS
603};
604
605/* The relocation table used for SHT_RELA sections. */
606
607static reloc_howto_type elf_mips_howto_table_rela[] =
608{
609 /* No relocation. */
610 HOWTO (R_MIPS_NONE, /* type */
611 0, /* rightshift */
612 0, /* size (0 = byte, 1 = short, 2 = long) */
613 0, /* bitsize */
b34976b6 614 FALSE, /* pc_relative */
8a397dad
TS
615 0, /* bitpos */
616 complain_overflow_dont, /* complain_on_overflow */
30ac9238 617 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 618 "R_MIPS_NONE", /* name */
b34976b6 619 FALSE, /* partial_inplace */
8a397dad
TS
620 0, /* src_mask */
621 0, /* dst_mask */
b34976b6 622 FALSE), /* pcrel_offset */
8a397dad
TS
623
624 /* 16 bit relocation. */
625 HOWTO (R_MIPS_16, /* type */
626 0, /* rightshift */
627 2, /* size (0 = byte, 1 = short, 2 = long) */
628 16, /* bitsize */
b34976b6 629 FALSE, /* pc_relative */
8a397dad
TS
630 0, /* bitpos */
631 complain_overflow_signed, /* complain_on_overflow */
30ac9238 632 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 633 "R_MIPS_16", /* name */
b34976b6 634 FALSE, /* partial_inplace */
8a397dad
TS
635 0, /* src_mask */
636 0x0000, /* dst_mask */
b34976b6 637 FALSE), /* pcrel_offset */
8a397dad
TS
638
639 /* 32 bit relocation. */
640 HOWTO (R_MIPS_32, /* type */
641 0, /* rightshift */
642 2, /* size (0 = byte, 1 = short, 2 = long) */
643 32, /* bitsize */
b34976b6 644 FALSE, /* pc_relative */
8a397dad
TS
645 0, /* bitpos */
646 complain_overflow_dont, /* complain_on_overflow */
30ac9238 647 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 648 "R_MIPS_32", /* name */
b34976b6 649 FALSE, /* partial_inplace */
8a397dad
TS
650 0, /* src_mask */
651 0xffffffff, /* dst_mask */
b34976b6 652 FALSE), /* pcrel_offset */
8a397dad
TS
653
654 /* 32 bit symbol relative relocation. */
655 HOWTO (R_MIPS_REL32, /* type */
656 0, /* rightshift */
657 2, /* size (0 = byte, 1 = short, 2 = long) */
658 32, /* bitsize */
b34976b6 659 FALSE, /* pc_relative */
8a397dad
TS
660 0, /* bitpos */
661 complain_overflow_dont, /* complain_on_overflow */
30ac9238 662 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 663 "R_MIPS_REL32", /* name */
b34976b6 664 FALSE, /* partial_inplace */
8a397dad
TS
665 0, /* src_mask */
666 0xffffffff, /* dst_mask */
b34976b6 667 FALSE), /* pcrel_offset */
8a397dad
TS
668
669 /* 26 bit jump address. */
670 HOWTO (R_MIPS_26, /* type */
671 2, /* rightshift */
672 2, /* size (0 = byte, 1 = short, 2 = long) */
673 26, /* bitsize */
b34976b6 674 FALSE, /* pc_relative */
8a397dad
TS
675 0, /* bitpos */
676 complain_overflow_dont, /* complain_on_overflow */
677 /* This needs complex overflow
678 detection, because the upper 36
679 bits must match the PC + 4. */
30ac9238 680 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 681 "R_MIPS_26", /* name */
b34976b6 682 FALSE, /* partial_inplace */
8a397dad
TS
683 0, /* src_mask */
684 0x03ffffff, /* dst_mask */
b34976b6 685 FALSE), /* pcrel_offset */
8a397dad
TS
686
687 /* High 16 bits of symbol value. */
688 HOWTO (R_MIPS_HI16, /* type */
689 0, /* rightshift */
690 2, /* size (0 = byte, 1 = short, 2 = long) */
691 16, /* bitsize */
b34976b6 692 FALSE, /* pc_relative */
8a397dad
TS
693 0, /* bitpos */
694 complain_overflow_dont, /* complain_on_overflow */
30ac9238 695 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 696 "R_MIPS_HI16", /* name */
b34976b6 697 FALSE, /* partial_inplace */
8a397dad
TS
698 0, /* src_mask */
699 0x0000ffff, /* dst_mask */
b34976b6 700 FALSE), /* pcrel_offset */
8a397dad
TS
701
702 /* Low 16 bits of symbol value. */
703 HOWTO (R_MIPS_LO16, /* type */
704 0, /* rightshift */
705 2, /* size (0 = byte, 1 = short, 2 = long) */
706 16, /* bitsize */
b34976b6 707 FALSE, /* pc_relative */
8a397dad
TS
708 0, /* bitpos */
709 complain_overflow_dont, /* complain_on_overflow */
30ac9238 710 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 711 "R_MIPS_LO16", /* name */
b34976b6 712 FALSE, /* partial_inplace */
8a397dad
TS
713 0, /* src_mask */
714 0x0000ffff, /* dst_mask */
b34976b6 715 FALSE), /* pcrel_offset */
8a397dad
TS
716
717 /* GP relative reference. */
718 HOWTO (R_MIPS_GPREL16, /* type */
719 0, /* rightshift */
720 2, /* size (0 = byte, 1 = short, 2 = long) */
721 16, /* bitsize */
b34976b6 722 FALSE, /* pc_relative */
8a397dad
TS
723 0, /* bitpos */
724 complain_overflow_signed, /* complain_on_overflow */
725 mips_elf_gprel16_reloc, /* special_function */
726 "R_MIPS_GPREL16", /* name */
b34976b6 727 FALSE, /* partial_inplace */
8a397dad
TS
728 0, /* src_mask */
729 0x0000ffff, /* dst_mask */
b34976b6 730 FALSE), /* pcrel_offset */
8a397dad
TS
731
732 /* Reference to literal section. */
733 HOWTO (R_MIPS_LITERAL, /* type */
734 0, /* rightshift */
735 2, /* size (0 = byte, 1 = short, 2 = long) */
736 16, /* bitsize */
b34976b6 737 FALSE, /* pc_relative */
8a397dad
TS
738 0, /* bitpos */
739 complain_overflow_signed, /* complain_on_overflow */
740 mips_elf_literal_reloc, /* special_function */
741 "R_MIPS_LITERAL", /* name */
b34976b6 742 FALSE, /* partial_inplace */
8a397dad
TS
743 0, /* src_mask */
744 0x0000ffff, /* dst_mask */
b34976b6 745 FALSE), /* pcrel_offset */
8a397dad
TS
746
747 /* Reference to global offset table. */
748 HOWTO (R_MIPS_GOT16, /* type */
749 0, /* rightshift */
750 2, /* size (0 = byte, 1 = short, 2 = long) */
751 16, /* bitsize */
b34976b6 752 FALSE, /* pc_relative */
8a397dad
TS
753 0, /* bitpos */
754 complain_overflow_signed, /* complain_on_overflow */
30ac9238 755 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 756 "R_MIPS_GOT16", /* name */
b34976b6 757 FALSE, /* partial_inplace */
8a397dad
TS
758 0, /* src_mask */
759 0x0000ffff, /* dst_mask */
b34976b6 760 FALSE), /* pcrel_offset */
8a397dad 761
0b25d3e6 762 /* 16 bit PC relative reference. */
8a397dad 763 HOWTO (R_MIPS_PC16, /* type */
0b25d3e6 764 0, /* rightshift */
8a397dad
TS
765 2, /* size (0 = byte, 1 = short, 2 = long) */
766 16, /* bitsize */
b34976b6 767 TRUE, /* pc_relative */
8a397dad
TS
768 0, /* bitpos */
769 complain_overflow_signed, /* complain_on_overflow */
30ac9238 770 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 771 "R_MIPS_PC16", /* name */
b34976b6 772 FALSE, /* partial_inplace */
8a397dad
TS
773 0, /* src_mask */
774 0x0000ffff, /* dst_mask */
b34976b6 775 TRUE), /* pcrel_offset */
8a397dad
TS
776
777 /* 16 bit call through global offset table. */
778 HOWTO (R_MIPS_CALL16, /* type */
779 0, /* rightshift */
780 2, /* size (0 = byte, 1 = short, 2 = long) */
781 16, /* bitsize */
b34976b6 782 FALSE, /* pc_relative */
8a397dad
TS
783 0, /* bitpos */
784 complain_overflow_signed, /* complain_on_overflow */
30ac9238 785 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 786 "R_MIPS_CALL16", /* name */
b34976b6 787 FALSE, /* partial_inplace */
8a397dad
TS
788 0, /* src_mask */
789 0x0000ffff, /* dst_mask */
b34976b6 790 FALSE), /* pcrel_offset */
8a397dad
TS
791
792 /* 32 bit GP relative reference. */
793 HOWTO (R_MIPS_GPREL32, /* type */
794 0, /* rightshift */
795 2, /* size (0 = byte, 1 = short, 2 = long) */
796 32, /* bitsize */
b34976b6 797 FALSE, /* pc_relative */
8a397dad
TS
798 0, /* bitpos */
799 complain_overflow_dont, /* complain_on_overflow */
800 mips_elf_gprel32_reloc, /* special_function */
801 "R_MIPS_GPREL32", /* name */
b34976b6 802 FALSE, /* partial_inplace */
8a397dad
TS
803 0, /* src_mask */
804 0xffffffff, /* dst_mask */
b34976b6 805 FALSE), /* pcrel_offset */
8a397dad
TS
806
807 EMPTY_HOWTO (13),
808 EMPTY_HOWTO (14),
809 EMPTY_HOWTO (15),
810
811 /* A 5 bit shift field. */
812 HOWTO (R_MIPS_SHIFT5, /* type */
813 0, /* rightshift */
814 2, /* size (0 = byte, 1 = short, 2 = long) */
815 5, /* bitsize */
b34976b6 816 FALSE, /* pc_relative */
8a397dad
TS
817 6, /* bitpos */
818 complain_overflow_bitfield, /* complain_on_overflow */
30ac9238 819 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 820 "R_MIPS_SHIFT5", /* name */
b34976b6 821 FALSE, /* partial_inplace */
8a397dad
TS
822 0, /* src_mask */
823 0x000007c0, /* dst_mask */
b34976b6 824 FALSE), /* pcrel_offset */
8a397dad
TS
825
826 /* A 6 bit shift field. */
827 HOWTO (R_MIPS_SHIFT6, /* type */
828 0, /* rightshift */
829 2, /* size (0 = byte, 1 = short, 2 = long) */
830 6, /* bitsize */
b34976b6 831 FALSE, /* pc_relative */
8a397dad
TS
832 6, /* bitpos */
833 complain_overflow_bitfield, /* complain_on_overflow */
834 mips_elf_shift6_reloc, /* special_function */
835 "R_MIPS_SHIFT6", /* name */
b34976b6 836 FALSE, /* partial_inplace */
8a397dad
TS
837 0, /* src_mask */
838 0x000007c4, /* dst_mask */
b34976b6 839 FALSE), /* pcrel_offset */
8a397dad
TS
840
841 /* 64 bit relocation. */
842 HOWTO (R_MIPS_64, /* type */
843 0, /* rightshift */
844 4, /* size (0 = byte, 1 = short, 2 = long) */
845 64, /* bitsize */
b34976b6 846 FALSE, /* pc_relative */
8a397dad
TS
847 0, /* bitpos */
848 complain_overflow_dont, /* complain_on_overflow */
30ac9238 849 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 850 "R_MIPS_64", /* name */
b34976b6 851 FALSE, /* partial_inplace */
8a397dad
TS
852 0, /* src_mask */
853 MINUS_ONE, /* dst_mask */
b34976b6 854 FALSE), /* pcrel_offset */
8a397dad
TS
855
856 /* Displacement in the global offset table. */
857 HOWTO (R_MIPS_GOT_DISP, /* type */
858 0, /* rightshift */
859 2, /* size (0 = byte, 1 = short, 2 = long) */
860 16, /* bitsize */
b34976b6 861 FALSE, /* pc_relative */
8a397dad
TS
862 0, /* bitpos */
863 complain_overflow_signed, /* complain_on_overflow */
30ac9238 864 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 865 "R_MIPS_GOT_DISP", /* name */
b34976b6 866 FALSE, /* partial_inplace */
8a397dad
TS
867 0, /* src_mask */
868 0x0000ffff, /* dst_mask */
b34976b6 869 FALSE), /* pcrel_offset */
8a397dad
TS
870
871 /* Displacement to page pointer in the global offset table. */
872 HOWTO (R_MIPS_GOT_PAGE, /* type */
873 0, /* rightshift */
874 2, /* size (0 = byte, 1 = short, 2 = long) */
875 16, /* bitsize */
b34976b6 876 FALSE, /* pc_relative */
8a397dad
TS
877 0, /* bitpos */
878 complain_overflow_signed, /* complain_on_overflow */
30ac9238 879 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 880 "R_MIPS_GOT_PAGE", /* name */
b34976b6 881 FALSE, /* partial_inplace */
8a397dad
TS
882 0, /* src_mask */
883 0x0000ffff, /* dst_mask */
b34976b6 884 FALSE), /* pcrel_offset */
8a397dad
TS
885
886 /* Offset from page pointer in the global offset table. */
887 HOWTO (R_MIPS_GOT_OFST, /* type */
888 0, /* rightshift */
889 2, /* size (0 = byte, 1 = short, 2 = long) */
890 16, /* bitsize */
b34976b6 891 FALSE, /* pc_relative */
8a397dad
TS
892 0, /* bitpos */
893 complain_overflow_signed, /* complain_on_overflow */
30ac9238 894 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 895 "R_MIPS_GOT_OFST", /* name */
b34976b6 896 FALSE, /* partial_inplace */
8a397dad
TS
897 0, /* src_mask */
898 0x0000ffff, /* dst_mask */
b34976b6 899 FALSE), /* pcrel_offset */
8a397dad
TS
900
901 /* High 16 bits of displacement in global offset table. */
902 HOWTO (R_MIPS_GOT_HI16, /* type */
903 0, /* rightshift */
904 2, /* size (0 = byte, 1 = short, 2 = long) */
905 16, /* bitsize */
b34976b6 906 FALSE, /* pc_relative */
8a397dad
TS
907 0, /* bitpos */
908 complain_overflow_dont, /* complain_on_overflow */
30ac9238 909 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 910 "R_MIPS_GOT_HI16", /* name */
b34976b6 911 FALSE, /* partial_inplace */
8a397dad
TS
912 0, /* src_mask */
913 0x0000ffff, /* dst_mask */
b34976b6 914 FALSE), /* pcrel_offset */
8a397dad
TS
915
916 /* Low 16 bits of displacement in global offset table. */
917 HOWTO (R_MIPS_GOT_LO16, /* type */
918 0, /* rightshift */
919 2, /* size (0 = byte, 1 = short, 2 = long) */
920 16, /* bitsize */
b34976b6 921 FALSE, /* pc_relative */
8a397dad
TS
922 0, /* bitpos */
923 complain_overflow_dont, /* complain_on_overflow */
30ac9238 924 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 925 "R_MIPS_GOT_LO16", /* name */
b34976b6 926 FALSE, /* partial_inplace */
8a397dad
TS
927 0, /* src_mask */
928 0x0000ffff, /* dst_mask */
b34976b6 929 FALSE), /* pcrel_offset */
8a397dad 930
4cc11e76 931 /* 64 bit subtraction. */
8a397dad
TS
932 HOWTO (R_MIPS_SUB, /* type */
933 0, /* rightshift */
934 4, /* size (0 = byte, 1 = short, 2 = long) */
935 64, /* bitsize */
b34976b6 936 FALSE, /* pc_relative */
8a397dad
TS
937 0, /* bitpos */
938 complain_overflow_dont, /* complain_on_overflow */
30ac9238 939 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 940 "R_MIPS_SUB", /* name */
b34976b6 941 FALSE, /* partial_inplace */
8a397dad
TS
942 0, /* src_mask */
943 MINUS_ONE, /* dst_mask */
b34976b6 944 FALSE), /* pcrel_offset */
8a397dad
TS
945
946 /* Insert the addend as an instruction. */
947 /* FIXME: Not handled correctly. */
948 HOWTO (R_MIPS_INSERT_A, /* type */
949 0, /* rightshift */
950 2, /* size (0 = byte, 1 = short, 2 = long) */
951 32, /* bitsize */
b34976b6 952 FALSE, /* pc_relative */
8a397dad
TS
953 0, /* bitpos */
954 complain_overflow_dont, /* complain_on_overflow */
30ac9238 955 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 956 "R_MIPS_INSERT_A", /* name */
b34976b6 957 FALSE, /* partial_inplace */
8a397dad
TS
958 0, /* src_mask */
959 0xffffffff, /* dst_mask */
b34976b6 960 FALSE), /* pcrel_offset */
8a397dad
TS
961
962 /* Insert the addend as an instruction, and change all relocations
963 to refer to the old instruction at the address. */
964 /* FIXME: Not handled correctly. */
965 HOWTO (R_MIPS_INSERT_B, /* type */
966 0, /* rightshift */
967 2, /* size (0 = byte, 1 = short, 2 = long) */
968 32, /* bitsize */
b34976b6 969 FALSE, /* pc_relative */
8a397dad
TS
970 0, /* bitpos */
971 complain_overflow_dont, /* complain_on_overflow */
30ac9238 972 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 973 "R_MIPS_INSERT_B", /* name */
b34976b6 974 FALSE, /* partial_inplace */
8a397dad
TS
975 0, /* src_mask */
976 0xffffffff, /* dst_mask */
b34976b6 977 FALSE), /* pcrel_offset */
8a397dad
TS
978
979 /* Delete a 32 bit instruction. */
980 /* FIXME: Not handled correctly. */
981 HOWTO (R_MIPS_DELETE, /* type */
982 0, /* rightshift */
983 2, /* size (0 = byte, 1 = short, 2 = long) */
984 32, /* bitsize */
b34976b6 985 FALSE, /* pc_relative */
8a397dad
TS
986 0, /* bitpos */
987 complain_overflow_dont, /* complain_on_overflow */
30ac9238 988 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 989 "R_MIPS_DELETE", /* name */
b34976b6 990 FALSE, /* partial_inplace */
8a397dad
TS
991 0, /* src_mask */
992 0xffffffff, /* dst_mask */
b34976b6 993 FALSE), /* pcrel_offset */
8a397dad
TS
994
995 /* Get the higher value of a 64 bit addend. */
996 HOWTO (R_MIPS_HIGHER, /* type */
997 0, /* rightshift */
998 2, /* size (0 = byte, 1 = short, 2 = long) */
999 16, /* bitsize */
b34976b6 1000 FALSE, /* pc_relative */
8a397dad
TS
1001 0, /* bitpos */
1002 complain_overflow_dont, /* complain_on_overflow */
30ac9238 1003 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 1004 "R_MIPS_HIGHER", /* name */
b34976b6 1005 FALSE, /* partial_inplace */
8a397dad
TS
1006 0, /* src_mask */
1007 0x0000ffff, /* dst_mask */
b34976b6 1008 FALSE), /* pcrel_offset */
8a397dad
TS
1009
1010 /* Get the highest value of a 64 bit addend. */
1011 HOWTO (R_MIPS_HIGHEST, /* type */
1012 0, /* rightshift */
1013 2, /* size (0 = byte, 1 = short, 2 = long) */
1014 16, /* bitsize */
b34976b6 1015 FALSE, /* pc_relative */
8a397dad
TS
1016 0, /* bitpos */
1017 complain_overflow_dont, /* complain_on_overflow */
30ac9238 1018 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 1019 "R_MIPS_HIGHEST", /* name */
b34976b6 1020 FALSE, /* partial_inplace */
8a397dad
TS
1021 0, /* src_mask */
1022 0x0000ffff, /* dst_mask */
b34976b6 1023 FALSE), /* pcrel_offset */
8a397dad
TS
1024
1025 /* High 16 bits of displacement in global offset table. */
1026 HOWTO (R_MIPS_CALL_HI16, /* type */
1027 0, /* rightshift */
1028 2, /* size (0 = byte, 1 = short, 2 = long) */
1029 16, /* bitsize */
b34976b6 1030 FALSE, /* pc_relative */
8a397dad
TS
1031 0, /* bitpos */
1032 complain_overflow_dont, /* complain_on_overflow */
30ac9238 1033 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 1034 "R_MIPS_CALL_HI16", /* name */
b34976b6 1035 FALSE, /* partial_inplace */
8a397dad
TS
1036 0, /* src_mask */
1037 0x0000ffff, /* dst_mask */
b34976b6 1038 FALSE), /* pcrel_offset */
8a397dad
TS
1039
1040 /* Low 16 bits of displacement in global offset table. */
1041 HOWTO (R_MIPS_CALL_LO16, /* type */
1042 0, /* rightshift */
1043 2, /* size (0 = byte, 1 = short, 2 = long) */
1044 16, /* bitsize */
b34976b6 1045 FALSE, /* pc_relative */
8a397dad
TS
1046 0, /* bitpos */
1047 complain_overflow_dont, /* complain_on_overflow */
30ac9238 1048 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 1049 "R_MIPS_CALL_LO16", /* name */
b34976b6 1050 FALSE, /* partial_inplace */
8a397dad
TS
1051 0, /* src_mask */
1052 0x0000ffff, /* dst_mask */
b34976b6 1053 FALSE), /* pcrel_offset */
8a397dad
TS
1054
1055 /* Section displacement, used by an associated event location section. */
1056 HOWTO (R_MIPS_SCN_DISP, /* type */
1057 0, /* rightshift */
1058 2, /* size (0 = byte, 1 = short, 2 = long) */
1059 32, /* bitsize */
b34976b6 1060 FALSE, /* pc_relative */
8a397dad
TS
1061 0, /* bitpos */
1062 complain_overflow_dont, /* complain_on_overflow */
30ac9238 1063 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 1064 "R_MIPS_SCN_DISP", /* name */
b34976b6 1065 FALSE, /* partial_inplace */
8a397dad
TS
1066 0, /* src_mask */
1067 0xffffffff, /* dst_mask */
b34976b6 1068 FALSE), /* pcrel_offset */
8a397dad
TS
1069
1070 /* 16 bit relocation. */
1071 HOWTO (R_MIPS_REL16, /* type */
1072 0, /* rightshift */
1073 1, /* size (0 = byte, 1 = short, 2 = long) */
1074 16, /* bitsize */
b34976b6 1075 FALSE, /* pc_relative */
8a397dad
TS
1076 0, /* bitpos */
1077 complain_overflow_signed, /* complain_on_overflow */
30ac9238 1078 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 1079 "R_MIPS_REL16", /* name */
b34976b6 1080 FALSE, /* partial_inplace */
8a397dad
TS
1081 0, /* src_mask */
1082 0xffff, /* dst_mask */
b34976b6 1083 FALSE), /* pcrel_offset */
8a397dad
TS
1084
1085 /* These two are obsolete. */
1086 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
1087 EMPTY_HOWTO (R_MIPS_PJUMP),
1088
1089 /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
1090 It must be used for multigot GOT's (and only there). */
1091 HOWTO (R_MIPS_RELGOT, /* type */
1092 0, /* rightshift */
1093 2, /* size (0 = byte, 1 = short, 2 = long) */
1094 32, /* bitsize */
b34976b6 1095 FALSE, /* pc_relative */
8a397dad
TS
1096 0, /* bitpos */
1097 complain_overflow_dont, /* complain_on_overflow */
30ac9238 1098 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 1099 "R_MIPS_RELGOT", /* name */
b34976b6 1100 FALSE, /* partial_inplace */
8a397dad
TS
1101 0, /* src_mask */
1102 0xffffffff, /* dst_mask */
b34976b6 1103 FALSE), /* pcrel_offset */
8a397dad
TS
1104
1105 /* Protected jump conversion. This is an optimization hint. No
1106 relocation is required for correctness. */
1107 HOWTO (R_MIPS_JALR, /* type */
1108 0, /* rightshift */
1109 2, /* size (0 = byte, 1 = short, 2 = long) */
1110 32, /* bitsize */
b34976b6 1111 FALSE, /* pc_relative */
8a397dad
TS
1112 0, /* bitpos */
1113 complain_overflow_dont, /* complain_on_overflow */
30ac9238 1114 _bfd_mips_elf_generic_reloc, /* special_function */
8a397dad 1115 "R_MIPS_JALR", /* name */
b34976b6 1116 FALSE, /* partial_inplace */
8a397dad 1117 0, /* src_mask */
74f79d8d 1118 0, /* dst_mask */
b34976b6 1119 FALSE), /* pcrel_offset */
8a397dad
TS
1120};
1121
d6f16593
MR
1122static reloc_howto_type elf_mips16_howto_table_rel[] =
1123{
1124 /* The reloc used for the mips16 jump instruction. */
8a397dad
TS
1125 HOWTO (R_MIPS16_26, /* type */
1126 2, /* rightshift */
1127 2, /* size (0 = byte, 1 = short, 2 = long) */
1128 26, /* bitsize */
b34976b6 1129 FALSE, /* pc_relative */
8a397dad
TS
1130 0, /* bitpos */
1131 complain_overflow_dont, /* complain_on_overflow */
1132 /* This needs complex overflow
1133 detection, because the upper four
1134 bits must match the PC. */
1135 mips16_jump_reloc, /* special_function */
1136 "R_MIPS16_26", /* name */
b34976b6 1137 TRUE, /* partial_inplace */
8a397dad
TS
1138 0x3ffffff, /* src_mask */
1139 0x3ffffff, /* dst_mask */
d6f16593 1140 FALSE), /* pcrel_offset */
8a397dad 1141
d6f16593 1142 /* The reloc used for the mips16 gprel instruction. */
8a397dad
TS
1143 HOWTO (R_MIPS16_GPREL, /* type */
1144 0, /* rightshift */
1145 2, /* size (0 = byte, 1 = short, 2 = long) */
1146 16, /* bitsize */
b34976b6 1147 FALSE, /* pc_relative */
8a397dad
TS
1148 0, /* bitpos */
1149 complain_overflow_signed, /* complain_on_overflow */
1150 mips16_gprel_reloc, /* special_function */
1151 "R_MIPS16_GPREL", /* name */
b34976b6 1152 TRUE, /* partial_inplace */
d6f16593
MR
1153 0x0000ffff, /* src_mask */
1154 0x0000ffff, /* dst_mask */
1155 FALSE), /* pcrel_offset */
1156
1157 /* A placeholder for MIPS16 reference to global offset table. */
1158 EMPTY_HOWTO (R_MIPS16_GOT16),
1159
1160 /* A placeholder for MIPS16 16 bit call through global offset table. */
1161 EMPTY_HOWTO (R_MIPS16_CALL16),
1162
1163 /* MIPS16 high 16 bits of symbol value. */
1164 HOWTO (R_MIPS16_HI16, /* type */
1165 16, /* rightshift */
1166 2, /* size (0 = byte, 1 = short, 2 = long) */
1167 16, /* bitsize */
1168 FALSE, /* pc_relative */
1169 0, /* bitpos */
1170 complain_overflow_dont, /* complain_on_overflow */
1171 _bfd_mips_elf_hi16_reloc, /* special_function */
1172 "R_MIPS16_HI16", /* name */
1173 TRUE, /* partial_inplace */
1174 0x0000ffff, /* src_mask */
1175 0x0000ffff, /* dst_mask */
1176 FALSE), /* pcrel_offset */
1177
1178 /* MIPS16 low 16 bits of symbol value. */
1179 HOWTO (R_MIPS16_LO16, /* type */
1180 0, /* rightshift */
1181 2, /* size (0 = byte, 1 = short, 2 = long) */
1182 16, /* bitsize */
1183 FALSE, /* pc_relative */
1184 0, /* bitpos */
1185 complain_overflow_dont, /* complain_on_overflow */
1186 _bfd_mips_elf_lo16_reloc, /* special_function */
1187 "R_MIPS16_LO16", /* name */
1188 TRUE, /* partial_inplace */
1189 0x0000ffff, /* src_mask */
1190 0x0000ffff, /* dst_mask */
1191 FALSE), /* pcrel_offset */
1192};
1193
1194static reloc_howto_type elf_mips16_howto_table_rela[] =
1195{
1196 /* The reloc used for the mips16 jump instruction. */
1197 HOWTO (R_MIPS16_26, /* type */
1198 2, /* rightshift */
1199 2, /* size (0 = byte, 1 = short, 2 = long) */
1200 26, /* bitsize */
1201 FALSE, /* pc_relative */
1202 0, /* bitpos */
1203 complain_overflow_dont, /* complain_on_overflow */
1204 /* This needs complex overflow
1205 detection, because the upper four
1206 bits must match the PC. */
1207 mips16_jump_reloc, /* special_function */
1208 "R_MIPS16_26", /* name */
1209 FALSE, /* partial_inplace */
1210 0x3ffffff, /* src_mask */
1211 0x3ffffff, /* dst_mask */
1212 FALSE), /* pcrel_offset */
1213
1214 /* The reloc used for the mips16 gprel instruction. */
1215 HOWTO (R_MIPS16_GPREL, /* type */
1216 0, /* rightshift */
1217 2, /* size (0 = byte, 1 = short, 2 = long) */
1218 16, /* bitsize */
1219 FALSE, /* pc_relative */
1220 0, /* bitpos */
1221 complain_overflow_signed, /* complain_on_overflow */
1222 mips16_gprel_reloc, /* special_function */
1223 "R_MIPS16_GPREL", /* name */
1224 FALSE, /* partial_inplace */
1225 0x0000ffff, /* src_mask */
1226 0x0000ffff, /* dst_mask */
1227 FALSE), /* pcrel_offset */
1228
1229 /* A placeholder for MIPS16 reference to global offset table. */
1230 EMPTY_HOWTO (R_MIPS16_GOT16),
1231
1232 /* A placeholder for MIPS16 16 bit call through global offset table. */
1233 EMPTY_HOWTO (R_MIPS16_CALL16),
1234
1235 /* MIPS16 high 16 bits of symbol value. */
1236 HOWTO (R_MIPS16_HI16, /* type */
1237 16, /* rightshift */
1238 2, /* size (0 = byte, 1 = short, 2 = long) */
1239 16, /* bitsize */
1240 FALSE, /* pc_relative */
1241 0, /* bitpos */
1242 complain_overflow_dont, /* complain_on_overflow */
1243 _bfd_mips_elf_hi16_reloc, /* special_function */
1244 "R_MIPS16_HI16", /* name */
1245 FALSE, /* partial_inplace */
1246 0x0000ffff, /* src_mask */
1247 0x0000ffff, /* dst_mask */
1248 FALSE), /* pcrel_offset */
1249
1250 /* MIPS16 low 16 bits of symbol value. */
1251 HOWTO (R_MIPS16_LO16, /* type */
1252 0, /* rightshift */
1253 2, /* size (0 = byte, 1 = short, 2 = long) */
1254 16, /* bitsize */
1255 FALSE, /* pc_relative */
1256 0, /* bitpos */
1257 complain_overflow_dont, /* complain_on_overflow */
1258 _bfd_mips_elf_lo16_reloc, /* special_function */
1259 "R_MIPS16_LO16", /* name */
1260 FALSE, /* partial_inplace */
1261 0x0000ffff, /* src_mask */
1262 0x0000ffff, /* dst_mask */
1263 FALSE), /* pcrel_offset */
1264};
8a397dad
TS
1265
1266/* GNU extension to record C++ vtable hierarchy */
1267static reloc_howto_type elf_mips_gnu_vtinherit_howto =
1268 HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
1269 0, /* rightshift */
1270 2, /* size (0 = byte, 1 = short, 2 = long) */
1271 0, /* bitsize */
b34976b6 1272 FALSE, /* pc_relative */
8a397dad
TS
1273 0, /* bitpos */
1274 complain_overflow_dont, /* complain_on_overflow */
1275 NULL, /* special_function */
1276 "R_MIPS_GNU_VTINHERIT", /* name */
b34976b6 1277 FALSE, /* partial_inplace */
8a397dad
TS
1278 0, /* src_mask */
1279 0, /* dst_mask */
b34976b6 1280 FALSE); /* pcrel_offset */
8a397dad
TS
1281
1282/* GNU extension to record C++ vtable member usage */
1283static reloc_howto_type elf_mips_gnu_vtentry_howto =
1284 HOWTO (R_MIPS_GNU_VTENTRY, /* type */
1285 0, /* rightshift */
1286 2, /* size (0 = byte, 1 = short, 2 = long) */
1287 0, /* bitsize */
b34976b6 1288 FALSE, /* pc_relative */
8a397dad
TS
1289 0, /* bitpos */
1290 complain_overflow_dont, /* complain_on_overflow */
1291 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
1292 "R_MIPS_GNU_VTENTRY", /* name */
b34976b6 1293 FALSE, /* partial_inplace */
8a397dad
TS
1294 0, /* src_mask */
1295 0, /* dst_mask */
b34976b6 1296 FALSE); /* pcrel_offset */
8a397dad 1297\f
d0c728db
TS
1298/* 16 bit offset for pc-relative branches. */
1299static reloc_howto_type elf_mips_gnu_rel16_s2 =
1300 HOWTO (R_MIPS_GNU_REL16_S2, /* type */
1301 2, /* rightshift */
1302 2, /* size (0 = byte, 1 = short, 2 = long) */
1303 16, /* bitsize */
1304 TRUE, /* pc_relative */
1305 0, /* bitpos */
1306 complain_overflow_signed, /* complain_on_overflow */
30ac9238 1307 _bfd_mips_elf_generic_reloc, /* special_function */
d0c728db
TS
1308 "R_MIPS_GNU_REL16_S2", /* name */
1309 TRUE, /* partial_inplace */
1310 0x0000ffff, /* src_mask */
1311 0x0000ffff, /* dst_mask */
1312 TRUE); /* pcrel_offset */
1313
1314/* 16 bit offset for pc-relative branches. */
1315static reloc_howto_type elf_mips_gnu_rela16_s2 =
1316 HOWTO (R_MIPS_GNU_REL16_S2, /* type */
1317 2, /* rightshift */
1318 2, /* size (0 = byte, 1 = short, 2 = long) */
1319 16, /* bitsize */
1320 TRUE, /* pc_relative */
1321 0, /* bitpos */
1322 complain_overflow_signed, /* complain_on_overflow */
30ac9238 1323 _bfd_mips_elf_generic_reloc, /* special_function */
d0c728db
TS
1324 "R_MIPS_GNU_REL16_S2", /* name */
1325 FALSE, /* partial_inplace */
1326 0, /* src_mask */
1327 0x0000ffff, /* dst_mask */
1328 TRUE); /* pcrel_offset */
1329\f
b34976b6 1330/* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
8a397dad
TS
1331 dangerous relocation. */
1332
b34976b6 1333static bfd_boolean
11a2be4d 1334mips_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
8a397dad
TS
1335{
1336 unsigned int count;
1337 asymbol **sym;
1338 unsigned int i;
1339
1340 /* If we've already figured out what GP will be, just return it. */
1341 *pgp = _bfd_get_gp_value (output_bfd);
1342 if (*pgp)
b34976b6 1343 return TRUE;
8a397dad
TS
1344
1345 count = bfd_get_symcount (output_bfd);
1346 sym = bfd_get_outsymbols (output_bfd);
1347
1348 /* The linker script will have created a symbol named `_gp' with the
1349 appropriate value. */
11a2be4d 1350 if (sym == NULL)
8a397dad
TS
1351 i = count;
1352 else
1353 {
1354 for (i = 0; i < count; i++, sym++)
1355 {
1356 register const char *name;
1357
1358 name = bfd_asymbol_name (*sym);
1359 if (*name == '_' && strcmp (name, "_gp") == 0)
1360 {
1361 *pgp = bfd_asymbol_value (*sym);
1362 _bfd_set_gp_value (output_bfd, *pgp);
1363 break;
1364 }
1365 }
1366 }
1367
1368 if (i >= count)
1369 {
1370 /* Only get the error once. */
1371 *pgp = 4;
1372 _bfd_set_gp_value (output_bfd, *pgp);
b34976b6 1373 return FALSE;
8a397dad
TS
1374 }
1375
b34976b6 1376 return TRUE;
8a397dad
TS
1377}
1378
1379/* We have to figure out the gp value, so that we can adjust the
1380 symbol value correctly. We look up the symbol _gp in the output
1381 BFD. If we can't find it, we're stuck. We cache it in the ELF
1382 target data. We don't need to adjust the symbol value for an
1049f94e 1383 external symbol if we are producing relocatable output. */
8a397dad
TS
1384
1385static bfd_reloc_status_type
11a2be4d
RS
1386mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
1387 char **error_message, bfd_vma *pgp)
8a397dad
TS
1388{
1389 if (bfd_is_und_section (symbol->section)
1049f94e 1390 && ! relocatable)
8a397dad
TS
1391 {
1392 *pgp = 0;
1393 return bfd_reloc_undefined;
1394 }
1395
1396 *pgp = _bfd_get_gp_value (output_bfd);
1397 if (*pgp == 0
1049f94e 1398 && (! relocatable
8a397dad
TS
1399 || (symbol->flags & BSF_SECTION_SYM) != 0))
1400 {
1049f94e 1401 if (relocatable)
8a397dad
TS
1402 {
1403 /* Make up a value. */
a902ee94 1404 *pgp = symbol->section->output_section->vma /*+ 0x4000*/;
8a397dad
TS
1405 _bfd_set_gp_value (output_bfd, *pgp);
1406 }
1407 else if (!mips_elf_assign_gp (output_bfd, pgp))
1408 {
1409 *error_message =
1410 (char *) _("GP relative relocation when _gp not defined");
1411 return bfd_reloc_dangerous;
1412 }
1413 }
1414
1415 return bfd_reloc_ok;
1416}
1417
1418/* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
1419 become the offset from the gp register. */
1420
1421static bfd_reloc_status_type
11a2be4d
RS
1422mips_elf_gprel16_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
1423 asymbol *symbol, void *data ATTRIBUTE_UNUSED,
1424 asection *input_section, bfd *output_bfd,
1425 char **error_message ATTRIBUTE_UNUSED)
8a397dad 1426{
1049f94e 1427 bfd_boolean relocatable;
8a397dad
TS
1428 bfd_reloc_status_type ret;
1429 bfd_vma gp;
1430
11a2be4d 1431 if (output_bfd != NULL)
1049f94e 1432 relocatable = TRUE;
8a397dad
TS
1433 else
1434 {
1049f94e 1435 relocatable = FALSE;
8a397dad
TS
1436 output_bfd = symbol->section->output_section->owner;
1437 }
1438
1049f94e 1439 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
8a397dad
TS
1440 &gp);
1441 if (ret != bfd_reloc_ok)
1442 return ret;
1443
1444 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1049f94e 1445 input_section, relocatable,
8a397dad
TS
1446 data, gp);
1447}
1448
1449/* Do a R_MIPS_LITERAL relocation. */
1450
1451static bfd_reloc_status_type
11a2be4d
RS
1452mips_elf_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
1453 void *data, asection *input_section, bfd *output_bfd,
1454 char **error_message)
8a397dad 1455{
1049f94e 1456 bfd_boolean relocatable;
8a397dad
TS
1457 bfd_reloc_status_type ret;
1458 bfd_vma gp;
1459
254f0426
MR
1460 /* R_MIPS_LITERAL relocations are defined for local symbols only. */
1461 if (output_bfd != NULL
1462 && (symbol->flags & BSF_SECTION_SYM) == 0
1463 && (symbol->flags & BSF_LOCAL) != 0)
1464 {
1465 *error_message = (char *)
1466 _("literal relocation occurs for an external symbol");
1467 return bfd_reloc_outofrange;
1468 }
1469
8a397dad 1470 /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */
11a2be4d 1471 if (output_bfd != NULL)
1049f94e 1472 relocatable = TRUE;
8a397dad
TS
1473 else
1474 {
1049f94e 1475 relocatable = FALSE;
8a397dad
TS
1476 output_bfd = symbol->section->output_section->owner;
1477 }
1478
1049f94e 1479 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
8a397dad
TS
1480 &gp);
1481 if (ret != bfd_reloc_ok)
1482 return ret;
1483
1484 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1049f94e 1485 input_section, relocatable,
8a397dad
TS
1486 data, gp);
1487}
1488
1489/* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
1490 become the offset from the gp register. */
1491
1492static bfd_reloc_status_type
11a2be4d
RS
1493mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
1494 void *data, asection *input_section, bfd *output_bfd,
1495 char **error_message)
8a397dad 1496{
1049f94e 1497 bfd_boolean relocatable;
8a397dad
TS
1498 bfd_reloc_status_type ret;
1499 bfd_vma gp;
1500
a7ebbfdf 1501 /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
11a2be4d 1502 if (output_bfd != NULL
8a397dad 1503 && (symbol->flags & BSF_SECTION_SYM) == 0
a7ebbfdf 1504 && (symbol->flags & BSF_LOCAL) != 0)
8a397dad
TS
1505 {
1506 *error_message = (char *)
1507 _("32bits gp relative relocation occurs for an external symbol");
1508 return bfd_reloc_outofrange;
1509 }
1510
11a2be4d 1511 if (output_bfd != NULL)
8a397dad 1512 {
1049f94e 1513 relocatable = TRUE;
8a397dad
TS
1514 gp = _bfd_get_gp_value (output_bfd);
1515 }
1516 else
1517 {
1049f94e 1518 relocatable = FALSE;
8a397dad
TS
1519 output_bfd = symbol->section->output_section->owner;
1520
1049f94e 1521 ret = mips_elf_final_gp (output_bfd, symbol, relocatable,
8a397dad
TS
1522 error_message, &gp);
1523 if (ret != bfd_reloc_ok)
1524 return ret;
1525 }
1526
1527 return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
1049f94e 1528 relocatable, data, gp);
8a397dad
TS
1529}
1530
1531static bfd_reloc_status_type
11a2be4d
RS
1532gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
1533 asection *input_section, bfd_boolean relocatable,
1534 void *data, bfd_vma gp)
8a397dad
TS
1535{
1536 bfd_vma relocation;
1537 unsigned long val;
1538
1539 if (bfd_is_com_section (symbol->section))
1540 relocation = 0;
1541 else
1542 relocation = symbol->value;
1543
1544 relocation += symbol->section->output_section->vma;
1545 relocation += symbol->section->output_offset;
1546
07515404 1547 if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
8a397dad
TS
1548 return bfd_reloc_outofrange;
1549
1550 if (reloc_entry->howto->src_mask == 0)
1551 val = 0;
1552 else
1553 val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
1554
1555 /* Set val to the offset into the section or symbol. */
1556 val += reloc_entry->addend;
1557
1558 /* Adjust val for the final section location and GP value. If we
1049f94e 1559 are producing relocatable output, we don't want to do this for
8a397dad 1560 an external symbol. */
1049f94e 1561 if (! relocatable
8a397dad
TS
1562 || (symbol->flags & BSF_SECTION_SYM) != 0)
1563 val += relocation - gp;
1564
11a2be4d 1565 bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
8a397dad 1566
1049f94e 1567 if (relocatable)
8a397dad
TS
1568 reloc_entry->address += input_section->output_offset;
1569
1570 return bfd_reloc_ok;
1571}
1572
1573/* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
1574 the rest is at bits 6-10. The bitpos already got right by the howto. */
1575
1576static bfd_reloc_status_type
30ac9238
RS
1577mips_elf_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
1578 void *data, asection *input_section, bfd *output_bfd,
1579 char **error_message)
8a397dad 1580{
a7ebbfdf
TS
1581 if (reloc_entry->howto->partial_inplace)
1582 {
1583 reloc_entry->addend = ((reloc_entry->addend & 0x00007c0)
1584 | (reloc_entry->addend & 0x00000800) >> 9);
1585 }
8a397dad 1586
30ac9238
RS
1587 return _bfd_mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
1588 input_section, output_bfd,
1589 error_message);
8a397dad
TS
1590}
1591\f
1592/* Handle a mips16 jump. */
1593
1594static bfd_reloc_status_type
30ac9238
RS
1595mips16_jump_reloc (bfd *abfd ATTRIBUTE_UNUSED,
1596 arelent *reloc_entry ATTRIBUTE_UNUSED,
1597 asymbol *symbol ATTRIBUTE_UNUSED,
1598 void *data ATTRIBUTE_UNUSED,
1599 asection *input_section, bfd *output_bfd ATTRIBUTE_UNUSED,
11a2be4d 1600 char **error_message ATTRIBUTE_UNUSED)
8a397dad 1601{
b34976b6 1602 static bfd_boolean warned = FALSE;
8a397dad 1603
8a397dad
TS
1604 /* FIXME. */
1605 if (! warned)
1606 (*_bfd_error_handler)
1607 (_("Linking mips16 objects into %s format is not supported"),
1608 bfd_get_target (input_section->output_section->owner));
b34976b6 1609 warned = TRUE;
8a397dad
TS
1610
1611 return bfd_reloc_undefined;
1612}
1613
1614/* Handle a mips16 GP relative reloc. */
1615
1616static bfd_reloc_status_type
11a2be4d
RS
1617mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
1618 void *data, asection *input_section, bfd *output_bfd,
1619 char **error_message)
8a397dad 1620{
1049f94e 1621 bfd_boolean relocatable;
8a397dad 1622 bfd_reloc_status_type ret;
d6f16593 1623 bfd_byte *location;
8a397dad 1624 bfd_vma gp;
8a397dad 1625
7f05722e
MR
1626 /* If we're relocating, and this is an external symbol, we don't want
1627 to change anything. */
1628 if (output_bfd != NULL
1629 && (symbol->flags & BSF_SECTION_SYM) == 0
1630 && (symbol->flags & BSF_LOCAL) != 0)
1631 {
1632 reloc_entry->address += input_section->output_offset;
1633 return bfd_reloc_ok;
1634 }
1635
8a397dad 1636 if (output_bfd != NULL)
1049f94e 1637 relocatable = TRUE;
8a397dad
TS
1638 else
1639 {
1049f94e 1640 relocatable = FALSE;
8a397dad
TS
1641 output_bfd = symbol->section->output_section->owner;
1642 }
1643
1049f94e 1644 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
8a397dad
TS
1645 &gp);
1646 if (ret != bfd_reloc_ok)
1647 return ret;
1648
d6f16593
MR
1649 location = (bfd_byte *) data + reloc_entry->address;
1650 _bfd_mips16_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE,
1651 location);
1652 ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1653 input_section, relocatable,
1654 data, gp);
1655 _bfd_mips16_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
1656 location);
8a397dad 1657
d6f16593 1658 return ret;
8a397dad 1659}
8a397dad
TS
1660\f
1661/* A mapping from BFD reloc types to MIPS ELF reloc types. */
1662
1663struct elf_reloc_map {
1664 bfd_reloc_code_real_type bfd_val;
1665 enum elf_mips_reloc_type elf_val;
1666};
1667
1668static const struct elf_reloc_map mips_reloc_map[] =
1669{
1670 { BFD_RELOC_NONE, R_MIPS_NONE },
1671 { BFD_RELOC_16, R_MIPS_16 },
1672 { BFD_RELOC_32, R_MIPS_32 },
1673 /* There is no BFD reloc for R_MIPS_REL32. */
1674 { BFD_RELOC_CTOR, R_MIPS_32 },
1675 { BFD_RELOC_64, R_MIPS_64 },
0b25d3e6 1676 { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
8a397dad
TS
1677 { BFD_RELOC_HI16_S, R_MIPS_HI16 },
1678 { BFD_RELOC_LO16, R_MIPS_LO16 },
1679 { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
1680 { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
1681 { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
1682 { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
1683 { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
1684 { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
1685 { BFD_RELOC_MIPS_SHIFT5, R_MIPS_SHIFT5 },
1686 { BFD_RELOC_MIPS_SHIFT6, R_MIPS_SHIFT6 },
1687 { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
1688 { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
1689 { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
1690 { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
1691 { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
1692 { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
1693 { BFD_RELOC_MIPS_INSERT_A, R_MIPS_INSERT_A },
1694 { BFD_RELOC_MIPS_INSERT_B, R_MIPS_INSERT_B },
1695 { BFD_RELOC_MIPS_DELETE, R_MIPS_DELETE },
1696 { BFD_RELOC_MIPS_HIGHEST, R_MIPS_HIGHEST },
1697 { BFD_RELOC_MIPS_HIGHER, R_MIPS_HIGHER },
1698 { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
1699 { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
1700 { BFD_RELOC_MIPS_SCN_DISP, R_MIPS_SCN_DISP },
1701 { BFD_RELOC_MIPS_REL16, R_MIPS_REL16 },
1702 /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated. */
1703 { BFD_RELOC_MIPS_RELGOT, R_MIPS_RELGOT },
1704 { BFD_RELOC_MIPS_JALR, R_MIPS_JALR }
1705};
1706
d6f16593
MR
1707static const struct elf_reloc_map mips16_reloc_map[] =
1708{
1709 { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
1710 { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
1711 { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
1712 { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
1713};
1714
8a397dad
TS
1715/* Given a BFD reloc type, return a howto structure. */
1716
1717static reloc_howto_type *
11a2be4d
RS
1718bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
1719 bfd_reloc_code_real_type code)
8a397dad
TS
1720{
1721 unsigned int i;
1722 /* FIXME: We default to RELA here instead of choosing the right
1723 relocation variant. */
1724 reloc_howto_type *howto_table = elf_mips_howto_table_rela;
d6f16593 1725 reloc_howto_type *howto16_table = elf_mips16_howto_table_rela;
8a397dad
TS
1726
1727 for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
1728 i++)
1729 {
1730 if (mips_reloc_map[i].bfd_val == code)
1731 return &howto_table[(int) mips_reloc_map[i].elf_val];
1732 }
1733
d6f16593
MR
1734 for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
1735 i++)
1736 {
1737 if (mips16_reloc_map[i].bfd_val == code)
1738 return &howto16_table[(int) mips16_reloc_map[i].elf_val];
1739 }
1740
8a397dad
TS
1741 switch (code)
1742 {
8a397dad
TS
1743 case BFD_RELOC_VTABLE_INHERIT:
1744 return &elf_mips_gnu_vtinherit_howto;
1745 case BFD_RELOC_VTABLE_ENTRY:
1746 return &elf_mips_gnu_vtentry_howto;
d0c728db
TS
1747 case BFD_RELOC_16_PCREL_S2:
1748 return &elf_mips_gnu_rela16_s2;
8a397dad
TS
1749 default:
1750 bfd_set_error (bfd_error_bad_value);
1751 return NULL;
1752 }
1753}
1754
947216bf 1755/* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
8a397dad
TS
1756
1757static reloc_howto_type *
11a2be4d 1758mips_elf_n32_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p)
8a397dad
TS
1759{
1760 switch (r_type)
1761 {
8a397dad
TS
1762 case R_MIPS_GNU_VTINHERIT:
1763 return &elf_mips_gnu_vtinherit_howto;
1764 case R_MIPS_GNU_VTENTRY:
1765 return &elf_mips_gnu_vtentry_howto;
d0c728db
TS
1766 case R_MIPS_GNU_REL16_S2:
1767 if (rela_p)
1768 return &elf_mips_gnu_rela16_s2;
1769 else
1770 return &elf_mips_gnu_rel16_s2;
8a397dad 1771 default:
d6f16593
MR
1772 if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
1773 {
1774 if (rela_p)
1775 return &elf_mips16_howto_table_rela[r_type - R_MIPS16_min];
1776 else
1777 return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
1778 }
8a397dad
TS
1779 BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
1780 if (rela_p)
1781 return &elf_mips_howto_table_rela[r_type];
1782 else
1783 return &elf_mips_howto_table_rel[r_type];
1784 break;
1785 }
1786}
1787
947216bf 1788/* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
8a397dad
TS
1789
1790static void
11a2be4d 1791mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
8a397dad
TS
1792{
1793 unsigned int r_type;
1794
1795 r_type = ELF32_R_TYPE (dst->r_info);
b34976b6 1796 cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, FALSE);
8a397dad
TS
1797
1798 /* The addend for a GPREL16 or LITERAL relocation comes from the GP
1799 value for the object file. We get the addend now, rather than
1800 when we do the relocation, because the symbol manipulations done
1801 by the linker may cause us to lose track of the input BFD. */
1802 if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
1803 && (r_type == (unsigned int) R_MIPS_GPREL16
1804 || r_type == (unsigned int) R_MIPS_LITERAL))
1805 cache_ptr->addend = elf_gp (abfd);
1806}
1807
947216bf 1808/* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */
8a397dad
TS
1809
1810static void
11a2be4d
RS
1811mips_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
1812 arelent *cache_ptr, Elf_Internal_Rela *dst)
8a397dad
TS
1813{
1814 unsigned int r_type;
1815
1816 r_type = ELF32_R_TYPE (dst->r_info);
b34976b6 1817 cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, TRUE);
8a397dad
TS
1818 cache_ptr->addend = dst->r_addend;
1819}
1820\f
1821/* Determine whether a symbol is global for the purposes of splitting
1822 the symbol table into global symbols and local symbols. At least
1823 on Irix 5, this split must be between section symbols and all other
1824 symbols. On most ELF targets the split is between static symbols
1825 and externally visible symbols. */
1826
b34976b6 1827static bfd_boolean
11a2be4d 1828mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
8a397dad
TS
1829{
1830 if (SGI_COMPAT (abfd))
1831 return (sym->flags & BSF_SECTION_SYM) == 0;
1832 else
1833 return ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
1834 || bfd_is_und_section (bfd_get_section (sym))
1835 || bfd_is_com_section (bfd_get_section (sym)));
1836}
1837\f
1838/* Set the right machine number for a MIPS ELF file. */
1839
b34976b6 1840static bfd_boolean
11a2be4d 1841mips_elf_n32_object_p (bfd *abfd)
8a397dad
TS
1842{
1843 unsigned long mach;
1844
1845 /* Irix 5 and 6 are broken. Object file symbol tables are not always
1846 sorted correctly such that local symbols precede global symbols,
1847 and the sh_info field in the symbol table is not always right. */
1848 if (SGI_COMPAT (abfd))
b34976b6 1849 elf_bad_symtab (abfd) = TRUE;
8a397dad
TS
1850
1851 mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
1852 bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
1853
1854 if (! ABI_N32_P(abfd))
b34976b6 1855 return FALSE;
8a397dad 1856
b34976b6 1857 return TRUE;
8a397dad
TS
1858}
1859\f
1860/* Support for core dump NOTE sections. */
b34976b6 1861static bfd_boolean
11a2be4d 1862elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
8a397dad
TS
1863{
1864 int offset;
eea6121a 1865 unsigned int size;
8a397dad
TS
1866
1867 switch (note->descsz)
1868 {
1869 default:
b34976b6 1870 return FALSE;
8a397dad 1871
59a8c196 1872 case 440: /* Linux/MIPS N32 */
8a397dad
TS
1873 /* pr_cursig */
1874 elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
1875
1876 /* pr_pid */
1877 elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
1878
1879 /* pr_reg */
1880 offset = 72;
eea6121a 1881 size = 360;
8a397dad
TS
1882
1883 break;
1884 }
1885
1886 /* Make a ".reg/999" section. */
eea6121a 1887 return _bfd_elfcore_make_pseudosection (abfd, ".reg", size,
8a397dad
TS
1888 note->descpos + offset);
1889}
1890
b34976b6 1891static bfd_boolean
11a2be4d 1892elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
8a397dad
TS
1893{
1894 switch (note->descsz)
1895 {
1896 default:
b34976b6 1897 return FALSE;
8a397dad
TS
1898
1899 case 128: /* Linux/MIPS elf_prpsinfo */
1900 elf_tdata (abfd)->core_program
1901 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
1902 elf_tdata (abfd)->core_command
1903 = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
1904 }
1905
1906 /* Note that for some reason, a spurious space is tacked
1907 onto the end of the args in some (at least one anyway)
1908 implementations, so strip it off if it exists. */
1909
1910 {
1911 char *command = elf_tdata (abfd)->core_command;
1912 int n = strlen (command);
1913
1914 if (0 < n && command[n - 1] == ' ')
1915 command[n - 1] = '\0';
1916 }
1917
b34976b6 1918 return TRUE;
8a397dad
TS
1919}
1920\f
1921/* Depending on the target vector we generate some version of Irix
1922 executables or "normal" MIPS ELF ABI executables. */
1923static irix_compat_t
11a2be4d 1924elf_n32_mips_irix_compat (bfd *abfd)
8a397dad
TS
1925{
1926 if ((abfd->xvec == &bfd_elf32_nbigmips_vec)
1927 || (abfd->xvec == &bfd_elf32_nlittlemips_vec))
1928 return ict_irix6;
1929 else
1930 return ict_none;
1931}
1932\f
1933/* ECOFF swapping routines. These are used when dealing with the
1934 .mdebug section, which is in the ECOFF debugging format. */
1935static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
1936 /* Symbol table magic number. */
1937 magicSym,
1938 /* Alignment of debugging information. E.g., 4. */
1939 4,
1940 /* Sizes of external symbolic information. */
1941 sizeof (struct hdr_ext),
1942 sizeof (struct dnr_ext),
1943 sizeof (struct pdr_ext),
1944 sizeof (struct sym_ext),
1945 sizeof (struct opt_ext),
1946 sizeof (struct fdr_ext),
1947 sizeof (struct rfd_ext),
1948 sizeof (struct ext_ext),
1949 /* Functions to swap in external symbolic data. */
1950 ecoff_swap_hdr_in,
1951 ecoff_swap_dnr_in,
1952 ecoff_swap_pdr_in,
1953 ecoff_swap_sym_in,
1954 ecoff_swap_opt_in,
1955 ecoff_swap_fdr_in,
1956 ecoff_swap_rfd_in,
1957 ecoff_swap_ext_in,
1958 _bfd_ecoff_swap_tir_in,
1959 _bfd_ecoff_swap_rndx_in,
1960 /* Functions to swap out external symbolic data. */
1961 ecoff_swap_hdr_out,
1962 ecoff_swap_dnr_out,
1963 ecoff_swap_pdr_out,
1964 ecoff_swap_sym_out,
1965 ecoff_swap_opt_out,
1966 ecoff_swap_fdr_out,
1967 ecoff_swap_rfd_out,
1968 ecoff_swap_ext_out,
1969 _bfd_ecoff_swap_tir_out,
1970 _bfd_ecoff_swap_rndx_out,
1971 /* Function to read in symbolic data. */
1972 _bfd_mips_elf_read_ecoff_info
1973};
1974\f
1975#define ELF_ARCH bfd_arch_mips
1976#define ELF_MACHINE_CODE EM_MIPS
1977
b34976b6
AM
1978#define elf_backend_collect TRUE
1979#define elf_backend_type_change_ok TRUE
1980#define elf_backend_can_gc_sections TRUE
8a397dad
TS
1981#define elf_info_to_howto mips_info_to_howto_rela
1982#define elf_info_to_howto_rel mips_info_to_howto_rel
1983#define elf_backend_sym_is_global mips_elf_sym_is_global
1984#define elf_backend_object_p mips_elf_n32_object_p
1985#define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
1986#define elf_backend_section_processing _bfd_mips_elf_section_processing
1987#define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
1988#define elf_backend_fake_sections _bfd_mips_elf_fake_sections
1989#define elf_backend_section_from_bfd_section \
1990 _bfd_mips_elf_section_from_bfd_section
1991#define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
1992#define elf_backend_link_output_symbol_hook \
1993 _bfd_mips_elf_link_output_symbol_hook
1994#define elf_backend_create_dynamic_sections \
1995 _bfd_mips_elf_create_dynamic_sections
1996#define elf_backend_check_relocs _bfd_mips_elf_check_relocs
1997#define elf_backend_adjust_dynamic_symbol \
1998 _bfd_mips_elf_adjust_dynamic_symbol
1999#define elf_backend_always_size_sections \
2000 _bfd_mips_elf_always_size_sections
2001#define elf_backend_size_dynamic_sections \
2002 _bfd_mips_elf_size_dynamic_sections
2003#define elf_backend_relocate_section _bfd_mips_elf_relocate_section
2004#define elf_backend_finish_dynamic_symbol \
2005 _bfd_mips_elf_finish_dynamic_symbol
2006#define elf_backend_finish_dynamic_sections \
2007 _bfd_mips_elf_finish_dynamic_sections
2008#define elf_backend_final_write_processing \
2009 _bfd_mips_elf_final_write_processing
2010#define elf_backend_additional_program_headers \
2011 _bfd_mips_elf_additional_program_headers
2012#define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
2013#define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
2014#define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
2015#define elf_backend_copy_indirect_symbol \
2016 _bfd_mips_elf_copy_indirect_symbol
2017#define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
2018#define elf_backend_grok_prstatus elf32_mips_grok_prstatus
2019#define elf_backend_grok_psinfo elf32_mips_grok_psinfo
2020#define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
2021
2022#define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
8a397dad
TS
2023
2024/* MIPS n32 ELF can use a mixture of REL and RELA, but some Relocations
2025 work better/work only in RELA, so we default to this. */
2026#define elf_backend_may_use_rel_p 1
2027#define elf_backend_may_use_rela_p 1
2028#define elf_backend_default_use_rela_p 1
b34976b6 2029#define elf_backend_sign_extend_vma TRUE
8a397dad
TS
2030
2031#define elf_backend_discard_info _bfd_mips_elf_discard_info
2032#define elf_backend_ignore_discarded_relocs \
2033 _bfd_mips_elf_ignore_discarded_relocs
2034#define elf_backend_write_section _bfd_mips_elf_write_section
2035#define elf_backend_mips_irix_compat elf_n32_mips_irix_compat
2036#define elf_backend_mips_rtype_to_howto mips_elf_n32_rtype_to_howto
2037#define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
f0abc2a1 2038#define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook
8a397dad
TS
2039#define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
2040#define bfd_elf32_bfd_get_relocated_section_contents \
2041 _bfd_elf_mips_get_relocated_section_contents
2042#define bfd_elf32_bfd_link_hash_table_create \
2043 _bfd_mips_elf_link_hash_table_create
2044#define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
2045#define bfd_elf32_bfd_merge_private_bfd_data \
2046 _bfd_mips_elf_merge_private_bfd_data
2047#define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
2048#define bfd_elf32_bfd_print_private_bfd_data \
2049 _bfd_mips_elf_print_private_bfd_data
d0647110 2050#define bfd_elf32_bfd_relax_section _bfd_mips_relax_section
8a397dad
TS
2051
2052/* Support for SGI-ish mips targets using n32 ABI. */
2053
2054#define TARGET_LITTLE_SYM bfd_elf32_nlittlemips_vec
2055#define TARGET_LITTLE_NAME "elf32-nlittlemips"
2056#define TARGET_BIG_SYM bfd_elf32_nbigmips_vec
2057#define TARGET_BIG_NAME "elf32-nbigmips"
2058
4301eeb1
MR
2059/* The SVR4 MIPS ABI says that this should be 0x10000, but Irix 5 uses
2060 a value of 0x1000, and we are compatible.
2061 FIXME: How does this affect NewABI? */
2062#define ELF_MAXPAGESIZE 0x1000
2063
8a397dad
TS
2064#include "elf32-target.h"
2065
2066/* Support for traditional mips targets using n32 ABI. */
8a397dad
TS
2067#undef TARGET_LITTLE_SYM
2068#undef TARGET_LITTLE_NAME
2069#undef TARGET_BIG_SYM
2070#undef TARGET_BIG_NAME
2071
4301eeb1
MR
2072#undef ELF_MAXPAGESIZE
2073
8a397dad
TS
2074#define TARGET_LITTLE_SYM bfd_elf32_ntradlittlemips_vec
2075#define TARGET_LITTLE_NAME "elf32-ntradlittlemips"
2076#define TARGET_BIG_SYM bfd_elf32_ntradbigmips_vec
2077#define TARGET_BIG_NAME "elf32-ntradbigmips"
2078
4301eeb1
MR
2079/* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses
2080 page sizes of up to that limit, so we need to respect it. */
2081#define ELF_MAXPAGESIZE 0x10000
2082#define elf32_bed elf32_tradbed
2083
8a397dad
TS
2084/* Include the target file again for this target. */
2085#include "elf32-target.h"
This page took 0.271209 seconds and 4 git commands to generate.