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