Commit | Line | Data |
---|---|---|
efcbd82c | 1 | /* MIPS-specific support for 32-bit ELF |
4b95cf5c | 2 | Copyright (C) 1993-2014 Free Software Foundation, Inc. |
252b5132 RH |
3 | |
4 | Most of the information added by Ian Lance Taylor, Cygnus Support, | |
5 | <ian@cygnus.com>. | |
103186c6 MM |
6 | N32/64 ABI support added by Mark Mitchell, CodeSourcery, LLC. |
7 | <mark@codesourcery.com> | |
f7cb7d68 UC |
8 | Traditional MIPS targets support added by Koundinya.K, Dansk Data |
9 | Elektronik & Operations Research Group. <kk@ddeorg.soft.net> | |
252b5132 | 10 | |
cd123cb7 | 11 | This file is part of BFD, the Binary File Descriptor library. |
252b5132 | 12 | |
cd123cb7 NC |
13 | This program is free software; you can redistribute it and/or modify |
14 | it under the terms of the GNU General Public License as published by | |
15 | the Free Software Foundation; either version 3 of the License, or | |
16 | (at your option) any later version. | |
252b5132 | 17 | |
cd123cb7 NC |
18 | This program is distributed in the hope that it will be useful, |
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | GNU General Public License for more details. | |
22 | ||
23 | You should have received a copy of the GNU General Public License | |
24 | along with this program; if not, write to the Free Software | |
25 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
26 | MA 02110-1301, USA. */ | |
252b5132 | 27 | |
252b5132 RH |
28 | |
29 | /* This file handles MIPS ELF targets. SGI Irix 5 uses a slightly | |
30 | different MIPS ELF from other targets. This matters when linking. | |
31 | This file supports both, switching at runtime. */ | |
32 | ||
252b5132 | 33 | #include "sysdep.h" |
3db64b00 | 34 | #include "bfd.h" |
252b5132 RH |
35 | #include "libbfd.h" |
36 | #include "bfdlink.h" | |
37 | #include "genlink.h" | |
38 | #include "elf-bfd.h" | |
c6e90b02 | 39 | #include "elfxx-mips.h" |
252b5132 | 40 | #include "elf/mips.h" |
0a44bf69 | 41 | #include "elf-vxworks.h" |
252b5132 RH |
42 | |
43 | /* Get the ECOFF swapping routines. */ | |
44 | #include "coff/sym.h" | |
45 | #include "coff/symconst.h" | |
46 | #include "coff/internal.h" | |
47 | #include "coff/ecoff.h" | |
48 | #include "coff/mips.h" | |
23e2c83b | 49 | #define ECOFF_SIGNED_32 |
252b5132 RH |
50 | #include "ecoffswap.h" |
51 | ||
a7ebbfdf | 52 | static bfd_reloc_status_type gprel32_with_gp |
11a2be4d | 53 | (bfd *, asymbol *, arelent *, asection *, bfd_boolean, void *, bfd_vma); |
c6e90b02 | 54 | static bfd_reloc_status_type mips_elf_gprel32_reloc |
11a2be4d | 55 | (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
252b5132 | 56 | static bfd_reloc_status_type mips32_64bit_reloc |
11a2be4d | 57 | (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
252b5132 | 58 | static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup |
11a2be4d | 59 | (bfd *, bfd_reloc_code_real_type); |
c6e90b02 | 60 | static reloc_howto_type *mips_elf32_rtype_to_howto |
11a2be4d | 61 | (unsigned int, bfd_boolean); |
252b5132 | 62 | static void mips_info_to_howto_rel |
11a2be4d | 63 | (bfd *, arelent *, Elf_Internal_Rela *); |
3f830999 | 64 | static void mips_info_to_howto_rela |
11a2be4d | 65 | (bfd *, arelent *, Elf_Internal_Rela *); |
b34976b6 | 66 | static bfd_boolean mips_elf_sym_is_global |
11a2be4d | 67 | (bfd *, asymbol *); |
b34976b6 | 68 | static bfd_boolean mips_elf32_object_p |
11a2be4d | 69 | (bfd *); |
b34976b6 | 70 | static bfd_boolean mips_elf_is_local_label_name |
11a2be4d | 71 | (bfd *, const char *); |
252b5132 | 72 | static bfd_reloc_status_type mips16_gprel_reloc |
11a2be4d | 73 | (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
252b5132 | 74 | static bfd_reloc_status_type mips_elf_final_gp |
11a2be4d | 75 | (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *); |
b34976b6 | 76 | static bfd_boolean mips_elf_assign_gp |
11a2be4d | 77 | (bfd *, bfd_vma *); |
b34976b6 | 78 | static bfd_boolean elf32_mips_grok_prstatus |
11a2be4d | 79 | (bfd *, Elf_Internal_Note *); |
b34976b6 | 80 | static bfd_boolean elf32_mips_grok_psinfo |
11a2be4d | 81 | (bfd *, Elf_Internal_Note *); |
c6e90b02 | 82 | static irix_compat_t elf32_mips_irix_compat |
11a2be4d | 83 | (bfd *); |
252b5132 | 84 | |
cb7394f2 TS |
85 | extern const bfd_target bfd_elf32_bigmips_vec; |
86 | extern const bfd_target bfd_elf32_littlemips_vec; | |
adb76a3e | 87 | |
a94a7c1c | 88 | /* Nonzero if ABFD is using the N32 ABI. */ |
a94a7c1c MM |
89 | #define ABI_N32_P(abfd) \ |
90 | ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0) | |
91 | ||
4e8a9624 | 92 | /* Whether we are trying to be compatible with IRIX at all. */ |
a94a7c1c | 93 | #define SGI_COMPAT(abfd) \ |
c6e90b02 | 94 | (elf32_mips_irix_compat (abfd) != ict_none) |
103186c6 | 95 | |
252b5132 RH |
96 | /* The number of local .got entries we reserve. */ |
97 | #define MIPS_RESERVED_GOTNO (2) | |
98 | ||
3f830999 MM |
99 | /* In case we're on a 32-bit machine, construct a 64-bit "-1" value |
100 | from smaller values. Start with zero, widen, *then* decrement. */ | |
101 | #define MINUS_ONE (((bfd_vma)0) - 1) | |
102 | ||
d75bc93d TS |
103 | /* The relocation table used for SHT_REL sections. */ |
104 | ||
105 | static reloc_howto_type elf_mips_howto_table_rel[] = | |
106 | { | |
107 | /* No relocation. */ | |
108 | HOWTO (R_MIPS_NONE, /* type */ | |
109 | 0, /* rightshift */ | |
110 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
111 | 0, /* bitsize */ | |
b34976b6 | 112 | FALSE, /* pc_relative */ |
d75bc93d TS |
113 | 0, /* bitpos */ |
114 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 115 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 116 | "R_MIPS_NONE", /* name */ |
b34976b6 | 117 | FALSE, /* partial_inplace */ |
d75bc93d TS |
118 | 0, /* src_mask */ |
119 | 0, /* dst_mask */ | |
b34976b6 | 120 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
121 | |
122 | /* 16 bit relocation. */ | |
123 | HOWTO (R_MIPS_16, /* type */ | |
124 | 0, /* rightshift */ | |
125 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
126 | 16, /* bitsize */ | |
b34976b6 | 127 | FALSE, /* pc_relative */ |
d75bc93d TS |
128 | 0, /* bitpos */ |
129 | complain_overflow_signed, /* complain_on_overflow */ | |
30ac9238 | 130 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 131 | "R_MIPS_16", /* name */ |
b34976b6 | 132 | TRUE, /* partial_inplace */ |
d75bc93d TS |
133 | 0x0000ffff, /* src_mask */ |
134 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 135 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
136 | |
137 | /* 32 bit relocation. */ | |
138 | HOWTO (R_MIPS_32, /* type */ | |
139 | 0, /* rightshift */ | |
140 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
141 | 32, /* bitsize */ | |
b34976b6 | 142 | FALSE, /* pc_relative */ |
d75bc93d TS |
143 | 0, /* bitpos */ |
144 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 145 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 146 | "R_MIPS_32", /* name */ |
b34976b6 | 147 | TRUE, /* partial_inplace */ |
d75bc93d TS |
148 | 0xffffffff, /* src_mask */ |
149 | 0xffffffff, /* dst_mask */ | |
b34976b6 | 150 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
151 | |
152 | /* 32 bit symbol relative relocation. */ | |
153 | HOWTO (R_MIPS_REL32, /* type */ | |
154 | 0, /* rightshift */ | |
155 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
156 | 32, /* bitsize */ | |
b34976b6 | 157 | FALSE, /* pc_relative */ |
d75bc93d TS |
158 | 0, /* bitpos */ |
159 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 160 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 161 | "R_MIPS_REL32", /* name */ |
b34976b6 | 162 | TRUE, /* partial_inplace */ |
d75bc93d TS |
163 | 0xffffffff, /* src_mask */ |
164 | 0xffffffff, /* dst_mask */ | |
b34976b6 | 165 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
166 | |
167 | /* 26 bit jump address. */ | |
168 | HOWTO (R_MIPS_26, /* type */ | |
169 | 2, /* rightshift */ | |
170 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
171 | 26, /* bitsize */ | |
b34976b6 | 172 | FALSE, /* pc_relative */ |
d75bc93d TS |
173 | 0, /* bitpos */ |
174 | complain_overflow_dont, /* complain_on_overflow */ | |
175 | /* This needs complex overflow | |
176 | detection, because the upper four | |
177 | bits must match the PC + 4. */ | |
30ac9238 | 178 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 179 | "R_MIPS_26", /* name */ |
b34976b6 | 180 | TRUE, /* partial_inplace */ |
d75bc93d TS |
181 | 0x03ffffff, /* src_mask */ |
182 | 0x03ffffff, /* dst_mask */ | |
b34976b6 | 183 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
184 | |
185 | /* High 16 bits of symbol value. */ | |
186 | HOWTO (R_MIPS_HI16, /* type */ | |
30ac9238 | 187 | 16, /* rightshift */ |
d75bc93d TS |
188 | 2, /* size (0 = byte, 1 = short, 2 = long) */ |
189 | 16, /* bitsize */ | |
b34976b6 | 190 | FALSE, /* pc_relative */ |
d75bc93d TS |
191 | 0, /* bitpos */ |
192 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 193 | _bfd_mips_elf_hi16_reloc, /* special_function */ |
d75bc93d | 194 | "R_MIPS_HI16", /* name */ |
b34976b6 | 195 | TRUE, /* partial_inplace */ |
d75bc93d TS |
196 | 0x0000ffff, /* src_mask */ |
197 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 198 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
199 | |
200 | /* Low 16 bits of symbol value. */ | |
201 | HOWTO (R_MIPS_LO16, /* type */ | |
202 | 0, /* rightshift */ | |
203 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
204 | 16, /* bitsize */ | |
b34976b6 | 205 | FALSE, /* pc_relative */ |
d75bc93d TS |
206 | 0, /* bitpos */ |
207 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 208 | _bfd_mips_elf_lo16_reloc, /* special_function */ |
d75bc93d | 209 | "R_MIPS_LO16", /* name */ |
b34976b6 | 210 | TRUE, /* partial_inplace */ |
d75bc93d TS |
211 | 0x0000ffff, /* src_mask */ |
212 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 213 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
214 | |
215 | /* GP relative reference. */ | |
216 | HOWTO (R_MIPS_GPREL16, /* type */ | |
217 | 0, /* rightshift */ | |
218 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
219 | 16, /* bitsize */ | |
b34976b6 | 220 | FALSE, /* pc_relative */ |
d75bc93d TS |
221 | 0, /* bitpos */ |
222 | complain_overflow_signed, /* complain_on_overflow */ | |
c6e90b02 | 223 | _bfd_mips_elf32_gprel16_reloc, /* special_function */ |
d75bc93d | 224 | "R_MIPS_GPREL16", /* name */ |
b34976b6 | 225 | TRUE, /* partial_inplace */ |
d75bc93d TS |
226 | 0x0000ffff, /* src_mask */ |
227 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 228 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
229 | |
230 | /* Reference to literal section. */ | |
231 | HOWTO (R_MIPS_LITERAL, /* type */ | |
232 | 0, /* rightshift */ | |
233 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
234 | 16, /* bitsize */ | |
b34976b6 | 235 | FALSE, /* pc_relative */ |
d75bc93d TS |
236 | 0, /* bitpos */ |
237 | complain_overflow_signed, /* complain_on_overflow */ | |
c6e90b02 | 238 | _bfd_mips_elf32_gprel16_reloc, /* special_function */ |
d75bc93d | 239 | "R_MIPS_LITERAL", /* name */ |
b34976b6 | 240 | TRUE, /* partial_inplace */ |
d75bc93d TS |
241 | 0x0000ffff, /* src_mask */ |
242 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 243 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
244 | |
245 | /* Reference to global offset table. */ | |
246 | HOWTO (R_MIPS_GOT16, /* type */ | |
247 | 0, /* rightshift */ | |
248 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
249 | 16, /* bitsize */ | |
b34976b6 | 250 | FALSE, /* pc_relative */ |
d75bc93d TS |
251 | 0, /* bitpos */ |
252 | complain_overflow_signed, /* complain_on_overflow */ | |
30ac9238 | 253 | _bfd_mips_elf_got16_reloc, /* special_function */ |
d75bc93d | 254 | "R_MIPS_GOT16", /* name */ |
b34976b6 | 255 | TRUE, /* partial_inplace */ |
d75bc93d TS |
256 | 0x0000ffff, /* src_mask */ |
257 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 258 | FALSE), /* pcrel_offset */ |
d75bc93d | 259 | |
bad36eac DJ |
260 | /* 16 bit PC relative reference. Note that the ABI document has a typo |
261 | and claims R_MIPS_PC16 to be not rightshifted, rendering it useless. | |
262 | We do the right thing here. */ | |
d75bc93d | 263 | HOWTO (R_MIPS_PC16, /* type */ |
bad36eac | 264 | 2, /* rightshift */ |
d75bc93d TS |
265 | 2, /* size (0 = byte, 1 = short, 2 = long) */ |
266 | 16, /* bitsize */ | |
b34976b6 | 267 | TRUE, /* pc_relative */ |
d75bc93d TS |
268 | 0, /* bitpos */ |
269 | complain_overflow_signed, /* complain_on_overflow */ | |
30ac9238 | 270 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 271 | "R_MIPS_PC16", /* name */ |
b34976b6 | 272 | TRUE, /* partial_inplace */ |
d75bc93d TS |
273 | 0x0000ffff, /* src_mask */ |
274 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 275 | TRUE), /* pcrel_offset */ |
d75bc93d TS |
276 | |
277 | /* 16 bit call through global offset table. */ | |
278 | HOWTO (R_MIPS_CALL16, /* type */ | |
279 | 0, /* rightshift */ | |
280 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
281 | 16, /* bitsize */ | |
b34976b6 | 282 | FALSE, /* pc_relative */ |
d75bc93d TS |
283 | 0, /* bitpos */ |
284 | complain_overflow_signed, /* complain_on_overflow */ | |
30ac9238 | 285 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 286 | "R_MIPS_CALL16", /* name */ |
b34976b6 | 287 | TRUE, /* partial_inplace */ |
d75bc93d TS |
288 | 0x0000ffff, /* src_mask */ |
289 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 290 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
291 | |
292 | /* 32 bit GP relative reference. */ | |
293 | HOWTO (R_MIPS_GPREL32, /* type */ | |
294 | 0, /* rightshift */ | |
295 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
296 | 32, /* bitsize */ | |
b34976b6 | 297 | FALSE, /* pc_relative */ |
d75bc93d TS |
298 | 0, /* bitpos */ |
299 | complain_overflow_dont, /* complain_on_overflow */ | |
c6e90b02 | 300 | mips_elf_gprel32_reloc, /* special_function */ |
d75bc93d | 301 | "R_MIPS_GPREL32", /* name */ |
b34976b6 | 302 | TRUE, /* partial_inplace */ |
d75bc93d TS |
303 | 0xffffffff, /* src_mask */ |
304 | 0xffffffff, /* dst_mask */ | |
b34976b6 | 305 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
306 | |
307 | /* The remaining relocs are defined on Irix 5, although they are | |
308 | not defined by the ABI. */ | |
309 | EMPTY_HOWTO (13), | |
310 | EMPTY_HOWTO (14), | |
311 | EMPTY_HOWTO (15), | |
312 | ||
313 | /* A 5 bit shift field. */ | |
314 | HOWTO (R_MIPS_SHIFT5, /* type */ | |
315 | 0, /* rightshift */ | |
316 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
317 | 5, /* bitsize */ | |
b34976b6 | 318 | FALSE, /* pc_relative */ |
d75bc93d TS |
319 | 6, /* bitpos */ |
320 | complain_overflow_bitfield, /* complain_on_overflow */ | |
30ac9238 | 321 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 322 | "R_MIPS_SHIFT5", /* name */ |
b34976b6 | 323 | TRUE, /* partial_inplace */ |
d75bc93d TS |
324 | 0x000007c0, /* src_mask */ |
325 | 0x000007c0, /* dst_mask */ | |
b34976b6 | 326 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
327 | |
328 | /* A 6 bit shift field. */ | |
329 | /* FIXME: This is not handled correctly; a special function is | |
330 | needed to put the most significant bit in the right place. */ | |
331 | HOWTO (R_MIPS_SHIFT6, /* type */ | |
332 | 0, /* rightshift */ | |
333 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
334 | 6, /* bitsize */ | |
b34976b6 | 335 | FALSE, /* pc_relative */ |
d75bc93d TS |
336 | 6, /* bitpos */ |
337 | complain_overflow_bitfield, /* complain_on_overflow */ | |
30ac9238 | 338 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 339 | "R_MIPS_SHIFT6", /* name */ |
b34976b6 | 340 | TRUE, /* partial_inplace */ |
d75bc93d TS |
341 | 0x000007c4, /* src_mask */ |
342 | 0x000007c4, /* dst_mask */ | |
b34976b6 | 343 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
344 | |
345 | /* A 64 bit relocation. */ | |
346 | HOWTO (R_MIPS_64, /* type */ | |
347 | 0, /* rightshift */ | |
348 | 4, /* size (0 = byte, 1 = short, 2 = long) */ | |
349 | 64, /* bitsize */ | |
b34976b6 | 350 | FALSE, /* pc_relative */ |
d75bc93d TS |
351 | 0, /* bitpos */ |
352 | complain_overflow_dont, /* complain_on_overflow */ | |
353 | mips32_64bit_reloc, /* special_function */ | |
354 | "R_MIPS_64", /* name */ | |
b34976b6 | 355 | TRUE, /* partial_inplace */ |
d75bc93d TS |
356 | MINUS_ONE, /* src_mask */ |
357 | MINUS_ONE, /* dst_mask */ | |
b34976b6 | 358 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
359 | |
360 | /* Displacement in the global offset table. */ | |
361 | HOWTO (R_MIPS_GOT_DISP, /* type */ | |
362 | 0, /* rightshift */ | |
363 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
364 | 16, /* bitsize */ | |
b34976b6 | 365 | FALSE, /* pc_relative */ |
d75bc93d TS |
366 | 0, /* bitpos */ |
367 | complain_overflow_signed, /* complain_on_overflow */ | |
30ac9238 | 368 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 369 | "R_MIPS_GOT_DISP", /* name */ |
b34976b6 | 370 | TRUE, /* partial_inplace */ |
d75bc93d TS |
371 | 0x0000ffff, /* src_mask */ |
372 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 373 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
374 | |
375 | /* Displacement to page pointer in the global offset table. */ | |
376 | HOWTO (R_MIPS_GOT_PAGE, /* type */ | |
377 | 0, /* rightshift */ | |
378 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
379 | 16, /* bitsize */ | |
b34976b6 | 380 | FALSE, /* pc_relative */ |
d75bc93d TS |
381 | 0, /* bitpos */ |
382 | complain_overflow_signed, /* complain_on_overflow */ | |
30ac9238 | 383 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 384 | "R_MIPS_GOT_PAGE", /* name */ |
b34976b6 | 385 | TRUE, /* partial_inplace */ |
d75bc93d TS |
386 | 0x0000ffff, /* src_mask */ |
387 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 388 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
389 | |
390 | /* Offset from page pointer in the global offset table. */ | |
391 | HOWTO (R_MIPS_GOT_OFST, /* type */ | |
392 | 0, /* rightshift */ | |
393 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
394 | 16, /* bitsize */ | |
b34976b6 | 395 | FALSE, /* pc_relative */ |
d75bc93d TS |
396 | 0, /* bitpos */ |
397 | complain_overflow_signed, /* complain_on_overflow */ | |
30ac9238 | 398 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 399 | "R_MIPS_GOT_OFST", /* name */ |
b34976b6 | 400 | TRUE, /* partial_inplace */ |
d75bc93d TS |
401 | 0x0000ffff, /* src_mask */ |
402 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 403 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
404 | |
405 | /* High 16 bits of displacement in global offset table. */ | |
406 | HOWTO (R_MIPS_GOT_HI16, /* type */ | |
407 | 0, /* rightshift */ | |
408 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
409 | 16, /* bitsize */ | |
b34976b6 | 410 | FALSE, /* pc_relative */ |
d75bc93d TS |
411 | 0, /* bitpos */ |
412 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 413 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 414 | "R_MIPS_GOT_HI16", /* name */ |
b34976b6 | 415 | TRUE, /* partial_inplace */ |
d75bc93d TS |
416 | 0x0000ffff, /* src_mask */ |
417 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 418 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
419 | |
420 | /* Low 16 bits of displacement in global offset table. */ | |
421 | HOWTO (R_MIPS_GOT_LO16, /* type */ | |
422 | 0, /* rightshift */ | |
423 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
424 | 16, /* bitsize */ | |
b34976b6 | 425 | FALSE, /* pc_relative */ |
d75bc93d TS |
426 | 0, /* bitpos */ |
427 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 428 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 429 | "R_MIPS_GOT_LO16", /* name */ |
b34976b6 | 430 | TRUE, /* partial_inplace */ |
d75bc93d TS |
431 | 0x0000ffff, /* src_mask */ |
432 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 433 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
434 | |
435 | /* 64 bit subtraction. Used in the N32 ABI. */ | |
436 | HOWTO (R_MIPS_SUB, /* type */ | |
437 | 0, /* rightshift */ | |
438 | 4, /* size (0 = byte, 1 = short, 2 = long) */ | |
439 | 64, /* bitsize */ | |
b34976b6 | 440 | FALSE, /* pc_relative */ |
d75bc93d TS |
441 | 0, /* bitpos */ |
442 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 443 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 444 | "R_MIPS_SUB", /* name */ |
b34976b6 | 445 | TRUE, /* partial_inplace */ |
d75bc93d TS |
446 | MINUS_ONE, /* src_mask */ |
447 | MINUS_ONE, /* dst_mask */ | |
b34976b6 | 448 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
449 | |
450 | /* Used to cause the linker to insert and delete instructions? */ | |
451 | EMPTY_HOWTO (R_MIPS_INSERT_A), | |
452 | EMPTY_HOWTO (R_MIPS_INSERT_B), | |
453 | EMPTY_HOWTO (R_MIPS_DELETE), | |
454 | ||
455 | /* Get the higher value of a 64 bit addend. */ | |
456 | HOWTO (R_MIPS_HIGHER, /* type */ | |
457 | 0, /* rightshift */ | |
458 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
459 | 16, /* bitsize */ | |
b34976b6 | 460 | FALSE, /* pc_relative */ |
d75bc93d TS |
461 | 0, /* bitpos */ |
462 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 463 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 464 | "R_MIPS_HIGHER", /* name */ |
b34976b6 | 465 | TRUE, /* partial_inplace */ |
d75bc93d TS |
466 | 0x0000ffff, /* src_mask */ |
467 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 468 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
469 | |
470 | /* Get the highest value of a 64 bit addend. */ | |
471 | HOWTO (R_MIPS_HIGHEST, /* type */ | |
472 | 0, /* rightshift */ | |
473 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
474 | 16, /* bitsize */ | |
b34976b6 | 475 | FALSE, /* pc_relative */ |
d75bc93d TS |
476 | 0, /* bitpos */ |
477 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 478 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 479 | "R_MIPS_HIGHEST", /* name */ |
b34976b6 | 480 | TRUE, /* partial_inplace */ |
d75bc93d TS |
481 | 0x0000ffff, /* src_mask */ |
482 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 483 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
484 | |
485 | /* High 16 bits of displacement in global offset table. */ | |
486 | HOWTO (R_MIPS_CALL_HI16, /* type */ | |
487 | 0, /* rightshift */ | |
488 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
489 | 16, /* bitsize */ | |
b34976b6 | 490 | FALSE, /* pc_relative */ |
d75bc93d TS |
491 | 0, /* bitpos */ |
492 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 493 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 494 | "R_MIPS_CALL_HI16", /* name */ |
b34976b6 | 495 | TRUE, /* partial_inplace */ |
d75bc93d TS |
496 | 0x0000ffff, /* src_mask */ |
497 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 498 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
499 | |
500 | /* Low 16 bits of displacement in global offset table. */ | |
501 | HOWTO (R_MIPS_CALL_LO16, /* type */ | |
502 | 0, /* rightshift */ | |
503 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
504 | 16, /* bitsize */ | |
b34976b6 | 505 | FALSE, /* pc_relative */ |
d75bc93d TS |
506 | 0, /* bitpos */ |
507 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 508 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 509 | "R_MIPS_CALL_LO16", /* name */ |
b34976b6 | 510 | TRUE, /* partial_inplace */ |
d75bc93d TS |
511 | 0x0000ffff, /* src_mask */ |
512 | 0x0000ffff, /* dst_mask */ | |
b34976b6 | 513 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
514 | |
515 | /* Section displacement. */ | |
516 | HOWTO (R_MIPS_SCN_DISP, /* type */ | |
517 | 0, /* rightshift */ | |
518 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
519 | 32, /* bitsize */ | |
b34976b6 | 520 | FALSE, /* pc_relative */ |
d75bc93d TS |
521 | 0, /* bitpos */ |
522 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 523 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 524 | "R_MIPS_SCN_DISP", /* name */ |
b34976b6 | 525 | TRUE, /* partial_inplace */ |
d75bc93d TS |
526 | 0xffffffff, /* src_mask */ |
527 | 0xffffffff, /* dst_mask */ | |
b34976b6 | 528 | FALSE), /* pcrel_offset */ |
d75bc93d TS |
529 | |
530 | EMPTY_HOWTO (R_MIPS_REL16), | |
531 | EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE), | |
532 | EMPTY_HOWTO (R_MIPS_PJUMP), | |
533 | EMPTY_HOWTO (R_MIPS_RELGOT), | |
534 | ||
535 | /* Protected jump conversion. This is an optimization hint. No | |
536 | relocation is required for correctness. */ | |
537 | HOWTO (R_MIPS_JALR, /* type */ | |
538 | 0, /* rightshift */ | |
539 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
540 | 32, /* bitsize */ | |
b34976b6 | 541 | FALSE, /* pc_relative */ |
d75bc93d TS |
542 | 0, /* bitpos */ |
543 | complain_overflow_dont, /* complain_on_overflow */ | |
30ac9238 | 544 | _bfd_mips_elf_generic_reloc, /* special_function */ |
d75bc93d | 545 | "R_MIPS_JALR", /* name */ |
b34976b6 | 546 | FALSE, /* partial_inplace */ |
d75bc93d TS |
547 | 0x00000000, /* src_mask */ |
548 | 0x00000000, /* dst_mask */ | |
b34976b6 | 549 | FALSE), /* pcrel_offset */ |
0f20cc35 DJ |
550 | |
551 | /* TLS GD/LD dynamic relocations. */ | |
552 | HOWTO (R_MIPS_TLS_DTPMOD32, /* type */ | |
553 | 0, /* rightshift */ | |
554 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
555 | 32, /* bitsize */ | |
556 | FALSE, /* pc_relative */ | |
557 | 0, /* bitpos */ | |
558 | complain_overflow_dont, /* complain_on_overflow */ | |
559 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
560 | "R_MIPS_TLS_DTPMOD32", /* name */ | |
561 | TRUE, /* partial_inplace */ | |
562 | 0xffffffff, /* src_mask */ | |
563 | 0xffffffff, /* dst_mask */ | |
564 | FALSE), /* pcrel_offset */ | |
565 | ||
566 | HOWTO (R_MIPS_TLS_DTPREL32, /* type */ | |
567 | 0, /* rightshift */ | |
568 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
569 | 32, /* bitsize */ | |
570 | FALSE, /* pc_relative */ | |
571 | 0, /* bitpos */ | |
572 | complain_overflow_dont, /* complain_on_overflow */ | |
573 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
574 | "R_MIPS_TLS_DTPREL32", /* name */ | |
575 | TRUE, /* partial_inplace */ | |
576 | 0xffffffff, /* src_mask */ | |
577 | 0xffffffff, /* dst_mask */ | |
578 | FALSE), /* pcrel_offset */ | |
579 | ||
580 | EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64), | |
581 | EMPTY_HOWTO (R_MIPS_TLS_DTPREL64), | |
582 | ||
583 | /* TLS general dynamic variable reference. */ | |
584 | HOWTO (R_MIPS_TLS_GD, /* type */ | |
585 | 0, /* rightshift */ | |
586 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
587 | 16, /* bitsize */ | |
588 | FALSE, /* pc_relative */ | |
589 | 0, /* bitpos */ | |
590 | complain_overflow_signed, /* complain_on_overflow */ | |
591 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
592 | "R_MIPS_TLS_GD", /* name */ | |
593 | TRUE, /* partial_inplace */ | |
594 | 0x0000ffff, /* src_mask */ | |
595 | 0x0000ffff, /* dst_mask */ | |
596 | FALSE), /* pcrel_offset */ | |
597 | ||
598 | /* TLS local dynamic variable reference. */ | |
599 | HOWTO (R_MIPS_TLS_LDM, /* type */ | |
600 | 0, /* rightshift */ | |
601 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
602 | 16, /* bitsize */ | |
603 | FALSE, /* pc_relative */ | |
604 | 0, /* bitpos */ | |
605 | complain_overflow_signed, /* complain_on_overflow */ | |
606 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
607 | "R_MIPS_TLS_LDM", /* name */ | |
608 | TRUE, /* partial_inplace */ | |
609 | 0x0000ffff, /* src_mask */ | |
610 | 0x0000ffff, /* dst_mask */ | |
611 | FALSE), /* pcrel_offset */ | |
612 | ||
613 | /* TLS local dynamic offset. */ | |
614 | HOWTO (R_MIPS_TLS_DTPREL_HI16, /* type */ | |
615 | 0, /* rightshift */ | |
616 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
617 | 16, /* bitsize */ | |
618 | FALSE, /* pc_relative */ | |
619 | 0, /* bitpos */ | |
620 | complain_overflow_signed, /* complain_on_overflow */ | |
621 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
622 | "R_MIPS_TLS_DTPREL_HI16", /* name */ | |
623 | TRUE, /* partial_inplace */ | |
624 | 0x0000ffff, /* src_mask */ | |
625 | 0x0000ffff, /* dst_mask */ | |
626 | FALSE), /* pcrel_offset */ | |
627 | ||
628 | /* TLS local dynamic offset. */ | |
629 | HOWTO (R_MIPS_TLS_DTPREL_LO16, /* type */ | |
630 | 0, /* rightshift */ | |
631 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
632 | 16, /* bitsize */ | |
633 | FALSE, /* pc_relative */ | |
634 | 0, /* bitpos */ | |
635 | complain_overflow_signed, /* complain_on_overflow */ | |
636 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
637 | "R_MIPS_TLS_DTPREL_LO16", /* name */ | |
638 | TRUE, /* partial_inplace */ | |
639 | 0x0000ffff, /* src_mask */ | |
640 | 0x0000ffff, /* dst_mask */ | |
641 | FALSE), /* pcrel_offset */ | |
642 | ||
643 | /* TLS thread pointer offset. */ | |
644 | HOWTO (R_MIPS_TLS_GOTTPREL, /* type */ | |
645 | 0, /* rightshift */ | |
646 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
647 | 16, /* bitsize */ | |
648 | FALSE, /* pc_relative */ | |
649 | 0, /* bitpos */ | |
650 | complain_overflow_signed, /* complain_on_overflow */ | |
651 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
652 | "R_MIPS_TLS_GOTTPREL", /* name */ | |
653 | TRUE, /* partial_inplace */ | |
654 | 0x0000ffff, /* src_mask */ | |
655 | 0x0000ffff, /* dst_mask */ | |
656 | FALSE), /* pcrel_offset */ | |
657 | ||
658 | /* TLS IE dynamic relocations. */ | |
659 | HOWTO (R_MIPS_TLS_TPREL32, /* type */ | |
660 | 0, /* rightshift */ | |
661 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
662 | 32, /* bitsize */ | |
663 | FALSE, /* pc_relative */ | |
664 | 0, /* bitpos */ | |
665 | complain_overflow_dont, /* complain_on_overflow */ | |
666 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
667 | "R_MIPS_TLS_TPREL32", /* name */ | |
668 | TRUE, /* partial_inplace */ | |
669 | 0xffffffff, /* src_mask */ | |
670 | 0xffffffff, /* dst_mask */ | |
671 | FALSE), /* pcrel_offset */ | |
672 | ||
673 | EMPTY_HOWTO (R_MIPS_TLS_TPREL64), | |
674 | ||
675 | /* TLS thread pointer offset. */ | |
676 | HOWTO (R_MIPS_TLS_TPREL_HI16, /* type */ | |
677 | 0, /* rightshift */ | |
678 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
679 | 16, /* bitsize */ | |
680 | FALSE, /* pc_relative */ | |
681 | 0, /* bitpos */ | |
682 | complain_overflow_signed, /* complain_on_overflow */ | |
683 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
684 | "R_MIPS_TLS_TPREL_HI16", /* name */ | |
685 | TRUE, /* partial_inplace */ | |
686 | 0x0000ffff, /* src_mask */ | |
687 | 0x0000ffff, /* dst_mask */ | |
688 | FALSE), /* pcrel_offset */ | |
689 | ||
690 | /* TLS thread pointer offset. */ | |
691 | HOWTO (R_MIPS_TLS_TPREL_LO16, /* type */ | |
692 | 0, /* rightshift */ | |
693 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
694 | 16, /* bitsize */ | |
695 | FALSE, /* pc_relative */ | |
696 | 0, /* bitpos */ | |
697 | complain_overflow_signed, /* complain_on_overflow */ | |
698 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
699 | "R_MIPS_TLS_TPREL_LO16", /* name */ | |
700 | TRUE, /* partial_inplace */ | |
701 | 0x0000ffff, /* src_mask */ | |
702 | 0x0000ffff, /* dst_mask */ | |
703 | FALSE), /* pcrel_offset */ | |
165b93e7 RS |
704 | |
705 | /* 32 bit relocation with no addend. */ | |
706 | HOWTO (R_MIPS_GLOB_DAT, /* type */ | |
707 | 0, /* rightshift */ | |
708 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
709 | 32, /* bitsize */ | |
710 | FALSE, /* pc_relative */ | |
711 | 0, /* bitpos */ | |
712 | complain_overflow_dont, /* complain_on_overflow */ | |
713 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
714 | "R_MIPS_GLOB_DAT", /* name */ | |
715 | FALSE, /* partial_inplace */ | |
716 | 0x0, /* src_mask */ | |
717 | 0xffffffff, /* dst_mask */ | |
718 | FALSE), /* pcrel_offset */ | |
d75bc93d TS |
719 | }; |
720 | ||
c6e90b02 TS |
721 | /* The reloc used for BFD_RELOC_CTOR when doing a 64 bit link. This |
722 | is a hack to make the linker think that we need 64 bit values. */ | |
723 | static reloc_howto_type elf_mips_ctor64_howto = | |
724 | HOWTO (R_MIPS_64, /* type */ | |
252b5132 | 725 | 0, /* rightshift */ |
c6e90b02 | 726 | 4, /* size (0 = byte, 1 = short, 2 = long) */ |
252b5132 | 727 | 32, /* bitsize */ |
b34976b6 | 728 | FALSE, /* pc_relative */ |
252b5132 | 729 | 0, /* bitpos */ |
c6e90b02 TS |
730 | complain_overflow_signed, /* complain_on_overflow */ |
731 | mips32_64bit_reloc, /* special_function */ | |
732 | "R_MIPS_64", /* name */ | |
b34976b6 | 733 | TRUE, /* partial_inplace */ |
c6e90b02 | 734 | 0xffffffff, /* src_mask */ |
252b5132 | 735 | 0xffffffff, /* dst_mask */ |
b34976b6 | 736 | FALSE); /* pcrel_offset */ |
252b5132 | 737 | |
d6f16593 MR |
738 | static reloc_howto_type elf_mips16_howto_table_rel[] = |
739 | { | |
740 | /* The reloc used for the mips16 jump instruction. */ | |
c6e90b02 | 741 | HOWTO (R_MIPS16_26, /* type */ |
252b5132 RH |
742 | 2, /* rightshift */ |
743 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
744 | 26, /* bitsize */ | |
b34976b6 | 745 | FALSE, /* pc_relative */ |
252b5132 RH |
746 | 0, /* bitpos */ |
747 | complain_overflow_dont, /* complain_on_overflow */ | |
c6e90b02 TS |
748 | /* This needs complex overflow |
749 | detection, because the upper four | |
750 | bits must match the PC. */ | |
35d3d567 | 751 | _bfd_mips_elf_generic_reloc, /* special_function */ |
c6e90b02 | 752 | "R_MIPS16_26", /* name */ |
b34976b6 | 753 | TRUE, /* partial_inplace */ |
c6e90b02 TS |
754 | 0x3ffffff, /* src_mask */ |
755 | 0x3ffffff, /* dst_mask */ | |
d6f16593 | 756 | FALSE), /* pcrel_offset */ |
252b5132 | 757 | |
d6f16593 | 758 | /* The reloc used for the mips16 gprel instruction. */ |
c6e90b02 | 759 | HOWTO (R_MIPS16_GPREL, /* type */ |
252b5132 RH |
760 | 0, /* rightshift */ |
761 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
762 | 16, /* bitsize */ | |
b34976b6 | 763 | FALSE, /* pc_relative */ |
252b5132 | 764 | 0, /* bitpos */ |
c6e90b02 TS |
765 | complain_overflow_signed, /* complain_on_overflow */ |
766 | mips16_gprel_reloc, /* special_function */ | |
767 | "R_MIPS16_GPREL", /* name */ | |
b34976b6 | 768 | TRUE, /* partial_inplace */ |
d6f16593 MR |
769 | 0x0000ffff, /* src_mask */ |
770 | 0x0000ffff, /* dst_mask */ | |
771 | FALSE), /* pcrel_offset */ | |
772 | ||
738e5348 RS |
773 | /* A MIPS16 reference to the global offset table. */ |
774 | HOWTO (R_MIPS16_GOT16, /* type */ | |
775 | 0, /* rightshift */ | |
776 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
777 | 16, /* bitsize */ | |
778 | FALSE, /* pc_relative */ | |
779 | 0, /* bitpos */ | |
780 | complain_overflow_dont, /* complain_on_overflow */ | |
781 | _bfd_mips_elf_got16_reloc, /* special_function */ | |
782 | "R_MIPS16_GOT16", /* name */ | |
783 | TRUE, /* partial_inplace */ | |
784 | 0x0000ffff, /* src_mask */ | |
785 | 0x0000ffff, /* dst_mask */ | |
786 | FALSE), /* pcrel_offset */ | |
d6f16593 | 787 | |
738e5348 RS |
788 | /* A MIPS16 call through the global offset table. */ |
789 | HOWTO (R_MIPS16_CALL16, /* type */ | |
790 | 0, /* rightshift */ | |
791 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
792 | 16, /* bitsize */ | |
793 | FALSE, /* pc_relative */ | |
794 | 0, /* bitpos */ | |
795 | complain_overflow_dont, /* complain_on_overflow */ | |
796 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
797 | "R_MIPS16_CALL16", /* name */ | |
798 | TRUE, /* partial_inplace */ | |
799 | 0x0000ffff, /* src_mask */ | |
800 | 0x0000ffff, /* dst_mask */ | |
801 | FALSE), /* pcrel_offset */ | |
d6f16593 MR |
802 | |
803 | /* MIPS16 high 16 bits of symbol value. */ | |
804 | HOWTO (R_MIPS16_HI16, /* type */ | |
805 | 16, /* rightshift */ | |
806 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
807 | 16, /* bitsize */ | |
808 | FALSE, /* pc_relative */ | |
809 | 0, /* bitpos */ | |
810 | complain_overflow_dont, /* complain_on_overflow */ | |
811 | _bfd_mips_elf_hi16_reloc, /* special_function */ | |
812 | "R_MIPS16_HI16", /* name */ | |
813 | TRUE, /* partial_inplace */ | |
814 | 0x0000ffff, /* src_mask */ | |
815 | 0x0000ffff, /* dst_mask */ | |
816 | FALSE), /* pcrel_offset */ | |
817 | ||
818 | /* MIPS16 low 16 bits of symbol value. */ | |
819 | HOWTO (R_MIPS16_LO16, /* type */ | |
820 | 0, /* rightshift */ | |
821 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
822 | 16, /* bitsize */ | |
823 | FALSE, /* pc_relative */ | |
824 | 0, /* bitpos */ | |
825 | complain_overflow_dont, /* complain_on_overflow */ | |
826 | _bfd_mips_elf_lo16_reloc, /* special_function */ | |
827 | "R_MIPS16_LO16", /* name */ | |
828 | TRUE, /* partial_inplace */ | |
829 | 0x0000ffff, /* src_mask */ | |
830 | 0x0000ffff, /* dst_mask */ | |
831 | FALSE), /* pcrel_offset */ | |
d0f13682 CLT |
832 | |
833 | /* MIPS16 TLS general dynamic variable reference. */ | |
834 | HOWTO (R_MIPS16_TLS_GD, /* type */ | |
835 | 0, /* rightshift */ | |
836 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
837 | 16, /* bitsize */ | |
838 | FALSE, /* pc_relative */ | |
839 | 0, /* bitpos */ | |
840 | complain_overflow_signed, /* complain_on_overflow */ | |
841 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
842 | "R_MIPS16_TLS_GD", /* name */ | |
843 | TRUE, /* partial_inplace */ | |
844 | 0x0000ffff, /* src_mask */ | |
845 | 0x0000ffff, /* dst_mask */ | |
846 | FALSE), /* pcrel_offset */ | |
847 | ||
848 | /* MIPS16 TLS local dynamic variable reference. */ | |
849 | HOWTO (R_MIPS16_TLS_LDM, /* type */ | |
850 | 0, /* rightshift */ | |
851 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
852 | 16, /* bitsize */ | |
853 | FALSE, /* pc_relative */ | |
854 | 0, /* bitpos */ | |
855 | complain_overflow_signed, /* complain_on_overflow */ | |
856 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
857 | "R_MIPS16_TLS_LDM", /* name */ | |
858 | TRUE, /* partial_inplace */ | |
859 | 0x0000ffff, /* src_mask */ | |
860 | 0x0000ffff, /* dst_mask */ | |
861 | FALSE), /* pcrel_offset */ | |
862 | ||
863 | /* MIPS16 TLS local dynamic offset. */ | |
864 | HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */ | |
865 | 0, /* rightshift */ | |
866 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
867 | 16, /* bitsize */ | |
868 | FALSE, /* pc_relative */ | |
869 | 0, /* bitpos */ | |
870 | complain_overflow_signed, /* complain_on_overflow */ | |
871 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
872 | "R_MIPS16_TLS_DTPREL_HI16", /* name */ | |
873 | TRUE, /* partial_inplace */ | |
874 | 0x0000ffff, /* src_mask */ | |
875 | 0x0000ffff, /* dst_mask */ | |
876 | FALSE), /* pcrel_offset */ | |
877 | ||
878 | /* MIPS16 TLS local dynamic offset. */ | |
879 | HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */ | |
880 | 0, /* rightshift */ | |
881 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
882 | 16, /* bitsize */ | |
883 | FALSE, /* pc_relative */ | |
884 | 0, /* bitpos */ | |
885 | complain_overflow_signed, /* complain_on_overflow */ | |
886 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
887 | "R_MIPS16_TLS_DTPREL_LO16", /* name */ | |
888 | TRUE, /* partial_inplace */ | |
889 | 0x0000ffff, /* src_mask */ | |
890 | 0x0000ffff, /* dst_mask */ | |
891 | FALSE), /* pcrel_offset */ | |
892 | ||
893 | /* MIPS16 TLS thread pointer offset. */ | |
894 | HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */ | |
895 | 0, /* rightshift */ | |
896 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
897 | 16, /* bitsize */ | |
898 | FALSE, /* pc_relative */ | |
899 | 0, /* bitpos */ | |
900 | complain_overflow_signed, /* complain_on_overflow */ | |
901 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
902 | "R_MIPS16_TLS_GOTTPREL", /* name */ | |
903 | TRUE, /* partial_inplace */ | |
904 | 0x0000ffff, /* src_mask */ | |
905 | 0x0000ffff, /* dst_mask */ | |
906 | FALSE), /* pcrel_offset */ | |
907 | ||
908 | /* MIPS16 TLS thread pointer offset. */ | |
909 | HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */ | |
910 | 0, /* rightshift */ | |
911 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
912 | 16, /* bitsize */ | |
913 | FALSE, /* pc_relative */ | |
914 | 0, /* bitpos */ | |
915 | complain_overflow_signed, /* complain_on_overflow */ | |
916 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
917 | "R_MIPS16_TLS_TPREL_HI16", /* name */ | |
918 | TRUE, /* partial_inplace */ | |
919 | 0x0000ffff, /* src_mask */ | |
920 | 0x0000ffff, /* dst_mask */ | |
921 | FALSE), /* pcrel_offset */ | |
922 | ||
923 | /* MIPS16 TLS thread pointer offset. */ | |
924 | HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */ | |
925 | 0, /* rightshift */ | |
926 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
927 | 16, /* bitsize */ | |
928 | FALSE, /* pc_relative */ | |
929 | 0, /* bitpos */ | |
930 | complain_overflow_signed, /* complain_on_overflow */ | |
931 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
932 | "R_MIPS16_TLS_TPREL_LO16", /* name */ | |
933 | TRUE, /* partial_inplace */ | |
934 | 0x0000ffff, /* src_mask */ | |
935 | 0x0000ffff, /* dst_mask */ | |
936 | FALSE), /* pcrel_offset */ | |
d6f16593 | 937 | }; |
252b5132 | 938 | |
df58fc94 RS |
939 | static reloc_howto_type elf_micromips_howto_table_rel[] = |
940 | { | |
941 | EMPTY_HOWTO (130), | |
942 | EMPTY_HOWTO (131), | |
943 | EMPTY_HOWTO (132), | |
944 | ||
945 | /* 26 bit jump address. */ | |
946 | HOWTO (R_MICROMIPS_26_S1, /* type */ | |
947 | 1, /* rightshift */ | |
948 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
949 | 26, /* bitsize */ | |
950 | FALSE, /* pc_relative */ | |
951 | 0, /* bitpos */ | |
952 | complain_overflow_dont, /* complain_on_overflow */ | |
953 | /* This needs complex overflow | |
954 | detection, because the upper four | |
955 | bits must match the PC. */ | |
956 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
957 | "R_MICROMIPS_26_S1", /* name */ | |
958 | TRUE, /* partial_inplace */ | |
959 | 0x3ffffff, /* src_mask */ | |
960 | 0x3ffffff, /* dst_mask */ | |
961 | FALSE), /* pcrel_offset */ | |
962 | ||
963 | /* High 16 bits of symbol value. */ | |
964 | HOWTO (R_MICROMIPS_HI16, /* type */ | |
965 | 16, /* rightshift */ | |
966 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
967 | 16, /* bitsize */ | |
968 | FALSE, /* pc_relative */ | |
969 | 0, /* bitpos */ | |
970 | complain_overflow_dont, /* complain_on_overflow */ | |
971 | _bfd_mips_elf_hi16_reloc, /* special_function */ | |
972 | "R_MICROMIPS_HI16", /* name */ | |
973 | TRUE, /* partial_inplace */ | |
974 | 0x0000ffff, /* src_mask */ | |
975 | 0x0000ffff, /* dst_mask */ | |
976 | FALSE), /* pcrel_offset */ | |
977 | ||
978 | /* Low 16 bits of symbol value. */ | |
979 | HOWTO (R_MICROMIPS_LO16, /* type */ | |
980 | 0, /* rightshift */ | |
981 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
982 | 16, /* bitsize */ | |
983 | FALSE, /* pc_relative */ | |
984 | 0, /* bitpos */ | |
985 | complain_overflow_dont, /* complain_on_overflow */ | |
986 | _bfd_mips_elf_lo16_reloc, /* special_function */ | |
987 | "R_MICROMIPS_LO16", /* name */ | |
988 | TRUE, /* partial_inplace */ | |
989 | 0x0000ffff, /* src_mask */ | |
990 | 0x0000ffff, /* dst_mask */ | |
991 | FALSE), /* pcrel_offset */ | |
992 | ||
993 | /* GP relative reference. */ | |
994 | HOWTO (R_MICROMIPS_GPREL16, /* type */ | |
995 | 0, /* rightshift */ | |
996 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
997 | 16, /* bitsize */ | |
998 | FALSE, /* pc_relative */ | |
999 | 0, /* bitpos */ | |
1000 | complain_overflow_signed, /* complain_on_overflow */ | |
1001 | _bfd_mips_elf32_gprel16_reloc, /* special_function */ | |
1002 | "R_MICROMIPS_GPREL16", /* name */ | |
1003 | TRUE, /* partial_inplace */ | |
1004 | 0x0000ffff, /* src_mask */ | |
1005 | 0x0000ffff, /* dst_mask */ | |
1006 | FALSE), /* pcrel_offset */ | |
1007 | ||
1008 | /* Reference to literal section. */ | |
1009 | HOWTO (R_MICROMIPS_LITERAL, /* type */ | |
1010 | 0, /* rightshift */ | |
1011 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1012 | 16, /* bitsize */ | |
1013 | FALSE, /* pc_relative */ | |
1014 | 0, /* bitpos */ | |
1015 | complain_overflow_signed, /* complain_on_overflow */ | |
1016 | _bfd_mips_elf32_gprel16_reloc, /* special_function */ | |
1017 | "R_MICROMIPS_LITERAL", /* name */ | |
1018 | TRUE, /* partial_inplace */ | |
1019 | 0x0000ffff, /* src_mask */ | |
1020 | 0x0000ffff, /* dst_mask */ | |
1021 | FALSE), /* pcrel_offset */ | |
1022 | ||
1023 | /* Reference to global offset table. */ | |
1024 | HOWTO (R_MICROMIPS_GOT16, /* type */ | |
1025 | 0, /* rightshift */ | |
1026 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1027 | 16, /* bitsize */ | |
1028 | FALSE, /* pc_relative */ | |
1029 | 0, /* bitpos */ | |
1030 | complain_overflow_signed, /* complain_on_overflow */ | |
1031 | _bfd_mips_elf_got16_reloc, /* special_function */ | |
1032 | "R_MICROMIPS_GOT16", /* name */ | |
1033 | TRUE, /* partial_inplace */ | |
1034 | 0x0000ffff, /* src_mask */ | |
1035 | 0x0000ffff, /* dst_mask */ | |
1036 | FALSE), /* pcrel_offset */ | |
1037 | ||
1038 | /* This is for microMIPS branches. */ | |
1039 | HOWTO (R_MICROMIPS_PC7_S1, /* type */ | |
1040 | 1, /* rightshift */ | |
1041 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
1042 | 7, /* bitsize */ | |
1043 | TRUE, /* pc_relative */ | |
1044 | 0, /* bitpos */ | |
1045 | complain_overflow_signed, /* complain_on_overflow */ | |
1046 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1047 | "R_MICROMIPS_PC7_S1", /* name */ | |
1048 | TRUE, /* partial_inplace */ | |
1049 | 0x0000007f, /* src_mask */ | |
1050 | 0x0000007f, /* dst_mask */ | |
1051 | TRUE), /* pcrel_offset */ | |
1052 | ||
1053 | HOWTO (R_MICROMIPS_PC10_S1, /* type */ | |
1054 | 1, /* rightshift */ | |
1055 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
1056 | 10, /* bitsize */ | |
1057 | TRUE, /* pc_relative */ | |
1058 | 0, /* bitpos */ | |
1059 | complain_overflow_signed, /* complain_on_overflow */ | |
1060 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1061 | "R_MICROMIPS_PC10_S1", /* name */ | |
1062 | TRUE, /* partial_inplace */ | |
1063 | 0x000003ff, /* src_mask */ | |
1064 | 0x000003ff, /* dst_mask */ | |
1065 | TRUE), /* pcrel_offset */ | |
1066 | ||
1067 | HOWTO (R_MICROMIPS_PC16_S1, /* type */ | |
1068 | 1, /* rightshift */ | |
1069 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1070 | 16, /* bitsize */ | |
1071 | TRUE, /* pc_relative */ | |
1072 | 0, /* bitpos */ | |
1073 | complain_overflow_signed, /* complain_on_overflow */ | |
1074 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1075 | "R_MICROMIPS_PC16_S1", /* name */ | |
1076 | TRUE, /* partial_inplace */ | |
1077 | 0x0000ffff, /* src_mask */ | |
1078 | 0x0000ffff, /* dst_mask */ | |
1079 | TRUE), /* pcrel_offset */ | |
1080 | ||
1081 | /* 16 bit call through global offset table. */ | |
1082 | HOWTO (R_MICROMIPS_CALL16, /* type */ | |
1083 | 0, /* rightshift */ | |
1084 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1085 | 16, /* bitsize */ | |
1086 | FALSE, /* pc_relative */ | |
1087 | 0, /* bitpos */ | |
1088 | complain_overflow_signed, /* complain_on_overflow */ | |
1089 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1090 | "R_MICROMIPS_CALL16", /* name */ | |
1091 | TRUE, /* partial_inplace */ | |
1092 | 0x0000ffff, /* src_mask */ | |
1093 | 0x0000ffff, /* dst_mask */ | |
1094 | FALSE), /* pcrel_offset */ | |
1095 | ||
1096 | EMPTY_HOWTO (143), | |
1097 | EMPTY_HOWTO (144), | |
1098 | ||
1099 | /* Displacement in the global offset table. */ | |
1100 | HOWTO (R_MICROMIPS_GOT_DISP, /* type */ | |
1101 | 0, /* rightshift */ | |
1102 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1103 | 16, /* bitsize */ | |
1104 | FALSE, /* pc_relative */ | |
1105 | 0, /* bitpos */ | |
1106 | complain_overflow_signed, /* complain_on_overflow */ | |
1107 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1108 | "R_MICROMIPS_GOT_DISP",/* name */ | |
1109 | TRUE, /* partial_inplace */ | |
1110 | 0x0000ffff, /* src_mask */ | |
1111 | 0x0000ffff, /* dst_mask */ | |
1112 | FALSE), /* pcrel_offset */ | |
1113 | ||
1114 | /* Displacement to page pointer in the global offset table. */ | |
1115 | HOWTO (R_MICROMIPS_GOT_PAGE, /* type */ | |
1116 | 0, /* rightshift */ | |
1117 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1118 | 16, /* bitsize */ | |
1119 | FALSE, /* pc_relative */ | |
1120 | 0, /* bitpos */ | |
1121 | complain_overflow_signed, /* complain_on_overflow */ | |
1122 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1123 | "R_MICROMIPS_GOT_PAGE",/* name */ | |
1124 | TRUE, /* partial_inplace */ | |
1125 | 0x0000ffff, /* src_mask */ | |
1126 | 0x0000ffff, /* dst_mask */ | |
1127 | FALSE), /* pcrel_offset */ | |
1128 | ||
1129 | /* Offset from page pointer in the global offset table. */ | |
1130 | HOWTO (R_MICROMIPS_GOT_OFST, /* type */ | |
1131 | 0, /* rightshift */ | |
1132 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1133 | 16, /* bitsize */ | |
1134 | FALSE, /* pc_relative */ | |
1135 | 0, /* bitpos */ | |
1136 | complain_overflow_signed, /* complain_on_overflow */ | |
1137 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1138 | "R_MICROMIPS_GOT_OFST",/* name */ | |
1139 | TRUE, /* partial_inplace */ | |
1140 | 0x0000ffff, /* src_mask */ | |
1141 | 0x0000ffff, /* dst_mask */ | |
1142 | FALSE), /* pcrel_offset */ | |
1143 | ||
1144 | /* High 16 bits of displacement in global offset table. */ | |
1145 | HOWTO (R_MICROMIPS_GOT_HI16, /* type */ | |
1146 | 0, /* rightshift */ | |
1147 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1148 | 16, /* bitsize */ | |
1149 | FALSE, /* pc_relative */ | |
1150 | 0, /* bitpos */ | |
1151 | complain_overflow_dont, /* complain_on_overflow */ | |
1152 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1153 | "R_MICROMIPS_GOT_HI16",/* name */ | |
1154 | TRUE, /* partial_inplace */ | |
1155 | 0x0000ffff, /* src_mask */ | |
1156 | 0x0000ffff, /* dst_mask */ | |
1157 | FALSE), /* pcrel_offset */ | |
1158 | ||
1159 | /* Low 16 bits of displacement in global offset table. */ | |
1160 | HOWTO (R_MICROMIPS_GOT_LO16, /* type */ | |
1161 | 0, /* rightshift */ | |
1162 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1163 | 16, /* bitsize */ | |
1164 | FALSE, /* pc_relative */ | |
1165 | 0, /* bitpos */ | |
1166 | complain_overflow_dont, /* complain_on_overflow */ | |
1167 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1168 | "R_MICROMIPS_GOT_LO16",/* name */ | |
1169 | TRUE, /* partial_inplace */ | |
1170 | 0x0000ffff, /* src_mask */ | |
1171 | 0x0000ffff, /* dst_mask */ | |
1172 | FALSE), /* pcrel_offset */ | |
1173 | ||
1174 | /* 64 bit subtraction. Used in the N32 ABI. */ | |
1175 | HOWTO (R_MICROMIPS_SUB, /* type */ | |
1176 | 0, /* rightshift */ | |
1177 | 4, /* size (0 = byte, 1 = short, 2 = long) */ | |
1178 | 64, /* bitsize */ | |
1179 | FALSE, /* pc_relative */ | |
1180 | 0, /* bitpos */ | |
1181 | complain_overflow_dont, /* complain_on_overflow */ | |
1182 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1183 | "R_MICROMIPS_SUB", /* name */ | |
1184 | TRUE, /* partial_inplace */ | |
1185 | MINUS_ONE, /* src_mask */ | |
1186 | MINUS_ONE, /* dst_mask */ | |
1187 | FALSE), /* pcrel_offset */ | |
1188 | ||
1189 | /* Get the higher value of a 64 bit addend. */ | |
1190 | HOWTO (R_MICROMIPS_HIGHER, /* type */ | |
1191 | 0, /* rightshift */ | |
1192 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1193 | 16, /* bitsize */ | |
1194 | FALSE, /* pc_relative */ | |
1195 | 0, /* bitpos */ | |
1196 | complain_overflow_dont, /* complain_on_overflow */ | |
1197 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1198 | "R_MICROMIPS_HIGHER", /* name */ | |
1199 | TRUE, /* partial_inplace */ | |
1200 | 0x0000ffff, /* src_mask */ | |
1201 | 0x0000ffff, /* dst_mask */ | |
1202 | FALSE), /* pcrel_offset */ | |
1203 | ||
1204 | /* Get the highest value of a 64 bit addend. */ | |
1205 | HOWTO (R_MICROMIPS_HIGHEST, /* type */ | |
1206 | 0, /* rightshift */ | |
1207 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1208 | 16, /* bitsize */ | |
1209 | FALSE, /* pc_relative */ | |
1210 | 0, /* bitpos */ | |
1211 | complain_overflow_dont, /* complain_on_overflow */ | |
1212 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1213 | "R_MICROMIPS_HIGHEST", /* name */ | |
1214 | TRUE, /* partial_inplace */ | |
1215 | 0x0000ffff, /* src_mask */ | |
1216 | 0x0000ffff, /* dst_mask */ | |
1217 | FALSE), /* pcrel_offset */ | |
1218 | ||
1219 | /* High 16 bits of displacement in global offset table. */ | |
1220 | HOWTO (R_MICROMIPS_CALL_HI16, /* type */ | |
1221 | 0, /* rightshift */ | |
1222 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1223 | 16, /* bitsize */ | |
1224 | FALSE, /* pc_relative */ | |
1225 | 0, /* bitpos */ | |
1226 | complain_overflow_dont, /* complain_on_overflow */ | |
1227 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1228 | "R_MICROMIPS_CALL_HI16",/* name */ | |
1229 | TRUE, /* partial_inplace */ | |
1230 | 0x0000ffff, /* src_mask */ | |
1231 | 0x0000ffff, /* dst_mask */ | |
1232 | FALSE), /* pcrel_offset */ | |
1233 | ||
1234 | /* Low 16 bits of displacement in global offset table. */ | |
1235 | HOWTO (R_MICROMIPS_CALL_LO16, /* type */ | |
1236 | 0, /* rightshift */ | |
1237 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1238 | 16, /* bitsize */ | |
1239 | FALSE, /* pc_relative */ | |
1240 | 0, /* bitpos */ | |
1241 | complain_overflow_dont, /* complain_on_overflow */ | |
1242 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1243 | "R_MICROMIPS_CALL_LO16",/* name */ | |
1244 | TRUE, /* partial_inplace */ | |
1245 | 0x0000ffff, /* src_mask */ | |
1246 | 0x0000ffff, /* dst_mask */ | |
1247 | FALSE), /* pcrel_offset */ | |
1248 | ||
1249 | /* Section displacement. */ | |
1250 | HOWTO (R_MICROMIPS_SCN_DISP, /* type */ | |
1251 | 0, /* rightshift */ | |
1252 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1253 | 32, /* bitsize */ | |
1254 | FALSE, /* pc_relative */ | |
1255 | 0, /* bitpos */ | |
1256 | complain_overflow_dont, /* complain_on_overflow */ | |
1257 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1258 | "R_MICROMIPS_SCN_DISP",/* name */ | |
1259 | TRUE, /* partial_inplace */ | |
1260 | 0xffffffff, /* src_mask */ | |
1261 | 0xffffffff, /* dst_mask */ | |
1262 | FALSE), /* pcrel_offset */ | |
1263 | ||
1264 | /* Protected jump conversion. This is an optimization hint. No | |
1265 | relocation is required for correctness. */ | |
1266 | HOWTO (R_MICROMIPS_JALR, /* type */ | |
1267 | 0, /* rightshift */ | |
1268 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1269 | 32, /* bitsize */ | |
1270 | FALSE, /* pc_relative */ | |
1271 | 0, /* bitpos */ | |
1272 | complain_overflow_dont, /* complain_on_overflow */ | |
1273 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1274 | "R_MICROMIPS_JALR", /* name */ | |
1275 | FALSE, /* partial_inplace */ | |
1276 | 0x00000000, /* src_mask */ | |
1277 | 0x00000000, /* dst_mask */ | |
1278 | FALSE), /* pcrel_offset */ | |
1279 | ||
1280 | /* Low 16 bits of symbol value. Note that the high 16 bits of symbol values | |
1281 | must be zero. This is used for relaxation. */ | |
1282 | HOWTO (R_MICROMIPS_HI0_LO16, /* type */ | |
1283 | 0, /* rightshift */ | |
1284 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1285 | 16, /* bitsize */ | |
1286 | FALSE, /* pc_relative */ | |
1287 | 0, /* bitpos */ | |
1288 | complain_overflow_dont, /* complain_on_overflow */ | |
1289 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1290 | "R_MICROMIPS_HI0_LO16",/* name */ | |
1291 | TRUE, /* partial_inplace */ | |
1292 | 0x0000ffff, /* src_mask */ | |
1293 | 0x0000ffff, /* dst_mask */ | |
1294 | FALSE), /* pcrel_offset */ | |
1295 | ||
1296 | EMPTY_HOWTO (158), | |
1297 | EMPTY_HOWTO (159), | |
1298 | EMPTY_HOWTO (160), | |
1299 | EMPTY_HOWTO (161), | |
1300 | ||
1301 | /* TLS general dynamic variable reference. */ | |
1302 | HOWTO (R_MICROMIPS_TLS_GD, /* type */ | |
1303 | 0, /* rightshift */ | |
1304 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1305 | 16, /* bitsize */ | |
1306 | FALSE, /* pc_relative */ | |
1307 | 0, /* bitpos */ | |
1308 | complain_overflow_signed, /* complain_on_overflow */ | |
1309 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1310 | "R_MICROMIPS_TLS_GD", /* name */ | |
1311 | TRUE, /* partial_inplace */ | |
1312 | 0x0000ffff, /* src_mask */ | |
1313 | 0x0000ffff, /* dst_mask */ | |
1314 | FALSE), /* pcrel_offset */ | |
1315 | ||
1316 | /* TLS local dynamic variable reference. */ | |
1317 | HOWTO (R_MICROMIPS_TLS_LDM, /* type */ | |
1318 | 0, /* rightshift */ | |
1319 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1320 | 16, /* bitsize */ | |
1321 | FALSE, /* pc_relative */ | |
1322 | 0, /* bitpos */ | |
1323 | complain_overflow_signed, /* complain_on_overflow */ | |
1324 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1325 | "R_MICROMIPS_TLS_LDM", /* name */ | |
1326 | TRUE, /* partial_inplace */ | |
1327 | 0x0000ffff, /* src_mask */ | |
1328 | 0x0000ffff, /* dst_mask */ | |
1329 | FALSE), /* pcrel_offset */ | |
1330 | ||
1331 | /* TLS local dynamic offset. */ | |
1332 | HOWTO (R_MICROMIPS_TLS_DTPREL_HI16, /* type */ | |
1333 | 0, /* rightshift */ | |
1334 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1335 | 16, /* bitsize */ | |
1336 | FALSE, /* pc_relative */ | |
1337 | 0, /* bitpos */ | |
1338 | complain_overflow_signed, /* complain_on_overflow */ | |
1339 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1340 | "R_MICROMIPS_TLS_DTPREL_HI16", /* name */ | |
1341 | TRUE, /* partial_inplace */ | |
1342 | 0x0000ffff, /* src_mask */ | |
1343 | 0x0000ffff, /* dst_mask */ | |
1344 | FALSE), /* pcrel_offset */ | |
1345 | ||
1346 | /* TLS local dynamic offset. */ | |
1347 | HOWTO (R_MICROMIPS_TLS_DTPREL_LO16, /* type */ | |
1348 | 0, /* rightshift */ | |
1349 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1350 | 16, /* bitsize */ | |
1351 | FALSE, /* pc_relative */ | |
1352 | 0, /* bitpos */ | |
1353 | complain_overflow_signed, /* complain_on_overflow */ | |
1354 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1355 | "R_MICROMIPS_TLS_DTPREL_LO16", /* name */ | |
1356 | TRUE, /* partial_inplace */ | |
1357 | 0x0000ffff, /* src_mask */ | |
1358 | 0x0000ffff, /* dst_mask */ | |
1359 | FALSE), /* pcrel_offset */ | |
1360 | ||
1361 | /* TLS thread pointer offset. */ | |
1362 | HOWTO (R_MICROMIPS_TLS_GOTTPREL, /* type */ | |
1363 | 0, /* rightshift */ | |
1364 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1365 | 16, /* bitsize */ | |
1366 | FALSE, /* pc_relative */ | |
1367 | 0, /* bitpos */ | |
1368 | complain_overflow_signed, /* complain_on_overflow */ | |
1369 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1370 | "R_MICROMIPS_TLS_GOTTPREL", /* name */ | |
1371 | TRUE, /* partial_inplace */ | |
1372 | 0x0000ffff, /* src_mask */ | |
1373 | 0x0000ffff, /* dst_mask */ | |
1374 | FALSE), /* pcrel_offset */ | |
1375 | ||
1376 | EMPTY_HOWTO (167), | |
1377 | EMPTY_HOWTO (168), | |
1378 | ||
1379 | /* TLS thread pointer offset. */ | |
1380 | HOWTO (R_MICROMIPS_TLS_TPREL_HI16, /* type */ | |
1381 | 0, /* rightshift */ | |
1382 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1383 | 16, /* bitsize */ | |
1384 | FALSE, /* pc_relative */ | |
1385 | 0, /* bitpos */ | |
1386 | complain_overflow_signed, /* complain_on_overflow */ | |
1387 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1388 | "R_MICROMIPS_TLS_TPREL_HI16", /* name */ | |
1389 | TRUE, /* partial_inplace */ | |
1390 | 0x0000ffff, /* src_mask */ | |
1391 | 0x0000ffff, /* dst_mask */ | |
1392 | FALSE), /* pcrel_offset */ | |
1393 | ||
1394 | /* TLS thread pointer offset. */ | |
1395 | HOWTO (R_MICROMIPS_TLS_TPREL_LO16, /* type */ | |
1396 | 0, /* rightshift */ | |
1397 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1398 | 16, /* bitsize */ | |
1399 | FALSE, /* pc_relative */ | |
1400 | 0, /* bitpos */ | |
1401 | complain_overflow_signed, /* complain_on_overflow */ | |
1402 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1403 | "R_MICROMIPS_TLS_TPREL_LO16", /* name */ | |
1404 | TRUE, /* partial_inplace */ | |
1405 | 0x0000ffff, /* src_mask */ | |
1406 | 0x0000ffff, /* dst_mask */ | |
1407 | FALSE), /* pcrel_offset */ | |
1408 | ||
1409 | EMPTY_HOWTO (171), | |
1410 | ||
1411 | /* GP- and PC-relative relocations. */ | |
1412 | HOWTO (R_MICROMIPS_GPREL7_S2, /* type */ | |
1413 | 2, /* rightshift */ | |
1414 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
1415 | 7, /* bitsize */ | |
1416 | FALSE, /* pc_relative */ | |
1417 | 0, /* bitpos */ | |
1418 | complain_overflow_signed, /* complain_on_overflow */ | |
1419 | _bfd_mips_elf32_gprel16_reloc, /* special_function */ | |
1420 | "R_MICROMIPS_GPREL7_S2", /* name */ | |
1421 | TRUE, /* partial_inplace */ | |
1422 | 0x0000007f, /* src_mask */ | |
1423 | 0x0000007f, /* dst_mask */ | |
1424 | FALSE), /* pcrel_offset */ | |
1425 | ||
1426 | HOWTO (R_MICROMIPS_PC23_S2, /* type */ | |
1427 | 2, /* rightshift */ | |
1428 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1429 | 23, /* bitsize */ | |
1430 | TRUE, /* pc_relative */ | |
1431 | 0, /* bitpos */ | |
1432 | complain_overflow_signed, /* complain_on_overflow */ | |
1433 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1434 | "R_MICROMIPS_PC23_S2", /* name */ | |
1435 | TRUE, /* partial_inplace */ | |
1436 | 0x007fffff, /* src_mask */ | |
1437 | 0x007fffff, /* dst_mask */ | |
1438 | TRUE), /* pcrel_offset */ | |
1439 | }; | |
1440 | ||
c6e90b02 TS |
1441 | /* 16 bit offset for pc-relative branches. */ |
1442 | static reloc_howto_type elf_mips_gnu_rel16_s2 = | |
1443 | HOWTO (R_MIPS_GNU_REL16_S2, /* type */ | |
1444 | 2, /* rightshift */ | |
252b5132 RH |
1445 | 2, /* size (0 = byte, 1 = short, 2 = long) */ |
1446 | 16, /* bitsize */ | |
b34976b6 | 1447 | TRUE, /* pc_relative */ |
252b5132 RH |
1448 | 0, /* bitpos */ |
1449 | complain_overflow_signed, /* complain_on_overflow */ | |
30ac9238 | 1450 | _bfd_mips_elf_generic_reloc, /* special_function */ |
c6e90b02 | 1451 | "R_MIPS_GNU_REL16_S2", /* name */ |
b34976b6 | 1452 | TRUE, /* partial_inplace */ |
c6e90b02 TS |
1453 | 0xffff, /* src_mask */ |
1454 | 0xffff, /* dst_mask */ | |
b34976b6 | 1455 | TRUE); /* pcrel_offset */ |
252b5132 | 1456 | |
092dcd75 CD |
1457 | /* 32 bit pc-relative. This was a GNU extension used by embedded-PIC. |
1458 | It was co-opted by mips-linux for exception-handling data. It is no | |
1459 | longer used, but should continue to be supported by the linker for | |
1460 | backward compatibility. (GCC stopped using it in May, 2004.) */ | |
1461 | static reloc_howto_type elf_mips_gnu_pcrel32 = | |
1462 | HOWTO (R_MIPS_PC32, /* type */ | |
1463 | 0, /* rightshift */ | |
1464 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1465 | 32, /* bitsize */ | |
1466 | TRUE, /* pc_relative */ | |
1467 | 0, /* bitpos */ | |
1468 | complain_overflow_signed, /* complain_on_overflow */ | |
1469 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1470 | "R_MIPS_PC32", /* name */ | |
1471 | TRUE, /* partial_inplace */ | |
1472 | 0xffffffff, /* src_mask */ | |
1473 | 0xffffffff, /* dst_mask */ | |
1474 | TRUE); /* pcrel_offset */ | |
1475 | ||
c6e90b02 TS |
1476 | /* GNU extension to record C++ vtable hierarchy */ |
1477 | static reloc_howto_type elf_mips_gnu_vtinherit_howto = | |
1478 | HOWTO (R_MIPS_GNU_VTINHERIT, /* type */ | |
252b5132 RH |
1479 | 0, /* rightshift */ |
1480 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
c6e90b02 | 1481 | 0, /* bitsize */ |
b34976b6 | 1482 | FALSE, /* pc_relative */ |
252b5132 | 1483 | 0, /* bitpos */ |
c6e90b02 TS |
1484 | complain_overflow_dont, /* complain_on_overflow */ |
1485 | NULL, /* special_function */ | |
1486 | "R_MIPS_GNU_VTINHERIT", /* name */ | |
b34976b6 | 1487 | FALSE, /* partial_inplace */ |
d75bc93d | 1488 | 0, /* src_mask */ |
c6e90b02 | 1489 | 0, /* dst_mask */ |
b34976b6 | 1490 | FALSE); /* pcrel_offset */ |
252b5132 | 1491 | |
c6e90b02 TS |
1492 | /* GNU extension to record C++ vtable member usage */ |
1493 | static reloc_howto_type elf_mips_gnu_vtentry_howto = | |
1494 | HOWTO (R_MIPS_GNU_VTENTRY, /* type */ | |
252b5132 RH |
1495 | 0, /* rightshift */ |
1496 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
c6e90b02 | 1497 | 0, /* bitsize */ |
b34976b6 | 1498 | FALSE, /* pc_relative */ |
252b5132 RH |
1499 | 0, /* bitpos */ |
1500 | complain_overflow_dont, /* complain_on_overflow */ | |
c6e90b02 TS |
1501 | _bfd_elf_rel_vtable_reloc_fn, /* special_function */ |
1502 | "R_MIPS_GNU_VTENTRY", /* name */ | |
b34976b6 | 1503 | FALSE, /* partial_inplace */ |
d75bc93d | 1504 | 0, /* src_mask */ |
c6e90b02 | 1505 | 0, /* dst_mask */ |
b34976b6 | 1506 | FALSE); /* pcrel_offset */ |
252b5132 | 1507 | |
861fb55a DJ |
1508 | /* Originally a VxWorks extension, but now used for other systems too. */ |
1509 | static reloc_howto_type elf_mips_copy_howto = | |
1510 | HOWTO (R_MIPS_COPY, /* type */ | |
1511 | 0, /* rightshift */ | |
1512 | 0, /* this one is variable size */ | |
1513 | 0, /* bitsize */ | |
1514 | FALSE, /* pc_relative */ | |
1515 | 0, /* bitpos */ | |
1516 | complain_overflow_bitfield, /* complain_on_overflow */ | |
d150b1a2 | 1517 | _bfd_mips_elf_generic_reloc, /* special_function */ |
861fb55a DJ |
1518 | "R_MIPS_COPY", /* name */ |
1519 | FALSE, /* partial_inplace */ | |
1520 | 0x0, /* src_mask */ | |
1521 | 0x0, /* dst_mask */ | |
1522 | FALSE); /* pcrel_offset */ | |
1523 | ||
1524 | /* Originally a VxWorks extension, but now used for other systems too. */ | |
1525 | static reloc_howto_type elf_mips_jump_slot_howto = | |
1526 | HOWTO (R_MIPS_JUMP_SLOT, /* type */ | |
1527 | 0, /* rightshift */ | |
1528 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1529 | 32, /* bitsize */ | |
1530 | FALSE, /* pc_relative */ | |
1531 | 0, /* bitpos */ | |
1532 | complain_overflow_bitfield, /* complain_on_overflow */ | |
d150b1a2 | 1533 | _bfd_mips_elf_generic_reloc, /* special_function */ |
861fb55a DJ |
1534 | "R_MIPS_JUMP_SLOT", /* name */ |
1535 | FALSE, /* partial_inplace */ | |
1536 | 0x0, /* src_mask */ | |
1537 | 0x0, /* dst_mask */ | |
1538 | FALSE); /* pcrel_offset */ | |
1539 | ||
067ec077 CM |
1540 | /* Used in EH tables. */ |
1541 | static reloc_howto_type elf_mips_eh_howto = | |
1542 | HOWTO (R_MIPS_EH, /* type */ | |
1543 | 0, /* rightshift */ | |
1544 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
1545 | 32, /* bitsize */ | |
1546 | FALSE, /* pc_relative */ | |
1547 | 0, /* bitpos */ | |
1548 | complain_overflow_signed, /* complain_on_overflow */ | |
1549 | _bfd_mips_elf_generic_reloc, /* special_function */ | |
1550 | "R_MIPS_EH", /* name */ | |
1551 | TRUE, /* partial_inplace */ | |
1552 | 0xffffffff, /* src_mask */ | |
1553 | 0xffffffff, /* dst_mask */ | |
1554 | FALSE); /* pcrel_offset */ | |
1555 | ||
b34976b6 | 1556 | /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a |
c6e90b02 | 1557 | dangerous relocation. */ |
252b5132 | 1558 | |
b34976b6 | 1559 | static bfd_boolean |
11a2be4d | 1560 | mips_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp) |
252b5132 | 1561 | { |
c6e90b02 TS |
1562 | unsigned int count; |
1563 | asymbol **sym; | |
1564 | unsigned int i; | |
e92d460e | 1565 | |
c6e90b02 TS |
1566 | /* If we've already figured out what GP will be, just return it. */ |
1567 | *pgp = _bfd_get_gp_value (output_bfd); | |
1568 | if (*pgp) | |
b34976b6 | 1569 | return TRUE; |
c6e90b02 TS |
1570 | |
1571 | count = bfd_get_symcount (output_bfd); | |
1572 | sym = bfd_get_outsymbols (output_bfd); | |
252b5132 | 1573 | |
c6e90b02 TS |
1574 | /* The linker script will have created a symbol named `_gp' with the |
1575 | appropriate value. */ | |
11a2be4d | 1576 | if (sym == NULL) |
c6e90b02 TS |
1577 | i = count; |
1578 | else | |
252b5132 | 1579 | { |
c6e90b02 TS |
1580 | for (i = 0; i < count; i++, sym++) |
1581 | { | |
1582 | register const char *name; | |
1583 | ||
1584 | name = bfd_asymbol_name (*sym); | |
1585 | if (*name == '_' && strcmp (name, "_gp") == 0) | |
1586 | { | |
1587 | *pgp = bfd_asymbol_value (*sym); | |
1588 | _bfd_set_gp_value (output_bfd, *pgp); | |
1589 | break; | |
1590 | } | |
1591 | } | |
252b5132 RH |
1592 | } |
1593 | ||
c6e90b02 | 1594 | if (i >= count) |
252b5132 | 1595 | { |
c6e90b02 TS |
1596 | /* Only get the error once. */ |
1597 | *pgp = 4; | |
1598 | _bfd_set_gp_value (output_bfd, *pgp); | |
b34976b6 | 1599 | return FALSE; |
252b5132 RH |
1600 | } |
1601 | ||
b34976b6 | 1602 | return TRUE; |
252b5132 RH |
1603 | } |
1604 | ||
c6e90b02 TS |
1605 | /* We have to figure out the gp value, so that we can adjust the |
1606 | symbol value correctly. We look up the symbol _gp in the output | |
1607 | BFD. If we can't find it, we're stuck. We cache it in the ELF | |
1608 | target data. We don't need to adjust the symbol value for an | |
1049f94e | 1609 | external symbol if we are producing relocatable output. */ |
252b5132 | 1610 | |
c6e90b02 | 1611 | static bfd_reloc_status_type |
11a2be4d RS |
1612 | mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable, |
1613 | char **error_message, bfd_vma *pgp) | |
252b5132 | 1614 | { |
c6e90b02 | 1615 | if (bfd_is_und_section (symbol->section) |
1049f94e | 1616 | && ! relocatable) |
252b5132 | 1617 | { |
c6e90b02 TS |
1618 | *pgp = 0; |
1619 | return bfd_reloc_undefined; | |
252b5132 RH |
1620 | } |
1621 | ||
c6e90b02 TS |
1622 | *pgp = _bfd_get_gp_value (output_bfd); |
1623 | if (*pgp == 0 | |
1049f94e | 1624 | && (! relocatable |
c6e90b02 | 1625 | || (symbol->flags & BSF_SECTION_SYM) != 0)) |
252b5132 | 1626 | { |
1049f94e | 1627 | if (relocatable) |
252b5132 | 1628 | { |
c6e90b02 | 1629 | /* Make up a value. */ |
453f5985 | 1630 | *pgp = symbol->section->output_section->vma /*+ 0x4000*/; |
c6e90b02 | 1631 | _bfd_set_gp_value (output_bfd, *pgp); |
252b5132 | 1632 | } |
c6e90b02 | 1633 | else if (!mips_elf_assign_gp (output_bfd, pgp)) |
252b5132 | 1634 | { |
c6e90b02 TS |
1635 | *error_message = |
1636 | (char *) _("GP relative relocation when _gp not defined"); | |
1637 | return bfd_reloc_dangerous; | |
252b5132 | 1638 | } |
252b5132 RH |
1639 | } |
1640 | ||
c6e90b02 TS |
1641 | return bfd_reloc_ok; |
1642 | } | |
252b5132 | 1643 | |
c6e90b02 TS |
1644 | /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must |
1645 | become the offset from the gp register. This function also handles | |
1646 | R_MIPS_LITERAL relocations, although those can be handled more | |
1647 | cleverly because the entries in the .lit8 and .lit4 sections can be | |
1648 | merged. */ | |
252b5132 | 1649 | |
c6e90b02 | 1650 | bfd_reloc_status_type |
11a2be4d RS |
1651 | _bfd_mips_elf32_gprel16_reloc (bfd *abfd, arelent *reloc_entry, |
1652 | asymbol *symbol, void *data, | |
1653 | asection *input_section, bfd *output_bfd, | |
1654 | char **error_message) | |
c6e90b02 | 1655 | { |
1049f94e | 1656 | bfd_boolean relocatable; |
c6e90b02 | 1657 | bfd_reloc_status_type ret; |
df58fc94 | 1658 | bfd_byte *location; |
c6e90b02 | 1659 | bfd_vma gp; |
252b5132 | 1660 | |
df58fc94 RS |
1661 | /* R_MIPS_LITERAL/R_MICROMIPS_LITERAL relocations are defined for local |
1662 | symbols only. */ | |
1663 | if (literal_reloc_p (reloc_entry->howto->type) | |
254f0426 MR |
1664 | && output_bfd != NULL |
1665 | && (symbol->flags & BSF_SECTION_SYM) == 0 | |
1666 | && (symbol->flags & BSF_LOCAL) != 0) | |
1667 | { | |
1668 | *error_message = (char *) | |
1669 | _("literal relocation occurs for an external symbol"); | |
1670 | return bfd_reloc_outofrange; | |
1671 | } | |
1672 | ||
11a2be4d | 1673 | if (output_bfd != NULL) |
1049f94e | 1674 | relocatable = TRUE; |
c6e90b02 TS |
1675 | else |
1676 | { | |
1049f94e | 1677 | relocatable = FALSE; |
c6e90b02 TS |
1678 | output_bfd = symbol->section->output_section->owner; |
1679 | } | |
252b5132 | 1680 | |
1049f94e | 1681 | ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message, |
c6e90b02 TS |
1682 | &gp); |
1683 | if (ret != bfd_reloc_ok) | |
1684 | return ret; | |
252b5132 | 1685 | |
df58fc94 RS |
1686 | location = (bfd_byte *) data + reloc_entry->address; |
1687 | _bfd_mips_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE, | |
1688 | location); | |
1689 | ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry, | |
1690 | input_section, relocatable, | |
1691 | data, gp); | |
1692 | _bfd_mips_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable, | |
1693 | location); | |
1694 | ||
1695 | return ret; | |
c6e90b02 | 1696 | } |
252b5132 | 1697 | |
cb7394f2 TS |
1698 | /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must |
1699 | become the offset from the gp register. */ | |
252b5132 | 1700 | |
c6e90b02 | 1701 | static bfd_reloc_status_type |
11a2be4d RS |
1702 | mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, |
1703 | void *data, asection *input_section, bfd *output_bfd, | |
1704 | char **error_message) | |
c6e90b02 | 1705 | { |
1049f94e | 1706 | bfd_boolean relocatable; |
c6e90b02 TS |
1707 | bfd_reloc_status_type ret; |
1708 | bfd_vma gp; | |
252b5132 | 1709 | |
765f2ef6 MR |
1710 | /* R_MIPS_GPREL32 relocations are defined for local symbols only. */ |
1711 | if (output_bfd != NULL | |
1712 | && (symbol->flags & BSF_SECTION_SYM) == 0 | |
1713 | && (symbol->flags & BSF_LOCAL) != 0) | |
1714 | { | |
1715 | *error_message = (char *) | |
1716 | _("32bits gp relative relocation occurs for an external symbol"); | |
1717 | return bfd_reloc_outofrange; | |
1718 | } | |
1719 | ||
11a2be4d | 1720 | if (output_bfd != NULL) |
1049f94e | 1721 | relocatable = TRUE; |
c6e90b02 TS |
1722 | else |
1723 | { | |
1049f94e | 1724 | relocatable = FALSE; |
c6e90b02 | 1725 | output_bfd = symbol->section->output_section->owner; |
c6e90b02 | 1726 | } |
252b5132 | 1727 | |
1049f94e | 1728 | ret = mips_elf_final_gp (output_bfd, symbol, relocatable, |
a7ebbfdf TS |
1729 | error_message, &gp); |
1730 | if (ret != bfd_reloc_ok) | |
1731 | return ret; | |
1732 | ||
c6e90b02 | 1733 | return gprel32_with_gp (abfd, symbol, reloc_entry, input_section, |
1049f94e | 1734 | relocatable, data, gp); |
c6e90b02 | 1735 | } |
252b5132 | 1736 | |
c6e90b02 | 1737 | static bfd_reloc_status_type |
11a2be4d RS |
1738 | gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry, |
1739 | asection *input_section, bfd_boolean relocatable, | |
1740 | void *data, bfd_vma gp) | |
c6e90b02 TS |
1741 | { |
1742 | bfd_vma relocation; | |
a7ebbfdf | 1743 | bfd_vma val; |
252b5132 | 1744 | |
c6e90b02 TS |
1745 | if (bfd_is_com_section (symbol->section)) |
1746 | relocation = 0; | |
1747 | else | |
1748 | relocation = symbol->value; | |
252b5132 | 1749 | |
c6e90b02 TS |
1750 | relocation += symbol->section->output_section->vma; |
1751 | relocation += symbol->section->output_offset; | |
252b5132 | 1752 | |
07515404 | 1753 | if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) |
c6e90b02 | 1754 | return bfd_reloc_outofrange; |
252b5132 | 1755 | |
c6e90b02 | 1756 | /* Set val to the offset into the section or symbol. */ |
a7ebbfdf TS |
1757 | val = reloc_entry->addend; |
1758 | ||
1759 | if (reloc_entry->howto->partial_inplace) | |
1760 | val += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address); | |
252b5132 | 1761 | |
c6e90b02 | 1762 | /* Adjust val for the final section location and GP value. If we |
1049f94e | 1763 | are producing relocatable output, we don't want to do this for |
c6e90b02 | 1764 | an external symbol. */ |
1049f94e | 1765 | if (! relocatable |
c6e90b02 TS |
1766 | || (symbol->flags & BSF_SECTION_SYM) != 0) |
1767 | val += relocation - gp; | |
252b5132 | 1768 | |
a7ebbfdf TS |
1769 | if (reloc_entry->howto->partial_inplace) |
1770 | bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address); | |
1771 | else | |
1772 | reloc_entry->addend = val; | |
c6142e5d | 1773 | |
1049f94e | 1774 | if (relocatable) |
c6e90b02 | 1775 | reloc_entry->address += input_section->output_offset; |
252b5132 | 1776 | |
c6e90b02 | 1777 | return bfd_reloc_ok; |
252b5132 RH |
1778 | } |
1779 | ||
c6e90b02 TS |
1780 | /* Handle a 64 bit reloc in a 32 bit MIPS ELF file. These are |
1781 | generated when addresses are 64 bits. The upper 32 bits are a simple | |
1782 | sign extension. */ | |
7403cb63 | 1783 | |
c6e90b02 | 1784 | static bfd_reloc_status_type |
30ac9238 RS |
1785 | mips32_64bit_reloc (bfd *abfd, arelent *reloc_entry, |
1786 | asymbol *symbol ATTRIBUTE_UNUSED, | |
1787 | void *data, asection *input_section, | |
1788 | bfd *output_bfd, char **error_message) | |
7403cb63 | 1789 | { |
c6e90b02 TS |
1790 | bfd_reloc_status_type r; |
1791 | arelent reloc32; | |
1792 | unsigned long val; | |
1793 | bfd_size_type addr; | |
7403cb63 | 1794 | |
c6e90b02 TS |
1795 | /* Do a normal 32 bit relocation on the lower 32 bits. */ |
1796 | reloc32 = *reloc_entry; | |
1797 | if (bfd_big_endian (abfd)) | |
1798 | reloc32.address += 4; | |
1799 | reloc32.howto = &elf_mips_howto_table_rel[R_MIPS_32]; | |
1800 | r = bfd_perform_relocation (abfd, &reloc32, data, input_section, | |
1801 | output_bfd, error_message); | |
be3ccd9c | 1802 | |
c6e90b02 TS |
1803 | /* Sign extend into the upper 32 bits. */ |
1804 | val = bfd_get_32 (abfd, (bfd_byte *) data + reloc32.address); | |
1805 | if ((val & 0x80000000) != 0) | |
1806 | val = 0xffffffff; | |
1807 | else | |
1808 | val = 0; | |
1809 | addr = reloc_entry->address; | |
1810 | if (bfd_little_endian (abfd)) | |
1811 | addr += 4; | |
11a2be4d | 1812 | bfd_put_32 (abfd, val, (bfd_byte *) data + addr); |
c6e90b02 TS |
1813 | |
1814 | return r; | |
7403cb63 MM |
1815 | } |
1816 | ||
c6e90b02 | 1817 | /* Handle a mips16 GP relative reloc. */ |
252b5132 | 1818 | |
c6e90b02 | 1819 | static bfd_reloc_status_type |
11a2be4d RS |
1820 | mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, |
1821 | void *data, asection *input_section, bfd *output_bfd, | |
1822 | char **error_message) | |
c6e90b02 | 1823 | { |
1049f94e | 1824 | bfd_boolean relocatable; |
c6e90b02 | 1825 | bfd_reloc_status_type ret; |
d6f16593 | 1826 | bfd_byte *location; |
c6e90b02 | 1827 | bfd_vma gp; |
252b5132 | 1828 | |
a7ebbfdf TS |
1829 | /* If we're relocating, and this is an external symbol, we don't want |
1830 | to change anything. */ | |
c6e90b02 TS |
1831 | if (output_bfd != NULL |
1832 | && (symbol->flags & BSF_SECTION_SYM) == 0 | |
a7ebbfdf | 1833 | && (symbol->flags & BSF_LOCAL) != 0) |
c6e90b02 TS |
1834 | { |
1835 | reloc_entry->address += input_section->output_offset; | |
1836 | return bfd_reloc_ok; | |
1837 | } | |
252b5132 | 1838 | |
c6e90b02 | 1839 | if (output_bfd != NULL) |
1049f94e | 1840 | relocatable = TRUE; |
c6e90b02 TS |
1841 | else |
1842 | { | |
1049f94e | 1843 | relocatable = FALSE; |
c6e90b02 | 1844 | output_bfd = symbol->section->output_section->owner; |
252b5132 RH |
1845 | } |
1846 | ||
1049f94e | 1847 | ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message, |
c6e90b02 TS |
1848 | &gp); |
1849 | if (ret != bfd_reloc_ok) | |
1850 | return ret; | |
252b5132 | 1851 | |
d6f16593 | 1852 | location = (bfd_byte *) data + reloc_entry->address; |
df58fc94 RS |
1853 | _bfd_mips_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE, |
1854 | location); | |
d6f16593 MR |
1855 | ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry, |
1856 | input_section, relocatable, | |
1857 | data, gp); | |
df58fc94 RS |
1858 | _bfd_mips_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable, |
1859 | location); | |
a7ebbfdf | 1860 | |
d6f16593 | 1861 | return ret; |
c6e90b02 | 1862 | } |
7403cb63 | 1863 | |
c6e90b02 | 1864 | /* A mapping from BFD reloc types to MIPS ELF reloc types. */ |
252b5132 | 1865 | |
c6e90b02 | 1866 | struct elf_reloc_map { |
cb7394f2 TS |
1867 | bfd_reloc_code_real_type bfd_val; |
1868 | enum elf_mips_reloc_type elf_val; | |
c6e90b02 | 1869 | }; |
252b5132 | 1870 | |
c6e90b02 TS |
1871 | static const struct elf_reloc_map mips_reloc_map[] = |
1872 | { | |
28458e7e | 1873 | { BFD_RELOC_NONE, R_MIPS_NONE }, |
c6e90b02 TS |
1874 | { BFD_RELOC_16, R_MIPS_16 }, |
1875 | { BFD_RELOC_32, R_MIPS_32 }, | |
cb7394f2 | 1876 | /* There is no BFD reloc for R_MIPS_REL32. */ |
c6e90b02 TS |
1877 | { BFD_RELOC_64, R_MIPS_64 }, |
1878 | { BFD_RELOC_MIPS_JMP, R_MIPS_26 }, | |
1879 | { BFD_RELOC_HI16_S, R_MIPS_HI16 }, | |
1880 | { BFD_RELOC_LO16, R_MIPS_LO16 }, | |
1881 | { BFD_RELOC_GPREL16, R_MIPS_GPREL16 }, | |
1882 | { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL }, | |
1883 | { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 }, | |
bad36eac | 1884 | { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 }, |
c6e90b02 TS |
1885 | { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 }, |
1886 | { BFD_RELOC_GPREL32, R_MIPS_GPREL32 }, | |
1887 | { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 }, | |
1888 | { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 }, | |
1889 | { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 }, | |
1890 | { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 }, | |
1891 | { BFD_RELOC_MIPS_SUB, R_MIPS_SUB }, | |
1892 | { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE }, | |
1893 | { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST }, | |
0f20cc35 | 1894 | { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP }, |
cd8d5a82 | 1895 | { BFD_RELOC_MIPS_JALR, R_MIPS_JALR }, |
0f20cc35 DJ |
1896 | { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 }, |
1897 | { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 }, | |
1898 | { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 }, | |
1899 | { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 }, | |
1900 | { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD }, | |
1901 | { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM }, | |
1902 | { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 }, | |
1903 | { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 }, | |
1904 | { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL }, | |
1905 | { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 }, | |
1906 | { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 }, | |
1907 | { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 }, | |
1908 | { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 } | |
c6e90b02 | 1909 | }; |
252b5132 | 1910 | |
d6f16593 MR |
1911 | static const struct elf_reloc_map mips16_reloc_map[] = |
1912 | { | |
1913 | { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min }, | |
1914 | { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min }, | |
738e5348 RS |
1915 | { BFD_RELOC_MIPS16_GOT16, R_MIPS16_GOT16 - R_MIPS16_min }, |
1916 | { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min }, | |
d6f16593 MR |
1917 | { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min }, |
1918 | { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min }, | |
d0f13682 CLT |
1919 | { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min }, |
1920 | { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min }, | |
1921 | { BFD_RELOC_MIPS16_TLS_DTPREL_HI16, | |
1922 | R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min }, | |
1923 | { BFD_RELOC_MIPS16_TLS_DTPREL_LO16, | |
1924 | R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min }, | |
1925 | { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min }, | |
1926 | { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min }, | |
1927 | { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min } | |
d6f16593 MR |
1928 | }; |
1929 | ||
df58fc94 RS |
1930 | static const struct elf_reloc_map micromips_reloc_map[] = |
1931 | { | |
1932 | { BFD_RELOC_MICROMIPS_JMP, R_MICROMIPS_26_S1 - R_MICROMIPS_min }, | |
1933 | { BFD_RELOC_MICROMIPS_HI16_S, R_MICROMIPS_HI16 - R_MICROMIPS_min }, | |
1934 | { BFD_RELOC_MICROMIPS_LO16, R_MICROMIPS_LO16 - R_MICROMIPS_min }, | |
1935 | { BFD_RELOC_MICROMIPS_GPREL16, R_MICROMIPS_GPREL16 - R_MICROMIPS_min }, | |
1936 | { BFD_RELOC_MICROMIPS_LITERAL, R_MICROMIPS_LITERAL - R_MICROMIPS_min }, | |
1937 | { BFD_RELOC_MICROMIPS_GOT16, R_MICROMIPS_GOT16 - R_MICROMIPS_min }, | |
1938 | { BFD_RELOC_MICROMIPS_7_PCREL_S1, R_MICROMIPS_PC7_S1 - R_MICROMIPS_min }, | |
1939 | { BFD_RELOC_MICROMIPS_10_PCREL_S1, R_MICROMIPS_PC10_S1 - R_MICROMIPS_min }, | |
1940 | { BFD_RELOC_MICROMIPS_16_PCREL_S1, R_MICROMIPS_PC16_S1 - R_MICROMIPS_min }, | |
1941 | { BFD_RELOC_MICROMIPS_CALL16, R_MICROMIPS_CALL16 - R_MICROMIPS_min }, | |
1942 | { BFD_RELOC_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_DISP - R_MICROMIPS_min }, | |
1943 | { BFD_RELOC_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_PAGE - R_MICROMIPS_min }, | |
1944 | { BFD_RELOC_MICROMIPS_GOT_OFST, R_MICROMIPS_GOT_OFST - R_MICROMIPS_min }, | |
1945 | { BFD_RELOC_MICROMIPS_GOT_HI16, R_MICROMIPS_GOT_HI16 - R_MICROMIPS_min }, | |
1946 | { BFD_RELOC_MICROMIPS_GOT_LO16, R_MICROMIPS_GOT_LO16 - R_MICROMIPS_min }, | |
1947 | { BFD_RELOC_MICROMIPS_SUB, R_MICROMIPS_SUB - R_MICROMIPS_min }, | |
1948 | { BFD_RELOC_MICROMIPS_HIGHER, R_MICROMIPS_HIGHER - R_MICROMIPS_min }, | |
1949 | { BFD_RELOC_MICROMIPS_HIGHEST, R_MICROMIPS_HIGHEST - R_MICROMIPS_min }, | |
1950 | { BFD_RELOC_MICROMIPS_CALL_HI16, R_MICROMIPS_CALL_HI16 - R_MICROMIPS_min }, | |
1951 | { BFD_RELOC_MICROMIPS_CALL_LO16, R_MICROMIPS_CALL_LO16 - R_MICROMIPS_min }, | |
1952 | { BFD_RELOC_MICROMIPS_SCN_DISP, R_MICROMIPS_SCN_DISP - R_MICROMIPS_min }, | |
1953 | { BFD_RELOC_MICROMIPS_JALR, R_MICROMIPS_JALR - R_MICROMIPS_min }, | |
1954 | /* There is no BFD reloc for R_MICROMIPS_HI0_LO16. */ | |
1955 | { BFD_RELOC_MICROMIPS_TLS_GD, R_MICROMIPS_TLS_GD - R_MICROMIPS_min }, | |
1956 | { BFD_RELOC_MICROMIPS_TLS_LDM, R_MICROMIPS_TLS_LDM - R_MICROMIPS_min }, | |
1957 | { BFD_RELOC_MICROMIPS_TLS_DTPREL_HI16, | |
1958 | R_MICROMIPS_TLS_DTPREL_HI16 - R_MICROMIPS_min }, | |
1959 | { BFD_RELOC_MICROMIPS_TLS_DTPREL_LO16, | |
1960 | R_MICROMIPS_TLS_DTPREL_LO16 - R_MICROMIPS_min }, | |
1961 | { BFD_RELOC_MICROMIPS_TLS_GOTTPREL, | |
1962 | R_MICROMIPS_TLS_GOTTPREL - R_MICROMIPS_min }, | |
1963 | { BFD_RELOC_MICROMIPS_TLS_TPREL_HI16, | |
1964 | R_MICROMIPS_TLS_TPREL_HI16 - R_MICROMIPS_min }, | |
1965 | { BFD_RELOC_MICROMIPS_TLS_TPREL_LO16, | |
1966 | R_MICROMIPS_TLS_TPREL_LO16 - R_MICROMIPS_min }, | |
1967 | /* There is no BFD reloc for R_MICROMIPS_GPREL7_S2. */ | |
1968 | /* There is no BFD reloc for R_MICROMIPS_PC23_S2. */ | |
1969 | }; | |
1970 | ||
c6e90b02 | 1971 | /* Given a BFD reloc type, return a howto structure. */ |
252b5132 | 1972 | |
c6e90b02 | 1973 | static reloc_howto_type * |
11a2be4d | 1974 | bfd_elf32_bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code) |
252b5132 | 1975 | { |
c6e90b02 | 1976 | unsigned int i; |
cb7394f2 | 1977 | reloc_howto_type *howto_table = elf_mips_howto_table_rel; |
d6f16593 | 1978 | reloc_howto_type *howto16_table = elf_mips16_howto_table_rel; |
df58fc94 | 1979 | reloc_howto_type *howto_micromips_table = elf_micromips_howto_table_rel; |
252b5132 | 1980 | |
cb7394f2 TS |
1981 | for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map); |
1982 | i++) | |
252b5132 | 1983 | { |
cb7394f2 TS |
1984 | if (mips_reloc_map[i].bfd_val == code) |
1985 | return &howto_table[(int) mips_reloc_map[i].elf_val]; | |
252b5132 RH |
1986 | } |
1987 | ||
d6f16593 MR |
1988 | for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map); |
1989 | i++) | |
1990 | { | |
1991 | if (mips16_reloc_map[i].bfd_val == code) | |
1992 | return &howto16_table[(int) mips16_reloc_map[i].elf_val]; | |
1993 | } | |
1994 | ||
df58fc94 RS |
1995 | for (i = 0; i < sizeof (micromips_reloc_map) / sizeof (struct elf_reloc_map); |
1996 | i++) | |
1997 | { | |
1998 | if (micromips_reloc_map[i].bfd_val == code) | |
1999 | return &howto_micromips_table[(int) micromips_reloc_map[i].elf_val]; | |
2000 | } | |
2001 | ||
c6e90b02 | 2002 | switch (code) |
252b5132 | 2003 | { |
c6e90b02 TS |
2004 | default: |
2005 | bfd_set_error (bfd_error_bad_value); | |
2006 | return NULL; | |
252b5132 | 2007 | |
c6e90b02 TS |
2008 | case BFD_RELOC_CTOR: |
2009 | /* We need to handle BFD_RELOC_CTOR specially. | |
2010 | Select the right relocation (R_MIPS_32 or R_MIPS_64) based on the | |
69931e60 AO |
2011 | size of addresses of the ABI. */ |
2012 | if ((elf_elfheader (abfd)->e_flags & (E_MIPS_ABI_O64 | |
2013 | | E_MIPS_ABI_EABI64)) != 0) | |
c6e90b02 | 2014 | return &elf_mips_ctor64_howto; |
69931e60 AO |
2015 | else |
2016 | return &howto_table[(int) R_MIPS_32]; | |
252b5132 | 2017 | |
c6e90b02 TS |
2018 | case BFD_RELOC_VTABLE_INHERIT: |
2019 | return &elf_mips_gnu_vtinherit_howto; | |
2020 | case BFD_RELOC_VTABLE_ENTRY: | |
2021 | return &elf_mips_gnu_vtentry_howto; | |
092dcd75 CD |
2022 | case BFD_RELOC_32_PCREL: |
2023 | return &elf_mips_gnu_pcrel32; | |
861fb55a DJ |
2024 | case BFD_RELOC_MIPS_COPY: |
2025 | return &elf_mips_copy_howto; | |
2026 | case BFD_RELOC_MIPS_JUMP_SLOT: | |
2027 | return &elf_mips_jump_slot_howto; | |
067ec077 CM |
2028 | case BFD_RELOC_MIPS_EH: |
2029 | return &elf_mips_eh_howto; | |
c6e90b02 TS |
2030 | } |
2031 | } | |
252b5132 | 2032 | |
157090f7 AM |
2033 | static reloc_howto_type * |
2034 | bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, | |
2035 | const char *r_name) | |
2036 | { | |
2037 | unsigned int i; | |
2038 | ||
2039 | for (i = 0; | |
2040 | i < (sizeof (elf_mips_howto_table_rel) | |
2041 | / sizeof (elf_mips_howto_table_rel[0])); | |
2042 | i++) | |
2043 | if (elf_mips_howto_table_rel[i].name != NULL | |
2044 | && strcasecmp (elf_mips_howto_table_rel[i].name, r_name) == 0) | |
2045 | return &elf_mips_howto_table_rel[i]; | |
2046 | ||
2047 | for (i = 0; | |
2048 | i < (sizeof (elf_mips16_howto_table_rel) | |
2049 | / sizeof (elf_mips16_howto_table_rel[0])); | |
2050 | i++) | |
2051 | if (elf_mips16_howto_table_rel[i].name != NULL | |
2052 | && strcasecmp (elf_mips16_howto_table_rel[i].name, r_name) == 0) | |
2053 | return &elf_mips16_howto_table_rel[i]; | |
2054 | ||
df58fc94 RS |
2055 | for (i = 0; |
2056 | i < (sizeof (elf_micromips_howto_table_rel) | |
2057 | / sizeof (elf_micromips_howto_table_rel[0])); | |
2058 | i++) | |
2059 | if (elf_micromips_howto_table_rel[i].name != NULL | |
2060 | && strcasecmp (elf_micromips_howto_table_rel[i].name, r_name) == 0) | |
2061 | return &elf_micromips_howto_table_rel[i]; | |
2062 | ||
157090f7 AM |
2063 | if (strcasecmp (elf_mips_gnu_pcrel32.name, r_name) == 0) |
2064 | return &elf_mips_gnu_pcrel32; | |
2065 | if (strcasecmp (elf_mips_gnu_rel16_s2.name, r_name) == 0) | |
2066 | return &elf_mips_gnu_rel16_s2; | |
2067 | if (strcasecmp (elf_mips_gnu_vtinherit_howto.name, r_name) == 0) | |
2068 | return &elf_mips_gnu_vtinherit_howto; | |
2069 | if (strcasecmp (elf_mips_gnu_vtentry_howto.name, r_name) == 0) | |
2070 | return &elf_mips_gnu_vtentry_howto; | |
861fb55a DJ |
2071 | if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0) |
2072 | return &elf_mips_copy_howto; | |
2073 | if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0) | |
2074 | return &elf_mips_jump_slot_howto; | |
067ec077 CM |
2075 | if (strcasecmp (elf_mips_eh_howto.name, r_name) == 0) |
2076 | return &elf_mips_eh_howto; | |
157090f7 AM |
2077 | |
2078 | return NULL; | |
2079 | } | |
2080 | ||
947216bf | 2081 | /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */ |
252b5132 | 2082 | |
c6e90b02 | 2083 | static reloc_howto_type * |
11a2be4d RS |
2084 | mips_elf32_rtype_to_howto (unsigned int r_type, |
2085 | bfd_boolean rela_p ATTRIBUTE_UNUSED) | |
c6e90b02 TS |
2086 | { |
2087 | switch (r_type) | |
2088 | { | |
c6e90b02 TS |
2089 | case R_MIPS_GNU_VTINHERIT: |
2090 | return &elf_mips_gnu_vtinherit_howto; | |
c6e90b02 TS |
2091 | case R_MIPS_GNU_VTENTRY: |
2092 | return &elf_mips_gnu_vtentry_howto; | |
c6e90b02 TS |
2093 | case R_MIPS_GNU_REL16_S2: |
2094 | return &elf_mips_gnu_rel16_s2; | |
092dcd75 CD |
2095 | case R_MIPS_PC32: |
2096 | return &elf_mips_gnu_pcrel32; | |
861fb55a DJ |
2097 | case R_MIPS_COPY: |
2098 | return &elf_mips_copy_howto; | |
2099 | case R_MIPS_JUMP_SLOT: | |
2100 | return &elf_mips_jump_slot_howto; | |
067ec077 CM |
2101 | case R_MIPS_EH: |
2102 | return &elf_mips_eh_howto; | |
c6e90b02 | 2103 | default: |
df58fc94 RS |
2104 | if (r_type >= R_MICROMIPS_min && r_type < R_MICROMIPS_max) |
2105 | return &elf_micromips_howto_table_rel[r_type - R_MICROMIPS_min]; | |
d6f16593 MR |
2106 | if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max) |
2107 | return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min]; | |
c6e90b02 TS |
2108 | BFD_ASSERT (r_type < (unsigned int) R_MIPS_max); |
2109 | return &elf_mips_howto_table_rel[r_type]; | |
2110 | } | |
2111 | } | |
252b5132 | 2112 | |
947216bf | 2113 | /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */ |
252b5132 | 2114 | |
c6e90b02 | 2115 | static void |
11a2be4d | 2116 | mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) |
c6e90b02 | 2117 | { |
0a44bf69 | 2118 | const struct elf_backend_data *bed; |
c6e90b02 | 2119 | unsigned int r_type; |
252b5132 | 2120 | |
c6e90b02 | 2121 | r_type = ELF32_R_TYPE (dst->r_info); |
0a44bf69 RS |
2122 | bed = get_elf_backend_data (abfd); |
2123 | cache_ptr->howto = bed->elf_backend_mips_rtype_to_howto (r_type, FALSE); | |
252b5132 | 2124 | |
c6e90b02 TS |
2125 | /* The addend for a GPREL16 or LITERAL relocation comes from the GP |
2126 | value for the object file. We get the addend now, rather than | |
2127 | when we do the relocation, because the symbol manipulations done | |
2128 | by the linker may cause us to lose track of the input BFD. */ | |
2129 | if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0 | |
df58fc94 | 2130 | && (gprel16_reloc_p (r_type) || literal_reloc_p (r_type))) |
c6e90b02 TS |
2131 | cache_ptr->addend = elf_gp (abfd); |
2132 | } | |
5499724a | 2133 | |
947216bf | 2134 | /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */ |
252b5132 | 2135 | |
c6e90b02 | 2136 | static void |
11a2be4d | 2137 | mips_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) |
c6e90b02 | 2138 | { |
947216bf | 2139 | mips_info_to_howto_rel (abfd, cache_ptr, dst); |
252b5132 | 2140 | |
c6e90b02 | 2141 | /* If we ever need to do any extra processing with dst->r_addend |
947216bf | 2142 | (the field omitted in an Elf_Internal_Rel) we can do it here. */ |
c6e90b02 TS |
2143 | } |
2144 | \f | |
2145 | /* Determine whether a symbol is global for the purposes of splitting | |
2146 | the symbol table into global symbols and local symbols. At least | |
2147 | on Irix 5, this split must be between section symbols and all other | |
2148 | symbols. On most ELF targets the split is between static symbols | |
2149 | and externally visible symbols. */ | |
252b5132 | 2150 | |
b34976b6 | 2151 | static bfd_boolean |
11a2be4d | 2152 | mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym) |
c6e90b02 TS |
2153 | { |
2154 | if (SGI_COMPAT (abfd)) | |
2155 | return (sym->flags & BSF_SECTION_SYM) == 0; | |
2156 | else | |
e47bf690 | 2157 | return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0 |
c6e90b02 TS |
2158 | || bfd_is_und_section (bfd_get_section (sym)) |
2159 | || bfd_is_com_section (bfd_get_section (sym))); | |
2160 | } | |
2161 | \f | |
2162 | /* Set the right machine number for a MIPS ELF file. */ | |
7403cb63 | 2163 | |
b34976b6 | 2164 | static bfd_boolean |
11a2be4d | 2165 | mips_elf32_object_p (bfd *abfd) |
c6e90b02 TS |
2166 | { |
2167 | unsigned long mach; | |
103186c6 | 2168 | |
dd2bed3a MR |
2169 | if (ABI_N32_P (abfd)) |
2170 | return FALSE; | |
2171 | ||
c6e90b02 TS |
2172 | /* Irix 5 and 6 are broken. Object file symbol tables are not always |
2173 | sorted correctly such that local symbols precede global symbols, | |
2174 | and the sh_info field in the symbol table is not always right. */ | |
2175 | if (SGI_COMPAT (abfd)) | |
b34976b6 | 2176 | elf_bad_symtab (abfd) = TRUE; |
103186c6 | 2177 | |
c6e90b02 TS |
2178 | mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags); |
2179 | bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach); | |
b34976b6 | 2180 | return TRUE; |
c6e90b02 TS |
2181 | } |
2182 | \f | |
2183 | /* MIPS ELF local labels start with '$', not 'L'. */ | |
252b5132 | 2184 | |
b34976b6 | 2185 | static bfd_boolean |
11a2be4d | 2186 | mips_elf_is_local_label_name (bfd *abfd, const char *name) |
c6e90b02 TS |
2187 | { |
2188 | if (name[0] == '$') | |
b34976b6 | 2189 | return TRUE; |
252b5132 | 2190 | |
c6e90b02 TS |
2191 | /* On Irix 6, the labels go back to starting with '.', so we accept |
2192 | the generic ELF local label syntax as well. */ | |
2193 | return _bfd_elf_is_local_label_name (abfd, name); | |
252b5132 RH |
2194 | } |
2195 | \f | |
c6e90b02 | 2196 | /* Support for core dump NOTE sections. */ |
b34976b6 | 2197 | static bfd_boolean |
11a2be4d | 2198 | elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) |
bb0082d6 AM |
2199 | { |
2200 | int offset; | |
eea6121a | 2201 | unsigned int size; |
bb0082d6 AM |
2202 | |
2203 | switch (note->descsz) | |
2204 | { | |
2205 | default: | |
b34976b6 | 2206 | return FALSE; |
bb0082d6 AM |
2207 | |
2208 | case 256: /* Linux/MIPS */ | |
2209 | /* pr_cursig */ | |
228e534f | 2210 | elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12); |
bb0082d6 AM |
2211 | |
2212 | /* pr_pid */ | |
228e534f | 2213 | elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24); |
bb0082d6 AM |
2214 | |
2215 | /* pr_reg */ | |
2216 | offset = 72; | |
eea6121a | 2217 | size = 180; |
bb0082d6 AM |
2218 | |
2219 | break; | |
2220 | } | |
2221 | ||
2222 | /* Make a ".reg/999" section. */ | |
936e320b | 2223 | return _bfd_elfcore_make_pseudosection (abfd, ".reg", |
eea6121a | 2224 | size, note->descpos + offset); |
bb0082d6 AM |
2225 | } |
2226 | ||
b34976b6 | 2227 | static bfd_boolean |
11a2be4d | 2228 | elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) |
bb0082d6 AM |
2229 | { |
2230 | switch (note->descsz) | |
2231 | { | |
2232 | default: | |
b34976b6 | 2233 | return FALSE; |
bb0082d6 AM |
2234 | |
2235 | case 128: /* Linux/MIPS elf_prpsinfo */ | |
228e534f | 2236 | elf_tdata (abfd)->core->program |
bb0082d6 | 2237 | = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16); |
228e534f | 2238 | elf_tdata (abfd)->core->command |
bb0082d6 AM |
2239 | = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80); |
2240 | } | |
2241 | ||
2242 | /* Note that for some reason, a spurious space is tacked | |
2243 | onto the end of the args in some (at least one anyway) | |
2244 | implementations, so strip it off if it exists. */ | |
2245 | ||
2246 | { | |
228e534f | 2247 | char *command = elf_tdata (abfd)->core->command; |
bb0082d6 AM |
2248 | int n = strlen (command); |
2249 | ||
2250 | if (0 < n && command[n - 1] == ' ') | |
2251 | command[n - 1] = '\0'; | |
2252 | } | |
2253 | ||
b34976b6 | 2254 | return TRUE; |
bb0082d6 AM |
2255 | } |
2256 | \f | |
c6e90b02 TS |
2257 | /* Depending on the target vector we generate some version of Irix |
2258 | executables or "normal" MIPS ELF ABI executables. */ | |
2259 | static irix_compat_t | |
11a2be4d | 2260 | elf32_mips_irix_compat (bfd *abfd) |
c6e90b02 | 2261 | { |
cb7394f2 TS |
2262 | if ((abfd->xvec == &bfd_elf32_bigmips_vec) |
2263 | || (abfd->xvec == &bfd_elf32_littlemips_vec)) | |
c6e90b02 | 2264 | return ict_irix5; |
cb7394f2 TS |
2265 | else |
2266 | return ict_none; | |
c6e90b02 | 2267 | } |
73d074b4 | 2268 | \f |
252b5132 RH |
2269 | /* ECOFF swapping routines. These are used when dealing with the |
2270 | .mdebug section, which is in the ECOFF debugging format. */ | |
be3ccd9c | 2271 | static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = { |
252b5132 RH |
2272 | /* Symbol table magic number. */ |
2273 | magicSym, | |
2274 | /* Alignment of debugging information. E.g., 4. */ | |
2275 | 4, | |
2276 | /* Sizes of external symbolic information. */ | |
2277 | sizeof (struct hdr_ext), | |
2278 | sizeof (struct dnr_ext), | |
2279 | sizeof (struct pdr_ext), | |
2280 | sizeof (struct sym_ext), | |
2281 | sizeof (struct opt_ext), | |
2282 | sizeof (struct fdr_ext), | |
2283 | sizeof (struct rfd_ext), | |
2284 | sizeof (struct ext_ext), | |
2285 | /* Functions to swap in external symbolic data. */ | |
2286 | ecoff_swap_hdr_in, | |
2287 | ecoff_swap_dnr_in, | |
2288 | ecoff_swap_pdr_in, | |
2289 | ecoff_swap_sym_in, | |
2290 | ecoff_swap_opt_in, | |
2291 | ecoff_swap_fdr_in, | |
2292 | ecoff_swap_rfd_in, | |
2293 | ecoff_swap_ext_in, | |
2294 | _bfd_ecoff_swap_tir_in, | |
2295 | _bfd_ecoff_swap_rndx_in, | |
2296 | /* Functions to swap out external symbolic data. */ | |
2297 | ecoff_swap_hdr_out, | |
2298 | ecoff_swap_dnr_out, | |
2299 | ecoff_swap_pdr_out, | |
2300 | ecoff_swap_sym_out, | |
2301 | ecoff_swap_opt_out, | |
2302 | ecoff_swap_fdr_out, | |
2303 | ecoff_swap_rfd_out, | |
2304 | ecoff_swap_ext_out, | |
2305 | _bfd_ecoff_swap_tir_out, | |
2306 | _bfd_ecoff_swap_rndx_out, | |
2307 | /* Function to read in symbolic data. */ | |
2308 | _bfd_mips_elf_read_ecoff_info | |
2309 | }; | |
2310 | \f | |
252b5132 | 2311 | #define ELF_ARCH bfd_arch_mips |
ae95ffa6 | 2312 | #define ELF_TARGET_ID MIPS_ELF_DATA |
252b5132 RH |
2313 | #define ELF_MACHINE_CODE EM_MIPS |
2314 | ||
b34976b6 AM |
2315 | #define elf_backend_collect TRUE |
2316 | #define elf_backend_type_change_ok TRUE | |
2317 | #define elf_backend_can_gc_sections TRUE | |
3f830999 | 2318 | #define elf_info_to_howto mips_info_to_howto_rela |
252b5132 RH |
2319 | #define elf_info_to_howto_rel mips_info_to_howto_rel |
2320 | #define elf_backend_sym_is_global mips_elf_sym_is_global | |
c6e90b02 | 2321 | #define elf_backend_object_p mips_elf32_object_p |
d75bc93d TS |
2322 | #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing |
2323 | #define elf_backend_section_processing _bfd_mips_elf_section_processing | |
103186c6 | 2324 | #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr |
252b5132 RH |
2325 | #define elf_backend_fake_sections _bfd_mips_elf_fake_sections |
2326 | #define elf_backend_section_from_bfd_section \ | |
2327 | _bfd_mips_elf_section_from_bfd_section | |
103186c6 | 2328 | #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook |
d75bc93d TS |
2329 | #define elf_backend_link_output_symbol_hook \ |
2330 | _bfd_mips_elf_link_output_symbol_hook | |
103186c6 MM |
2331 | #define elf_backend_create_dynamic_sections \ |
2332 | _bfd_mips_elf_create_dynamic_sections | |
2333 | #define elf_backend_check_relocs _bfd_mips_elf_check_relocs | |
8992f0d7 TS |
2334 | #define elf_backend_merge_symbol_attribute \ |
2335 | _bfd_mips_elf_merge_symbol_attribute | |
ad9563d6 | 2336 | #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag |
103186c6 MM |
2337 | #define elf_backend_adjust_dynamic_symbol \ |
2338 | _bfd_mips_elf_adjust_dynamic_symbol | |
2339 | #define elf_backend_always_size_sections \ | |
2340 | _bfd_mips_elf_always_size_sections | |
2341 | #define elf_backend_size_dynamic_sections \ | |
2342 | _bfd_mips_elf_size_dynamic_sections | |
74541ad4 | 2343 | #define elf_backend_init_index_section _bfd_elf_init_1_index_section |
103186c6 | 2344 | #define elf_backend_relocate_section _bfd_mips_elf_relocate_section |
103186c6 MM |
2345 | #define elf_backend_finish_dynamic_symbol \ |
2346 | _bfd_mips_elf_finish_dynamic_symbol | |
2347 | #define elf_backend_finish_dynamic_sections \ | |
2348 | _bfd_mips_elf_finish_dynamic_sections | |
d75bc93d TS |
2349 | #define elf_backend_final_write_processing \ |
2350 | _bfd_mips_elf_final_write_processing | |
2351 | #define elf_backend_additional_program_headers \ | |
2352 | _bfd_mips_elf_additional_program_headers | |
2353 | #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map | |
103186c6 MM |
2354 | #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook |
2355 | #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook | |
8a20f077 UC |
2356 | #define elf_backend_copy_indirect_symbol \ |
2357 | _bfd_mips_elf_copy_indirect_symbol | |
c6e90b02 TS |
2358 | #define elf_backend_grok_prstatus elf32_mips_grok_prstatus |
2359 | #define elf_backend_grok_psinfo elf32_mips_grok_psinfo | |
d75bc93d TS |
2360 | #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap |
2361 | ||
2362 | #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO) | |
d75bc93d TS |
2363 | #define elf_backend_may_use_rel_p 1 |
2364 | #define elf_backend_may_use_rela_p 0 | |
2365 | #define elf_backend_default_use_rela_p 0 | |
b34976b6 | 2366 | #define elf_backend_sign_extend_vma TRUE |
861fb55a | 2367 | #define elf_backend_plt_readonly 1 |
b305ef96 | 2368 | |
d01414a5 | 2369 | #define elf_backend_discard_info _bfd_mips_elf_discard_info |
73d074b4 | 2370 | #define elf_backend_ignore_discarded_relocs \ |
53bfd6b4 | 2371 | _bfd_mips_elf_ignore_discarded_relocs |
20163277 | 2372 | #define elf_backend_write_section _bfd_mips_elf_write_section |
c6e90b02 TS |
2373 | #define elf_backend_mips_irix_compat elf32_mips_irix_compat |
2374 | #define elf_backend_mips_rtype_to_howto mips_elf32_rtype_to_howto | |
252b5132 RH |
2375 | #define bfd_elf32_bfd_is_local_label_name \ |
2376 | mips_elf_is_local_label_name | |
df58fc94 RS |
2377 | #define bfd_elf32_bfd_is_target_special_symbol \ |
2378 | _bfd_mips_elf_is_target_special_symbol | |
1bbce132 | 2379 | #define bfd_elf32_get_synthetic_symtab _bfd_mips_elf_get_synthetic_symtab |
252b5132 | 2380 | #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line |
4ab527b0 | 2381 | #define bfd_elf32_find_inliner_info _bfd_mips_elf_find_inliner_info |
f0abc2a1 | 2382 | #define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook |
252b5132 | 2383 | #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents |
c6e90b02 TS |
2384 | #define bfd_elf32_bfd_get_relocated_section_contents \ |
2385 | _bfd_elf_mips_get_relocated_section_contents | |
252b5132 | 2386 | #define bfd_elf32_bfd_link_hash_table_create \ |
103186c6 MM |
2387 | _bfd_mips_elf_link_hash_table_create |
2388 | #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link | |
252b5132 RH |
2389 | #define bfd_elf32_bfd_merge_private_bfd_data \ |
2390 | _bfd_mips_elf_merge_private_bfd_data | |
2391 | #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags | |
2392 | #define bfd_elf32_bfd_print_private_bfd_data \ | |
2393 | _bfd_mips_elf_print_private_bfd_data | |
df58fc94 | 2394 | #define bfd_elf32_bfd_relax_section _bfd_mips_elf_relax_section |
6ae68ba3 | 2395 | #define bfd_elf32_mkobject _bfd_mips_elf_mkobject |
e364195d | 2396 | |
d75bc93d TS |
2397 | /* Support for SGI-ish mips targets. */ |
2398 | #define TARGET_LITTLE_SYM bfd_elf32_littlemips_vec | |
2399 | #define TARGET_LITTLE_NAME "elf32-littlemips" | |
2400 | #define TARGET_BIG_SYM bfd_elf32_bigmips_vec | |
2401 | #define TARGET_BIG_NAME "elf32-bigmips" | |
2402 | ||
4301eeb1 MR |
2403 | /* The SVR4 MIPS ABI says that this should be 0x10000, but Irix 5 uses |
2404 | a value of 0x1000, and we are compatible. */ | |
2405 | #define ELF_MAXPAGESIZE 0x1000 | |
24718e3b | 2406 | #define ELF_COMMONPAGESIZE 0x1000 |
4301eeb1 | 2407 | |
d75bc93d | 2408 | #include "elf32-target.h" |
e364195d | 2409 | |
d75bc93d | 2410 | /* Support for traditional mips targets. */ |
e364195d UC |
2411 | #undef TARGET_LITTLE_SYM |
2412 | #undef TARGET_LITTLE_NAME | |
2413 | #undef TARGET_BIG_SYM | |
2414 | #undef TARGET_BIG_NAME | |
2415 | ||
4301eeb1 | 2416 | #undef ELF_MAXPAGESIZE |
7fd91fe0 | 2417 | #undef ELF_COMMONPAGESIZE |
4301eeb1 | 2418 | |
e364195d UC |
2419 | #define TARGET_LITTLE_SYM bfd_elf32_tradlittlemips_vec |
2420 | #define TARGET_LITTLE_NAME "elf32-tradlittlemips" | |
2421 | #define TARGET_BIG_SYM bfd_elf32_tradbigmips_vec | |
2422 | #define TARGET_BIG_NAME "elf32-tradbigmips" | |
2423 | ||
7fd91fe0 TS |
2424 | /* The MIPS ABI says at Page 5-1: |
2425 | Virtual addresses and file offsets for MIPS segments are congruent | |
2426 | modulo 64 KByte (0x10000) or larger powers of 2. Because 64 KBytes | |
2427 | is the maximum page size, the files are suitable for paging | |
2428 | regardless of physical page size. */ | |
4301eeb1 | 2429 | #define ELF_MAXPAGESIZE 0x10000 |
7fd91fe0 | 2430 | #define ELF_COMMONPAGESIZE 0x1000 |
4301eeb1 MR |
2431 | #define elf32_bed elf32_tradbed |
2432 | ||
c6e90b02 | 2433 | /* Include the target file again for this target. */ |
e364195d | 2434 | #include "elf32-target.h" |
0a44bf69 | 2435 | |
aeffff67 RS |
2436 | /* FreeBSD support. */ |
2437 | ||
2438 | #undef TARGET_LITTLE_SYM | |
2439 | #undef TARGET_LITTLE_NAME | |
2440 | #undef TARGET_BIG_SYM | |
2441 | #undef TARGET_BIG_NAME | |
2442 | ||
2443 | #define TARGET_LITTLE_SYM bfd_elf32_tradlittlemips_freebsd_vec | |
2444 | #define TARGET_LITTLE_NAME "elf32-tradlittlemips-freebsd" | |
2445 | #define TARGET_BIG_SYM bfd_elf32_tradbigmips_freebsd_vec | |
2446 | #define TARGET_BIG_NAME "elf32-tradbigmips-freebsd" | |
2447 | ||
2448 | #undef ELF_OSABI | |
2449 | #define ELF_OSABI ELFOSABI_FREEBSD | |
2450 | ||
aeffff67 RS |
2451 | #undef elf32_bed |
2452 | #define elf32_bed elf32_fbsd_tradbed | |
2453 | ||
2454 | #include "elf32-target.h" | |
0a44bf69 RS |
2455 | /* Implement elf_backend_final_write_processing for VxWorks. */ |
2456 | ||
2457 | static void | |
2458 | mips_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker) | |
2459 | { | |
2460 | _bfd_mips_elf_final_write_processing (abfd, linker); | |
2461 | elf_vxworks_final_write_processing (abfd, linker); | |
2462 | } | |
2463 | ||
2464 | #undef TARGET_LITTLE_SYM | |
2465 | #undef TARGET_LITTLE_NAME | |
2466 | #undef TARGET_BIG_SYM | |
2467 | #undef TARGET_BIG_NAME | |
2468 | ||
7fd91fe0 TS |
2469 | #undef ELF_MAXPAGESIZE |
2470 | #undef ELF_COMMONPAGESIZE | |
2471 | ||
0a44bf69 RS |
2472 | #define TARGET_LITTLE_SYM bfd_elf32_littlemips_vxworks_vec |
2473 | #define TARGET_LITTLE_NAME "elf32-littlemips-vxworks" | |
2474 | #define TARGET_BIG_SYM bfd_elf32_bigmips_vxworks_vec | |
2475 | #define TARGET_BIG_NAME "elf32-bigmips-vxworks" | |
91ea67ca | 2476 | #undef ELF_OSABI |
0a44bf69 RS |
2477 | |
2478 | #undef elf32_bed | |
2479 | #define elf32_bed elf32_mips_vxworks_bed | |
2480 | ||
0a44bf69 | 2481 | #define ELF_MAXPAGESIZE 0x1000 |
7fd91fe0 | 2482 | #define ELF_COMMONPAGESIZE 0x1000 |
0a44bf69 RS |
2483 | |
2484 | #undef elf_backend_want_got_plt | |
2485 | #define elf_backend_want_got_plt 1 | |
2486 | #undef elf_backend_want_plt_sym | |
2487 | #define elf_backend_want_plt_sym 1 | |
0a44bf69 RS |
2488 | #undef elf_backend_may_use_rel_p |
2489 | #define elf_backend_may_use_rel_p 0 | |
2490 | #undef elf_backend_may_use_rela_p | |
2491 | #define elf_backend_may_use_rela_p 1 | |
2492 | #undef elf_backend_default_use_rela_p | |
2493 | #define elf_backend_default_use_rela_p 1 | |
2494 | #undef elf_backend_got_header_size | |
2495 | #define elf_backend_got_header_size (4 * 3) | |
861fb55a | 2496 | |
0a44bf69 RS |
2497 | #undef elf_backend_finish_dynamic_symbol |
2498 | #define elf_backend_finish_dynamic_symbol \ | |
2499 | _bfd_mips_vxworks_finish_dynamic_symbol | |
2500 | #undef bfd_elf32_bfd_link_hash_table_create | |
2501 | #define bfd_elf32_bfd_link_hash_table_create \ | |
2502 | _bfd_mips_vxworks_link_hash_table_create | |
2503 | #undef elf_backend_add_symbol_hook | |
2504 | #define elf_backend_add_symbol_hook \ | |
2505 | elf_vxworks_add_symbol_hook | |
2506 | #undef elf_backend_link_output_symbol_hook | |
2507 | #define elf_backend_link_output_symbol_hook \ | |
2508 | elf_vxworks_link_output_symbol_hook | |
2509 | #undef elf_backend_emit_relocs | |
2510 | #define elf_backend_emit_relocs \ | |
2511 | elf_vxworks_emit_relocs | |
2512 | #undef elf_backend_final_write_processing | |
2513 | #define elf_backend_final_write_processing \ | |
2514 | mips_vxworks_final_write_processing | |
2515 | ||
2516 | #undef elf_backend_additional_program_headers | |
2517 | #undef elf_backend_modify_segment_map | |
2518 | #undef elf_backend_symbol_processing | |
2519 | /* NOTE: elf_backend_rela_normal is not defined for MIPS. */ | |
2520 | ||
1bbce132 MR |
2521 | #undef bfd_elf32_get_synthetic_symtab |
2522 | ||
0a44bf69 | 2523 | #include "elf32-target.h" |