elfn32-mips.c revision 1.1 1 1.1 christos /* MIPS-specific support for 32-bit ELF
2 1.1 christos Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 1.1 christos 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4 1.1 christos
5 1.1 christos Most of the information added by Ian Lance Taylor, Cygnus Support,
6 1.1 christos <ian (at) cygnus.com>.
7 1.1 christos N32/64 ABI support added by Mark Mitchell, CodeSourcery, LLC.
8 1.1 christos <mark (at) codesourcery.com>
9 1.1 christos Traditional MIPS targets support added by Koundinya.K, Dansk Data
10 1.1 christos Elektronik & Operations Research Group. <kk (at) ddeorg.soft.net>
11 1.1 christos
12 1.1 christos This file is part of BFD, the Binary File Descriptor library.
13 1.1 christos
14 1.1 christos This program is free software; you can redistribute it and/or modify
15 1.1 christos it under the terms of the GNU General Public License as published by
16 1.1 christos the Free Software Foundation; either version 3 of the License, or
17 1.1 christos (at your option) any later version.
18 1.1 christos
19 1.1 christos This program is distributed in the hope that it will be useful,
20 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
21 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 1.1 christos GNU General Public License for more details.
23 1.1 christos
24 1.1 christos You should have received a copy of the GNU General Public License
25 1.1 christos along with this program; if not, write to the Free Software
26 1.1 christos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
27 1.1 christos MA 02110-1301, USA. */
28 1.1 christos
29 1.1 christos
30 1.1 christos /* This file handles MIPS ELF targets. SGI Irix 5 uses a slightly
31 1.1 christos different MIPS ELF from other targets. This matters when linking.
32 1.1 christos This file supports both, switching at runtime. */
33 1.1 christos
34 1.1 christos #include "sysdep.h"
35 1.1 christos #include "bfd.h"
36 1.1 christos #include "libbfd.h"
37 1.1 christos #include "bfdlink.h"
38 1.1 christos #include "genlink.h"
39 1.1 christos #include "elf-bfd.h"
40 1.1 christos #include "elfxx-mips.h"
41 1.1 christos #include "elf/mips.h"
42 1.1 christos
43 1.1 christos /* Get the ECOFF swapping routines. */
44 1.1 christos #include "coff/sym.h"
45 1.1 christos #include "coff/symconst.h"
46 1.1 christos #include "coff/internal.h"
47 1.1 christos #include "coff/ecoff.h"
48 1.1 christos #include "coff/mips.h"
49 1.1 christos #define ECOFF_SIGNED_32
50 1.1 christos #include "ecoffswap.h"
51 1.1 christos
52 1.1 christos static bfd_boolean mips_elf_assign_gp
53 1.1 christos (bfd *, bfd_vma *);
54 1.1 christos static bfd_reloc_status_type mips_elf_final_gp
55 1.1 christos (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *);
56 1.1 christos static bfd_reloc_status_type mips_elf_gprel16_reloc
57 1.1 christos (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
58 1.1 christos static bfd_reloc_status_type mips_elf_literal_reloc
59 1.1 christos (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
60 1.1 christos static bfd_reloc_status_type mips_elf_gprel32_reloc
61 1.1 christos (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
62 1.1 christos static bfd_reloc_status_type gprel32_with_gp
63 1.1 christos (bfd *, asymbol *, arelent *, asection *, bfd_boolean, void *, bfd_vma);
64 1.1 christos static bfd_reloc_status_type mips_elf_shift6_reloc
65 1.1 christos (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
66 1.1 christos static bfd_reloc_status_type mips16_gprel_reloc
67 1.1 christos (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
68 1.1 christos static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
69 1.1 christos (bfd *, bfd_reloc_code_real_type);
70 1.1 christos static reloc_howto_type *mips_elf_n32_rtype_to_howto
71 1.1 christos (unsigned int, bfd_boolean);
72 1.1 christos static void mips_info_to_howto_rel
73 1.1 christos (bfd *, arelent *, Elf_Internal_Rela *);
74 1.1 christos static void mips_info_to_howto_rela
75 1.1 christos (bfd *, arelent *, Elf_Internal_Rela *);
76 1.1 christos static bfd_boolean mips_elf_sym_is_global
77 1.1 christos (bfd *, asymbol *);
78 1.1 christos static bfd_boolean mips_elf_n32_object_p
79 1.1 christos (bfd *);
80 1.1 christos static bfd_boolean elf32_mips_grok_prstatus
81 1.1 christos (bfd *, Elf_Internal_Note *);
82 1.1 christos static bfd_boolean elf32_mips_grok_psinfo
83 1.1 christos (bfd *, Elf_Internal_Note *);
84 1.1 christos static irix_compat_t elf_n32_mips_irix_compat
85 1.1 christos (bfd *);
86 1.1 christos
87 1.1 christos extern const bfd_target bfd_elf32_nbigmips_vec;
88 1.1 christos extern const bfd_target bfd_elf32_nlittlemips_vec;
89 1.1 christos
90 1.1 christos /* Nonzero if ABFD is using the N32 ABI. */
91 1.1 christos #define ABI_N32_P(abfd) \
92 1.1 christos ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
93 1.1 christos
94 1.1 christos /* Whether we are trying to be compatible with IRIX at all. */
95 1.1 christos #define SGI_COMPAT(abfd) \
96 1.1 christos (elf_n32_mips_irix_compat (abfd) != ict_none)
97 1.1 christos
98 1.1 christos /* The number of local .got entries we reserve. */
99 1.1 christos #define MIPS_RESERVED_GOTNO (2)
100 1.1 christos
101 1.1 christos /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
102 1.1 christos from smaller values. Start with zero, widen, *then* decrement. */
103 1.1 christos #define MINUS_ONE (((bfd_vma)0) - 1)
104 1.1 christos
105 1.1 christos /* The relocation table used for SHT_REL sections. */
106 1.1 christos
107 1.1 christos static reloc_howto_type elf_mips_howto_table_rel[] =
108 1.1 christos {
109 1.1 christos /* No relocation. */
110 1.1 christos HOWTO (R_MIPS_NONE, /* type */
111 1.1 christos 0, /* rightshift */
112 1.1 christos 0, /* size (0 = byte, 1 = short, 2 = long) */
113 1.1 christos 0, /* bitsize */
114 1.1 christos FALSE, /* pc_relative */
115 1.1 christos 0, /* bitpos */
116 1.1 christos complain_overflow_dont, /* complain_on_overflow */
117 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
118 1.1 christos "R_MIPS_NONE", /* name */
119 1.1 christos FALSE, /* partial_inplace */
120 1.1 christos 0, /* src_mask */
121 1.1 christos 0, /* dst_mask */
122 1.1 christos FALSE), /* pcrel_offset */
123 1.1 christos
124 1.1 christos /* 16 bit relocation. */
125 1.1 christos HOWTO (R_MIPS_16, /* type */
126 1.1 christos 0, /* rightshift */
127 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
128 1.1 christos 16, /* bitsize */
129 1.1 christos FALSE, /* pc_relative */
130 1.1 christos 0, /* bitpos */
131 1.1 christos complain_overflow_signed, /* complain_on_overflow */
132 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
133 1.1 christos "R_MIPS_16", /* name */
134 1.1 christos TRUE, /* partial_inplace */
135 1.1 christos 0x0000ffff, /* src_mask */
136 1.1 christos 0x0000ffff, /* dst_mask */
137 1.1 christos FALSE), /* pcrel_offset */
138 1.1 christos
139 1.1 christos /* 32 bit relocation. */
140 1.1 christos HOWTO (R_MIPS_32, /* type */
141 1.1 christos 0, /* rightshift */
142 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
143 1.1 christos 32, /* bitsize */
144 1.1 christos FALSE, /* pc_relative */
145 1.1 christos 0, /* bitpos */
146 1.1 christos complain_overflow_dont, /* complain_on_overflow */
147 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
148 1.1 christos "R_MIPS_32", /* name */
149 1.1 christos TRUE, /* partial_inplace */
150 1.1 christos 0xffffffff, /* src_mask */
151 1.1 christos 0xffffffff, /* dst_mask */
152 1.1 christos FALSE), /* pcrel_offset */
153 1.1 christos
154 1.1 christos /* 32 bit symbol relative relocation. */
155 1.1 christos HOWTO (R_MIPS_REL32, /* type */
156 1.1 christos 0, /* rightshift */
157 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
158 1.1 christos 32, /* bitsize */
159 1.1 christos FALSE, /* pc_relative */
160 1.1 christos 0, /* bitpos */
161 1.1 christos complain_overflow_dont, /* complain_on_overflow */
162 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
163 1.1 christos "R_MIPS_REL32", /* name */
164 1.1 christos TRUE, /* partial_inplace */
165 1.1 christos 0xffffffff, /* src_mask */
166 1.1 christos 0xffffffff, /* dst_mask */
167 1.1 christos FALSE), /* pcrel_offset */
168 1.1 christos
169 1.1 christos /* 26 bit jump address. */
170 1.1 christos HOWTO (R_MIPS_26, /* type */
171 1.1 christos 2, /* rightshift */
172 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
173 1.1 christos 26, /* bitsize */
174 1.1 christos FALSE, /* pc_relative */
175 1.1 christos 0, /* bitpos */
176 1.1 christos complain_overflow_dont, /* complain_on_overflow */
177 1.1 christos /* This needs complex overflow
178 1.1 christos detection, because the upper four
179 1.1 christos bits must match the PC + 4. */
180 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
181 1.1 christos "R_MIPS_26", /* name */
182 1.1 christos TRUE, /* partial_inplace */
183 1.1 christos 0x03ffffff, /* src_mask */
184 1.1 christos 0x03ffffff, /* dst_mask */
185 1.1 christos FALSE), /* pcrel_offset */
186 1.1 christos
187 1.1 christos /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for NewABI REL.
188 1.1 christos However, the native IRIX6 tools use them, so we try our best. */
189 1.1 christos
190 1.1 christos /* High 16 bits of symbol value. */
191 1.1 christos HOWTO (R_MIPS_HI16, /* type */
192 1.1 christos 16, /* rightshift */
193 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
194 1.1 christos 16, /* bitsize */
195 1.1 christos FALSE, /* pc_relative */
196 1.1 christos 0, /* bitpos */
197 1.1 christos complain_overflow_dont, /* complain_on_overflow */
198 1.1 christos _bfd_mips_elf_hi16_reloc, /* special_function */
199 1.1 christos "R_MIPS_HI16", /* name */
200 1.1 christos TRUE, /* partial_inplace */
201 1.1 christos 0x0000ffff, /* src_mask */
202 1.1 christos 0x0000ffff, /* dst_mask */
203 1.1 christos FALSE), /* pcrel_offset */
204 1.1 christos
205 1.1 christos /* Low 16 bits of symbol value. */
206 1.1 christos HOWTO (R_MIPS_LO16, /* type */
207 1.1 christos 0, /* rightshift */
208 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
209 1.1 christos 16, /* bitsize */
210 1.1 christos FALSE, /* pc_relative */
211 1.1 christos 0, /* bitpos */
212 1.1 christos complain_overflow_dont, /* complain_on_overflow */
213 1.1 christos _bfd_mips_elf_lo16_reloc, /* special_function */
214 1.1 christos "R_MIPS_LO16", /* name */
215 1.1 christos TRUE, /* partial_inplace */
216 1.1 christos 0x0000ffff, /* src_mask */
217 1.1 christos 0x0000ffff, /* dst_mask */
218 1.1 christos FALSE), /* pcrel_offset */
219 1.1 christos
220 1.1 christos /* GP relative reference. */
221 1.1 christos HOWTO (R_MIPS_GPREL16, /* type */
222 1.1 christos 0, /* rightshift */
223 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
224 1.1 christos 16, /* bitsize */
225 1.1 christos FALSE, /* pc_relative */
226 1.1 christos 0, /* bitpos */
227 1.1 christos complain_overflow_signed, /* complain_on_overflow */
228 1.1 christos mips_elf_gprel16_reloc, /* special_function */
229 1.1 christos "R_MIPS_GPREL16", /* name */
230 1.1 christos TRUE, /* partial_inplace */
231 1.1 christos 0x0000ffff, /* src_mask */
232 1.1 christos 0x0000ffff, /* dst_mask */
233 1.1 christos FALSE), /* pcrel_offset */
234 1.1 christos
235 1.1 christos /* Reference to literal section. */
236 1.1 christos HOWTO (R_MIPS_LITERAL, /* type */
237 1.1 christos 0, /* rightshift */
238 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
239 1.1 christos 16, /* bitsize */
240 1.1 christos FALSE, /* pc_relative */
241 1.1 christos 0, /* bitpos */
242 1.1 christos complain_overflow_signed, /* complain_on_overflow */
243 1.1 christos mips_elf_literal_reloc, /* special_function */
244 1.1 christos "R_MIPS_LITERAL", /* name */
245 1.1 christos TRUE, /* partial_inplace */
246 1.1 christos 0x0000ffff, /* src_mask */
247 1.1 christos 0x0000ffff, /* dst_mask */
248 1.1 christos FALSE), /* pcrel_offset */
249 1.1 christos
250 1.1 christos /* Reference to global offset table. */
251 1.1 christos HOWTO (R_MIPS_GOT16, /* type */
252 1.1 christos 0, /* rightshift */
253 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
254 1.1 christos 16, /* bitsize */
255 1.1 christos FALSE, /* pc_relative */
256 1.1 christos 0, /* bitpos */
257 1.1 christos complain_overflow_signed, /* complain_on_overflow */
258 1.1 christos _bfd_mips_elf_got16_reloc, /* special_function */
259 1.1 christos "R_MIPS_GOT16", /* name */
260 1.1 christos TRUE, /* partial_inplace */
261 1.1 christos 0x0000ffff, /* src_mask */
262 1.1 christos 0x0000ffff, /* dst_mask */
263 1.1 christos FALSE), /* pcrel_offset */
264 1.1 christos
265 1.1 christos /* 16 bit PC relative reference. Note that the ABI document has a typo
266 1.1 christos and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
267 1.1 christos We do the right thing here. */
268 1.1 christos HOWTO (R_MIPS_PC16, /* type */
269 1.1 christos 2, /* rightshift */
270 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
271 1.1 christos 16, /* bitsize */
272 1.1 christos TRUE, /* pc_relative */
273 1.1 christos 0, /* bitpos */
274 1.1 christos complain_overflow_signed, /* complain_on_overflow */
275 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
276 1.1 christos "R_MIPS_PC16", /* name */
277 1.1 christos TRUE, /* partial_inplace */
278 1.1 christos 0x0000ffff, /* src_mask */
279 1.1 christos 0x0000ffff, /* dst_mask */
280 1.1 christos TRUE), /* pcrel_offset */
281 1.1 christos
282 1.1 christos /* 16 bit call through global offset table. */
283 1.1 christos HOWTO (R_MIPS_CALL16, /* type */
284 1.1 christos 0, /* rightshift */
285 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
286 1.1 christos 16, /* bitsize */
287 1.1 christos FALSE, /* pc_relative */
288 1.1 christos 0, /* bitpos */
289 1.1 christos complain_overflow_signed, /* complain_on_overflow */
290 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
291 1.1 christos "R_MIPS_CALL16", /* name */
292 1.1 christos TRUE, /* partial_inplace */
293 1.1 christos 0x0000ffff, /* src_mask */
294 1.1 christos 0x0000ffff, /* dst_mask */
295 1.1 christos FALSE), /* pcrel_offset */
296 1.1 christos
297 1.1 christos /* 32 bit GP relative reference. */
298 1.1 christos HOWTO (R_MIPS_GPREL32, /* type */
299 1.1 christos 0, /* rightshift */
300 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
301 1.1 christos 32, /* bitsize */
302 1.1 christos FALSE, /* pc_relative */
303 1.1 christos 0, /* bitpos */
304 1.1 christos complain_overflow_dont, /* complain_on_overflow */
305 1.1 christos mips_elf_gprel32_reloc, /* special_function */
306 1.1 christos "R_MIPS_GPREL32", /* name */
307 1.1 christos TRUE, /* partial_inplace */
308 1.1 christos 0xffffffff, /* src_mask */
309 1.1 christos 0xffffffff, /* dst_mask */
310 1.1 christos FALSE), /* pcrel_offset */
311 1.1 christos
312 1.1 christos /* The remaining relocs are defined on Irix 5, although they are
313 1.1 christos not defined by the ABI. */
314 1.1 christos EMPTY_HOWTO (13),
315 1.1 christos EMPTY_HOWTO (14),
316 1.1 christos EMPTY_HOWTO (15),
317 1.1 christos
318 1.1 christos /* A 5 bit shift field. */
319 1.1 christos HOWTO (R_MIPS_SHIFT5, /* type */
320 1.1 christos 0, /* rightshift */
321 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
322 1.1 christos 5, /* bitsize */
323 1.1 christos FALSE, /* pc_relative */
324 1.1 christos 6, /* bitpos */
325 1.1 christos complain_overflow_bitfield, /* complain_on_overflow */
326 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
327 1.1 christos "R_MIPS_SHIFT5", /* name */
328 1.1 christos TRUE, /* partial_inplace */
329 1.1 christos 0x000007c0, /* src_mask */
330 1.1 christos 0x000007c0, /* dst_mask */
331 1.1 christos FALSE), /* pcrel_offset */
332 1.1 christos
333 1.1 christos /* A 6 bit shift field. */
334 1.1 christos HOWTO (R_MIPS_SHIFT6, /* type */
335 1.1 christos 0, /* rightshift */
336 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
337 1.1 christos 6, /* bitsize */
338 1.1 christos FALSE, /* pc_relative */
339 1.1 christos 6, /* bitpos */
340 1.1 christos complain_overflow_bitfield, /* complain_on_overflow */
341 1.1 christos mips_elf_shift6_reloc, /* special_function */
342 1.1 christos "R_MIPS_SHIFT6", /* name */
343 1.1 christos TRUE, /* partial_inplace */
344 1.1 christos 0x000007c4, /* src_mask */
345 1.1 christos 0x000007c4, /* dst_mask */
346 1.1 christos FALSE), /* pcrel_offset */
347 1.1 christos
348 1.1 christos /* A 64 bit relocation. */
349 1.1 christos HOWTO (R_MIPS_64, /* type */
350 1.1 christos 0, /* rightshift */
351 1.1 christos 4, /* size (0 = byte, 1 = short, 2 = long) */
352 1.1 christos 64, /* bitsize */
353 1.1 christos FALSE, /* pc_relative */
354 1.1 christos 0, /* bitpos */
355 1.1 christos complain_overflow_dont, /* complain_on_overflow */
356 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
357 1.1 christos "R_MIPS_64", /* name */
358 1.1 christos TRUE, /* partial_inplace */
359 1.1 christos MINUS_ONE, /* src_mask */
360 1.1 christos MINUS_ONE, /* dst_mask */
361 1.1 christos FALSE), /* pcrel_offset */
362 1.1 christos
363 1.1 christos /* Displacement in the global offset table. */
364 1.1 christos HOWTO (R_MIPS_GOT_DISP, /* type */
365 1.1 christos 0, /* rightshift */
366 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
367 1.1 christos 16, /* bitsize */
368 1.1 christos FALSE, /* pc_relative */
369 1.1 christos 0, /* bitpos */
370 1.1 christos complain_overflow_signed, /* complain_on_overflow */
371 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
372 1.1 christos "R_MIPS_GOT_DISP", /* name */
373 1.1 christos TRUE, /* partial_inplace */
374 1.1 christos 0x0000ffff, /* src_mask */
375 1.1 christos 0x0000ffff, /* dst_mask */
376 1.1 christos FALSE), /* pcrel_offset */
377 1.1 christos
378 1.1 christos /* Displacement to page pointer in the global offset table. */
379 1.1 christos HOWTO (R_MIPS_GOT_PAGE, /* type */
380 1.1 christos 0, /* rightshift */
381 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
382 1.1 christos 16, /* bitsize */
383 1.1 christos FALSE, /* pc_relative */
384 1.1 christos 0, /* bitpos */
385 1.1 christos complain_overflow_signed, /* complain_on_overflow */
386 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
387 1.1 christos "R_MIPS_GOT_PAGE", /* name */
388 1.1 christos TRUE, /* partial_inplace */
389 1.1 christos 0x0000ffff, /* src_mask */
390 1.1 christos 0x0000ffff, /* dst_mask */
391 1.1 christos FALSE), /* pcrel_offset */
392 1.1 christos
393 1.1 christos /* Offset from page pointer in the global offset table. */
394 1.1 christos HOWTO (R_MIPS_GOT_OFST, /* type */
395 1.1 christos 0, /* rightshift */
396 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
397 1.1 christos 16, /* bitsize */
398 1.1 christos FALSE, /* pc_relative */
399 1.1 christos 0, /* bitpos */
400 1.1 christos complain_overflow_signed, /* complain_on_overflow */
401 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
402 1.1 christos "R_MIPS_GOT_OFST", /* name */
403 1.1 christos TRUE, /* partial_inplace */
404 1.1 christos 0x0000ffff, /* src_mask */
405 1.1 christos 0x0000ffff, /* dst_mask */
406 1.1 christos FALSE), /* pcrel_offset */
407 1.1 christos
408 1.1 christos /* High 16 bits of displacement in global offset table. */
409 1.1 christos HOWTO (R_MIPS_GOT_HI16, /* type */
410 1.1 christos 0, /* rightshift */
411 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
412 1.1 christos 16, /* bitsize */
413 1.1 christos FALSE, /* pc_relative */
414 1.1 christos 0, /* bitpos */
415 1.1 christos complain_overflow_dont, /* complain_on_overflow */
416 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
417 1.1 christos "R_MIPS_GOT_HI16", /* name */
418 1.1 christos TRUE, /* partial_inplace */
419 1.1 christos 0x0000ffff, /* src_mask */
420 1.1 christos 0x0000ffff, /* dst_mask */
421 1.1 christos FALSE), /* pcrel_offset */
422 1.1 christos
423 1.1 christos /* Low 16 bits of displacement in global offset table. */
424 1.1 christos HOWTO (R_MIPS_GOT_LO16, /* type */
425 1.1 christos 0, /* rightshift */
426 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
427 1.1 christos 16, /* bitsize */
428 1.1 christos FALSE, /* pc_relative */
429 1.1 christos 0, /* bitpos */
430 1.1 christos complain_overflow_dont, /* complain_on_overflow */
431 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
432 1.1 christos "R_MIPS_GOT_LO16", /* name */
433 1.1 christos TRUE, /* partial_inplace */
434 1.1 christos 0x0000ffff, /* src_mask */
435 1.1 christos 0x0000ffff, /* dst_mask */
436 1.1 christos FALSE), /* pcrel_offset */
437 1.1 christos
438 1.1 christos /* 64 bit subtraction. */
439 1.1 christos HOWTO (R_MIPS_SUB, /* type */
440 1.1 christos 0, /* rightshift */
441 1.1 christos 4, /* size (0 = byte, 1 = short, 2 = long) */
442 1.1 christos 64, /* bitsize */
443 1.1 christos FALSE, /* pc_relative */
444 1.1 christos 0, /* bitpos */
445 1.1 christos complain_overflow_dont, /* complain_on_overflow */
446 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
447 1.1 christos "R_MIPS_SUB", /* name */
448 1.1 christos TRUE, /* partial_inplace */
449 1.1 christos MINUS_ONE, /* src_mask */
450 1.1 christos MINUS_ONE, /* dst_mask */
451 1.1 christos FALSE), /* pcrel_offset */
452 1.1 christos
453 1.1 christos /* Insert the addend as an instruction. */
454 1.1 christos /* FIXME: Not handled correctly. */
455 1.1 christos HOWTO (R_MIPS_INSERT_A, /* type */
456 1.1 christos 0, /* rightshift */
457 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
458 1.1 christos 32, /* bitsize */
459 1.1 christos FALSE, /* pc_relative */
460 1.1 christos 0, /* bitpos */
461 1.1 christos complain_overflow_dont, /* complain_on_overflow */
462 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
463 1.1 christos "R_MIPS_INSERT_A", /* name */
464 1.1 christos TRUE, /* partial_inplace */
465 1.1 christos 0xffffffff, /* src_mask */
466 1.1 christos 0xffffffff, /* dst_mask */
467 1.1 christos FALSE), /* pcrel_offset */
468 1.1 christos
469 1.1 christos /* Insert the addend as an instruction, and change all relocations
470 1.1 christos to refer to the old instruction at the address. */
471 1.1 christos /* FIXME: Not handled correctly. */
472 1.1 christos HOWTO (R_MIPS_INSERT_B, /* type */
473 1.1 christos 0, /* rightshift */
474 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
475 1.1 christos 32, /* bitsize */
476 1.1 christos FALSE, /* pc_relative */
477 1.1 christos 0, /* bitpos */
478 1.1 christos complain_overflow_dont, /* complain_on_overflow */
479 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
480 1.1 christos "R_MIPS_INSERT_B", /* name */
481 1.1 christos TRUE, /* partial_inplace */
482 1.1 christos 0xffffffff, /* src_mask */
483 1.1 christos 0xffffffff, /* dst_mask */
484 1.1 christos FALSE), /* pcrel_offset */
485 1.1 christos
486 1.1 christos /* Delete a 32 bit instruction. */
487 1.1 christos /* FIXME: Not handled correctly. */
488 1.1 christos HOWTO (R_MIPS_DELETE, /* type */
489 1.1 christos 0, /* rightshift */
490 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
491 1.1 christos 32, /* bitsize */
492 1.1 christos FALSE, /* pc_relative */
493 1.1 christos 0, /* bitpos */
494 1.1 christos complain_overflow_dont, /* complain_on_overflow */
495 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
496 1.1 christos "R_MIPS_DELETE", /* name */
497 1.1 christos TRUE, /* partial_inplace */
498 1.1 christos 0xffffffff, /* src_mask */
499 1.1 christos 0xffffffff, /* dst_mask */
500 1.1 christos FALSE), /* pcrel_offset */
501 1.1 christos
502 1.1 christos /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations.
503 1.1 christos We don't, because
504 1.1 christos a) It means building the addend from a R_MIPS_HIGHEST/R_MIPS_HIGHER/
505 1.1 christos R_MIPS_HI16/R_MIPS_LO16 sequence with varying ordering, using
506 1.1 christos fallable heuristics.
507 1.1 christos b) No other NewABI toolchain actually emits such relocations. */
508 1.1 christos EMPTY_HOWTO (R_MIPS_HIGHER),
509 1.1 christos EMPTY_HOWTO (R_MIPS_HIGHEST),
510 1.1 christos
511 1.1 christos /* High 16 bits of displacement in global offset table. */
512 1.1 christos HOWTO (R_MIPS_CALL_HI16, /* type */
513 1.1 christos 0, /* rightshift */
514 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
515 1.1 christos 16, /* bitsize */
516 1.1 christos FALSE, /* pc_relative */
517 1.1 christos 0, /* bitpos */
518 1.1 christos complain_overflow_dont, /* complain_on_overflow */
519 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
520 1.1 christos "R_MIPS_CALL_HI16", /* name */
521 1.1 christos TRUE, /* partial_inplace */
522 1.1 christos 0x0000ffff, /* src_mask */
523 1.1 christos 0x0000ffff, /* dst_mask */
524 1.1 christos FALSE), /* pcrel_offset */
525 1.1 christos
526 1.1 christos /* Low 16 bits of displacement in global offset table. */
527 1.1 christos HOWTO (R_MIPS_CALL_LO16, /* type */
528 1.1 christos 0, /* rightshift */
529 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
530 1.1 christos 16, /* bitsize */
531 1.1 christos FALSE, /* pc_relative */
532 1.1 christos 0, /* bitpos */
533 1.1 christos complain_overflow_dont, /* complain_on_overflow */
534 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
535 1.1 christos "R_MIPS_CALL_LO16", /* name */
536 1.1 christos TRUE, /* partial_inplace */
537 1.1 christos 0x0000ffff, /* src_mask */
538 1.1 christos 0x0000ffff, /* dst_mask */
539 1.1 christos FALSE), /* pcrel_offset */
540 1.1 christos
541 1.1 christos /* Section displacement. */
542 1.1 christos HOWTO (R_MIPS_SCN_DISP, /* type */
543 1.1 christos 0, /* rightshift */
544 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
545 1.1 christos 32, /* bitsize */
546 1.1 christos FALSE, /* pc_relative */
547 1.1 christos 0, /* bitpos */
548 1.1 christos complain_overflow_dont, /* complain_on_overflow */
549 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
550 1.1 christos "R_MIPS_SCN_DISP", /* name */
551 1.1 christos TRUE, /* partial_inplace */
552 1.1 christos 0xffffffff, /* src_mask */
553 1.1 christos 0xffffffff, /* dst_mask */
554 1.1 christos FALSE), /* pcrel_offset */
555 1.1 christos
556 1.1 christos HOWTO (R_MIPS_REL16, /* type */
557 1.1 christos 0, /* rightshift */
558 1.1 christos 1, /* size (0 = byte, 1 = short, 2 = long) */
559 1.1 christos 16, /* bitsize */
560 1.1 christos FALSE, /* pc_relative */
561 1.1 christos 0, /* bitpos */
562 1.1 christos complain_overflow_signed, /* complain_on_overflow */
563 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
564 1.1 christos "R_MIPS_REL16", /* name */
565 1.1 christos TRUE, /* partial_inplace */
566 1.1 christos 0xffff, /* src_mask */
567 1.1 christos 0xffff, /* dst_mask */
568 1.1 christos FALSE), /* pcrel_offset */
569 1.1 christos
570 1.1 christos /* These two are obsolete. */
571 1.1 christos EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
572 1.1 christos EMPTY_HOWTO (R_MIPS_PJUMP),
573 1.1 christos
574 1.1 christos /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
575 1.1 christos It must be used for multigot GOT's (and only there). */
576 1.1 christos HOWTO (R_MIPS_RELGOT, /* type */
577 1.1 christos 0, /* rightshift */
578 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
579 1.1 christos 32, /* bitsize */
580 1.1 christos FALSE, /* pc_relative */
581 1.1 christos 0, /* bitpos */
582 1.1 christos complain_overflow_dont, /* complain_on_overflow */
583 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
584 1.1 christos "R_MIPS_RELGOT", /* name */
585 1.1 christos TRUE, /* partial_inplace */
586 1.1 christos 0xffffffff, /* src_mask */
587 1.1 christos 0xffffffff, /* dst_mask */
588 1.1 christos FALSE), /* pcrel_offset */
589 1.1 christos
590 1.1 christos /* Protected jump conversion. This is an optimization hint. No
591 1.1 christos relocation is required for correctness. */
592 1.1 christos HOWTO (R_MIPS_JALR, /* type */
593 1.1 christos 0, /* rightshift */
594 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
595 1.1 christos 32, /* bitsize */
596 1.1 christos FALSE, /* pc_relative */
597 1.1 christos 0, /* bitpos */
598 1.1 christos complain_overflow_dont, /* complain_on_overflow */
599 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
600 1.1 christos "R_MIPS_JALR", /* name */
601 1.1 christos FALSE, /* partial_inplace */
602 1.1 christos 0x00000000, /* src_mask */
603 1.1 christos 0x00000000, /* dst_mask */
604 1.1 christos FALSE), /* pcrel_offset */
605 1.1 christos
606 1.1 christos /* TLS GD/LD dynamic relocations. */
607 1.1 christos HOWTO (R_MIPS_TLS_DTPMOD32, /* type */
608 1.1 christos 0, /* rightshift */
609 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
610 1.1 christos 32, /* bitsize */
611 1.1 christos FALSE, /* pc_relative */
612 1.1 christos 0, /* bitpos */
613 1.1 christos complain_overflow_dont, /* complain_on_overflow */
614 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
615 1.1 christos "R_MIPS_TLS_DTPMOD32", /* name */
616 1.1 christos TRUE, /* partial_inplace */
617 1.1 christos 0xffffffff, /* src_mask */
618 1.1 christos 0xffffffff, /* dst_mask */
619 1.1 christos FALSE), /* pcrel_offset */
620 1.1 christos
621 1.1 christos HOWTO (R_MIPS_TLS_DTPREL32, /* type */
622 1.1 christos 0, /* rightshift */
623 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
624 1.1 christos 32, /* bitsize */
625 1.1 christos FALSE, /* pc_relative */
626 1.1 christos 0, /* bitpos */
627 1.1 christos complain_overflow_dont, /* complain_on_overflow */
628 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
629 1.1 christos "R_MIPS_TLS_DTPREL32", /* name */
630 1.1 christos TRUE, /* partial_inplace */
631 1.1 christos 0xffffffff, /* src_mask */
632 1.1 christos 0xffffffff, /* dst_mask */
633 1.1 christos FALSE), /* pcrel_offset */
634 1.1 christos
635 1.1 christos EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
636 1.1 christos EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
637 1.1 christos
638 1.1 christos /* TLS general dynamic variable reference. */
639 1.1 christos HOWTO (R_MIPS_TLS_GD, /* type */
640 1.1 christos 0, /* rightshift */
641 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
642 1.1 christos 16, /* bitsize */
643 1.1 christos FALSE, /* pc_relative */
644 1.1 christos 0, /* bitpos */
645 1.1 christos complain_overflow_signed, /* complain_on_overflow */
646 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
647 1.1 christos "R_MIPS_TLS_GD", /* name */
648 1.1 christos TRUE, /* partial_inplace */
649 1.1 christos 0x0000ffff, /* src_mask */
650 1.1 christos 0x0000ffff, /* dst_mask */
651 1.1 christos FALSE), /* pcrel_offset */
652 1.1 christos
653 1.1 christos /* TLS local dynamic variable reference. */
654 1.1 christos HOWTO (R_MIPS_TLS_LDM, /* type */
655 1.1 christos 0, /* rightshift */
656 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
657 1.1 christos 16, /* bitsize */
658 1.1 christos FALSE, /* pc_relative */
659 1.1 christos 0, /* bitpos */
660 1.1 christos complain_overflow_signed, /* complain_on_overflow */
661 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
662 1.1 christos "R_MIPS_TLS_LDM", /* name */
663 1.1 christos TRUE, /* partial_inplace */
664 1.1 christos 0x0000ffff, /* src_mask */
665 1.1 christos 0x0000ffff, /* dst_mask */
666 1.1 christos FALSE), /* pcrel_offset */
667 1.1 christos
668 1.1 christos /* TLS local dynamic offset. */
669 1.1 christos HOWTO (R_MIPS_TLS_DTPREL_HI16, /* type */
670 1.1 christos 0, /* rightshift */
671 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
672 1.1 christos 16, /* bitsize */
673 1.1 christos FALSE, /* pc_relative */
674 1.1 christos 0, /* bitpos */
675 1.1 christos complain_overflow_signed, /* complain_on_overflow */
676 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
677 1.1 christos "R_MIPS_TLS_DTPREL_HI16", /* name */
678 1.1 christos TRUE, /* partial_inplace */
679 1.1 christos 0x0000ffff, /* src_mask */
680 1.1 christos 0x0000ffff, /* dst_mask */
681 1.1 christos FALSE), /* pcrel_offset */
682 1.1 christos
683 1.1 christos /* TLS local dynamic offset. */
684 1.1 christos HOWTO (R_MIPS_TLS_DTPREL_LO16, /* type */
685 1.1 christos 0, /* rightshift */
686 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
687 1.1 christos 16, /* bitsize */
688 1.1 christos FALSE, /* pc_relative */
689 1.1 christos 0, /* bitpos */
690 1.1 christos complain_overflow_signed, /* complain_on_overflow */
691 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
692 1.1 christos "R_MIPS_TLS_DTPREL_LO16", /* name */
693 1.1 christos TRUE, /* partial_inplace */
694 1.1 christos 0x0000ffff, /* src_mask */
695 1.1 christos 0x0000ffff, /* dst_mask */
696 1.1 christos FALSE), /* pcrel_offset */
697 1.1 christos
698 1.1 christos /* TLS thread pointer offset. */
699 1.1 christos HOWTO (R_MIPS_TLS_GOTTPREL, /* type */
700 1.1 christos 0, /* rightshift */
701 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
702 1.1 christos 16, /* bitsize */
703 1.1 christos FALSE, /* pc_relative */
704 1.1 christos 0, /* bitpos */
705 1.1 christos complain_overflow_signed, /* complain_on_overflow */
706 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
707 1.1 christos "R_MIPS_TLS_GOTTPREL", /* name */
708 1.1 christos TRUE, /* partial_inplace */
709 1.1 christos 0x0000ffff, /* src_mask */
710 1.1 christos 0x0000ffff, /* dst_mask */
711 1.1 christos FALSE), /* pcrel_offset */
712 1.1 christos
713 1.1 christos /* TLS IE dynamic relocations. */
714 1.1 christos HOWTO (R_MIPS_TLS_TPREL32, /* type */
715 1.1 christos 0, /* rightshift */
716 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
717 1.1 christos 32, /* bitsize */
718 1.1 christos FALSE, /* pc_relative */
719 1.1 christos 0, /* bitpos */
720 1.1 christos complain_overflow_dont, /* complain_on_overflow */
721 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
722 1.1 christos "R_MIPS_TLS_TPREL32", /* name */
723 1.1 christos TRUE, /* partial_inplace */
724 1.1 christos 0xffffffff, /* src_mask */
725 1.1 christos 0xffffffff, /* dst_mask */
726 1.1 christos FALSE), /* pcrel_offset */
727 1.1 christos
728 1.1 christos EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
729 1.1 christos
730 1.1 christos /* TLS thread pointer offset. */
731 1.1 christos HOWTO (R_MIPS_TLS_TPREL_HI16, /* type */
732 1.1 christos 0, /* rightshift */
733 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
734 1.1 christos 16, /* bitsize */
735 1.1 christos FALSE, /* pc_relative */
736 1.1 christos 0, /* bitpos */
737 1.1 christos complain_overflow_signed, /* complain_on_overflow */
738 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
739 1.1 christos "R_MIPS_TLS_TPREL_HI16", /* name */
740 1.1 christos TRUE, /* partial_inplace */
741 1.1 christos 0x0000ffff, /* src_mask */
742 1.1 christos 0x0000ffff, /* dst_mask */
743 1.1 christos FALSE), /* pcrel_offset */
744 1.1 christos
745 1.1 christos /* TLS thread pointer offset. */
746 1.1 christos HOWTO (R_MIPS_TLS_TPREL_LO16, /* type */
747 1.1 christos 0, /* rightshift */
748 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
749 1.1 christos 16, /* bitsize */
750 1.1 christos FALSE, /* pc_relative */
751 1.1 christos 0, /* bitpos */
752 1.1 christos complain_overflow_signed, /* complain_on_overflow */
753 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
754 1.1 christos "R_MIPS_TLS_TPREL_LO16", /* name */
755 1.1 christos TRUE, /* partial_inplace */
756 1.1 christos 0x0000ffff, /* src_mask */
757 1.1 christos 0x0000ffff, /* dst_mask */
758 1.1 christos FALSE), /* pcrel_offset */
759 1.1 christos
760 1.1 christos /* 32 bit relocation with no addend. */
761 1.1 christos HOWTO (R_MIPS_GLOB_DAT, /* type */
762 1.1 christos 0, /* rightshift */
763 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
764 1.1 christos 32, /* bitsize */
765 1.1 christos FALSE, /* pc_relative */
766 1.1 christos 0, /* bitpos */
767 1.1 christos complain_overflow_dont, /* complain_on_overflow */
768 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
769 1.1 christos "R_MIPS_GLOB_DAT", /* name */
770 1.1 christos FALSE, /* partial_inplace */
771 1.1 christos 0x0, /* src_mask */
772 1.1 christos 0xffffffff, /* dst_mask */
773 1.1 christos FALSE), /* pcrel_offset */
774 1.1 christos };
775 1.1 christos
776 1.1 christos /* The relocation table used for SHT_RELA sections. */
777 1.1 christos
778 1.1 christos static reloc_howto_type elf_mips_howto_table_rela[] =
779 1.1 christos {
780 1.1 christos /* No relocation. */
781 1.1 christos HOWTO (R_MIPS_NONE, /* type */
782 1.1 christos 0, /* rightshift */
783 1.1 christos 0, /* size (0 = byte, 1 = short, 2 = long) */
784 1.1 christos 0, /* bitsize */
785 1.1 christos FALSE, /* pc_relative */
786 1.1 christos 0, /* bitpos */
787 1.1 christos complain_overflow_dont, /* complain_on_overflow */
788 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
789 1.1 christos "R_MIPS_NONE", /* name */
790 1.1 christos FALSE, /* partial_inplace */
791 1.1 christos 0, /* src_mask */
792 1.1 christos 0, /* dst_mask */
793 1.1 christos FALSE), /* pcrel_offset */
794 1.1 christos
795 1.1 christos /* 16 bit relocation. */
796 1.1 christos HOWTO (R_MIPS_16, /* type */
797 1.1 christos 0, /* rightshift */
798 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
799 1.1 christos 16, /* bitsize */
800 1.1 christos FALSE, /* pc_relative */
801 1.1 christos 0, /* bitpos */
802 1.1 christos complain_overflow_signed, /* complain_on_overflow */
803 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
804 1.1 christos "R_MIPS_16", /* name */
805 1.1 christos FALSE, /* partial_inplace */
806 1.1 christos 0, /* src_mask */
807 1.1 christos 0x0000, /* dst_mask */
808 1.1 christos FALSE), /* pcrel_offset */
809 1.1 christos
810 1.1 christos /* 32 bit relocation. */
811 1.1 christos HOWTO (R_MIPS_32, /* type */
812 1.1 christos 0, /* rightshift */
813 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
814 1.1 christos 32, /* bitsize */
815 1.1 christos FALSE, /* pc_relative */
816 1.1 christos 0, /* bitpos */
817 1.1 christos complain_overflow_dont, /* complain_on_overflow */
818 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
819 1.1 christos "R_MIPS_32", /* name */
820 1.1 christos FALSE, /* partial_inplace */
821 1.1 christos 0, /* src_mask */
822 1.1 christos 0xffffffff, /* dst_mask */
823 1.1 christos FALSE), /* pcrel_offset */
824 1.1 christos
825 1.1 christos /* 32 bit symbol relative relocation. */
826 1.1 christos HOWTO (R_MIPS_REL32, /* type */
827 1.1 christos 0, /* rightshift */
828 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
829 1.1 christos 32, /* bitsize */
830 1.1 christos FALSE, /* pc_relative */
831 1.1 christos 0, /* bitpos */
832 1.1 christos complain_overflow_dont, /* complain_on_overflow */
833 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
834 1.1 christos "R_MIPS_REL32", /* name */
835 1.1 christos FALSE, /* partial_inplace */
836 1.1 christos 0, /* src_mask */
837 1.1 christos 0xffffffff, /* dst_mask */
838 1.1 christos FALSE), /* pcrel_offset */
839 1.1 christos
840 1.1 christos /* 26 bit jump address. */
841 1.1 christos HOWTO (R_MIPS_26, /* type */
842 1.1 christos 2, /* rightshift */
843 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
844 1.1 christos 26, /* bitsize */
845 1.1 christos FALSE, /* pc_relative */
846 1.1 christos 0, /* bitpos */
847 1.1 christos complain_overflow_dont, /* complain_on_overflow */
848 1.1 christos /* This needs complex overflow
849 1.1 christos detection, because the upper 36
850 1.1 christos bits must match the PC + 4. */
851 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
852 1.1 christos "R_MIPS_26", /* name */
853 1.1 christos FALSE, /* partial_inplace */
854 1.1 christos 0, /* src_mask */
855 1.1 christos 0x03ffffff, /* dst_mask */
856 1.1 christos FALSE), /* pcrel_offset */
857 1.1 christos
858 1.1 christos /* High 16 bits of symbol value. */
859 1.1 christos HOWTO (R_MIPS_HI16, /* type */
860 1.1 christos 0, /* rightshift */
861 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
862 1.1 christos 16, /* bitsize */
863 1.1 christos FALSE, /* pc_relative */
864 1.1 christos 0, /* bitpos */
865 1.1 christos complain_overflow_dont, /* complain_on_overflow */
866 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
867 1.1 christos "R_MIPS_HI16", /* name */
868 1.1 christos FALSE, /* partial_inplace */
869 1.1 christos 0, /* src_mask */
870 1.1 christos 0x0000ffff, /* dst_mask */
871 1.1 christos FALSE), /* pcrel_offset */
872 1.1 christos
873 1.1 christos /* Low 16 bits of symbol value. */
874 1.1 christos HOWTO (R_MIPS_LO16, /* type */
875 1.1 christos 0, /* rightshift */
876 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
877 1.1 christos 16, /* bitsize */
878 1.1 christos FALSE, /* pc_relative */
879 1.1 christos 0, /* bitpos */
880 1.1 christos complain_overflow_dont, /* complain_on_overflow */
881 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
882 1.1 christos "R_MIPS_LO16", /* name */
883 1.1 christos FALSE, /* partial_inplace */
884 1.1 christos 0, /* src_mask */
885 1.1 christos 0x0000ffff, /* dst_mask */
886 1.1 christos FALSE), /* pcrel_offset */
887 1.1 christos
888 1.1 christos /* GP relative reference. */
889 1.1 christos HOWTO (R_MIPS_GPREL16, /* type */
890 1.1 christos 0, /* rightshift */
891 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
892 1.1 christos 16, /* bitsize */
893 1.1 christos FALSE, /* pc_relative */
894 1.1 christos 0, /* bitpos */
895 1.1 christos complain_overflow_signed, /* complain_on_overflow */
896 1.1 christos mips_elf_gprel16_reloc, /* special_function */
897 1.1 christos "R_MIPS_GPREL16", /* name */
898 1.1 christos FALSE, /* partial_inplace */
899 1.1 christos 0, /* src_mask */
900 1.1 christos 0x0000ffff, /* dst_mask */
901 1.1 christos FALSE), /* pcrel_offset */
902 1.1 christos
903 1.1 christos /* Reference to literal section. */
904 1.1 christos HOWTO (R_MIPS_LITERAL, /* type */
905 1.1 christos 0, /* rightshift */
906 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
907 1.1 christos 16, /* bitsize */
908 1.1 christos FALSE, /* pc_relative */
909 1.1 christos 0, /* bitpos */
910 1.1 christos complain_overflow_signed, /* complain_on_overflow */
911 1.1 christos mips_elf_literal_reloc, /* special_function */
912 1.1 christos "R_MIPS_LITERAL", /* name */
913 1.1 christos FALSE, /* partial_inplace */
914 1.1 christos 0, /* src_mask */
915 1.1 christos 0x0000ffff, /* dst_mask */
916 1.1 christos FALSE), /* pcrel_offset */
917 1.1 christos
918 1.1 christos /* Reference to global offset table. */
919 1.1 christos HOWTO (R_MIPS_GOT16, /* type */
920 1.1 christos 0, /* rightshift */
921 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
922 1.1 christos 16, /* bitsize */
923 1.1 christos FALSE, /* pc_relative */
924 1.1 christos 0, /* bitpos */
925 1.1 christos complain_overflow_signed, /* complain_on_overflow */
926 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
927 1.1 christos "R_MIPS_GOT16", /* name */
928 1.1 christos FALSE, /* partial_inplace */
929 1.1 christos 0, /* src_mask */
930 1.1 christos 0x0000ffff, /* dst_mask */
931 1.1 christos FALSE), /* pcrel_offset */
932 1.1 christos
933 1.1 christos /* 16 bit PC relative reference. Note that the ABI document has a typo
934 1.1 christos and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
935 1.1 christos We do the right thing here. */
936 1.1 christos HOWTO (R_MIPS_PC16, /* type */
937 1.1 christos 2, /* rightshift */
938 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
939 1.1 christos 16, /* bitsize */
940 1.1 christos TRUE, /* pc_relative */
941 1.1 christos 0, /* bitpos */
942 1.1 christos complain_overflow_signed, /* complain_on_overflow */
943 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
944 1.1 christos "R_MIPS_PC16", /* name */
945 1.1 christos FALSE, /* partial_inplace */
946 1.1 christos 0, /* src_mask */
947 1.1 christos 0x0000ffff, /* dst_mask */
948 1.1 christos TRUE), /* pcrel_offset */
949 1.1 christos
950 1.1 christos /* 16 bit call through global offset table. */
951 1.1 christos HOWTO (R_MIPS_CALL16, /* type */
952 1.1 christos 0, /* rightshift */
953 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
954 1.1 christos 16, /* bitsize */
955 1.1 christos FALSE, /* pc_relative */
956 1.1 christos 0, /* bitpos */
957 1.1 christos complain_overflow_signed, /* complain_on_overflow */
958 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
959 1.1 christos "R_MIPS_CALL16", /* name */
960 1.1 christos FALSE, /* partial_inplace */
961 1.1 christos 0, /* src_mask */
962 1.1 christos 0x0000ffff, /* dst_mask */
963 1.1 christos FALSE), /* pcrel_offset */
964 1.1 christos
965 1.1 christos /* 32 bit GP relative reference. */
966 1.1 christos HOWTO (R_MIPS_GPREL32, /* type */
967 1.1 christos 0, /* rightshift */
968 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
969 1.1 christos 32, /* bitsize */
970 1.1 christos FALSE, /* pc_relative */
971 1.1 christos 0, /* bitpos */
972 1.1 christos complain_overflow_dont, /* complain_on_overflow */
973 1.1 christos mips_elf_gprel32_reloc, /* special_function */
974 1.1 christos "R_MIPS_GPREL32", /* name */
975 1.1 christos FALSE, /* partial_inplace */
976 1.1 christos 0, /* src_mask */
977 1.1 christos 0xffffffff, /* dst_mask */
978 1.1 christos FALSE), /* pcrel_offset */
979 1.1 christos
980 1.1 christos EMPTY_HOWTO (13),
981 1.1 christos EMPTY_HOWTO (14),
982 1.1 christos EMPTY_HOWTO (15),
983 1.1 christos
984 1.1 christos /* A 5 bit shift field. */
985 1.1 christos HOWTO (R_MIPS_SHIFT5, /* type */
986 1.1 christos 0, /* rightshift */
987 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
988 1.1 christos 5, /* bitsize */
989 1.1 christos FALSE, /* pc_relative */
990 1.1 christos 6, /* bitpos */
991 1.1 christos complain_overflow_bitfield, /* complain_on_overflow */
992 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
993 1.1 christos "R_MIPS_SHIFT5", /* name */
994 1.1 christos FALSE, /* partial_inplace */
995 1.1 christos 0, /* src_mask */
996 1.1 christos 0x000007c0, /* dst_mask */
997 1.1 christos FALSE), /* pcrel_offset */
998 1.1 christos
999 1.1 christos /* A 6 bit shift field. */
1000 1.1 christos HOWTO (R_MIPS_SHIFT6, /* type */
1001 1.1 christos 0, /* rightshift */
1002 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1003 1.1 christos 6, /* bitsize */
1004 1.1 christos FALSE, /* pc_relative */
1005 1.1 christos 6, /* bitpos */
1006 1.1 christos complain_overflow_bitfield, /* complain_on_overflow */
1007 1.1 christos mips_elf_shift6_reloc, /* special_function */
1008 1.1 christos "R_MIPS_SHIFT6", /* name */
1009 1.1 christos FALSE, /* partial_inplace */
1010 1.1 christos 0, /* src_mask */
1011 1.1 christos 0x000007c4, /* dst_mask */
1012 1.1 christos FALSE), /* pcrel_offset */
1013 1.1 christos
1014 1.1 christos /* 64 bit relocation. */
1015 1.1 christos HOWTO (R_MIPS_64, /* type */
1016 1.1 christos 0, /* rightshift */
1017 1.1 christos 4, /* size (0 = byte, 1 = short, 2 = long) */
1018 1.1 christos 64, /* bitsize */
1019 1.1 christos FALSE, /* pc_relative */
1020 1.1 christos 0, /* bitpos */
1021 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1022 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1023 1.1 christos "R_MIPS_64", /* name */
1024 1.1 christos FALSE, /* partial_inplace */
1025 1.1 christos 0, /* src_mask */
1026 1.1 christos MINUS_ONE, /* dst_mask */
1027 1.1 christos FALSE), /* pcrel_offset */
1028 1.1 christos
1029 1.1 christos /* Displacement in the global offset table. */
1030 1.1 christos HOWTO (R_MIPS_GOT_DISP, /* type */
1031 1.1 christos 0, /* rightshift */
1032 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1033 1.1 christos 16, /* bitsize */
1034 1.1 christos FALSE, /* pc_relative */
1035 1.1 christos 0, /* bitpos */
1036 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1037 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1038 1.1 christos "R_MIPS_GOT_DISP", /* name */
1039 1.1 christos FALSE, /* partial_inplace */
1040 1.1 christos 0, /* src_mask */
1041 1.1 christos 0x0000ffff, /* dst_mask */
1042 1.1 christos FALSE), /* pcrel_offset */
1043 1.1 christos
1044 1.1 christos /* Displacement to page pointer in the global offset table. */
1045 1.1 christos HOWTO (R_MIPS_GOT_PAGE, /* type */
1046 1.1 christos 0, /* rightshift */
1047 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1048 1.1 christos 16, /* bitsize */
1049 1.1 christos FALSE, /* pc_relative */
1050 1.1 christos 0, /* bitpos */
1051 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1052 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1053 1.1 christos "R_MIPS_GOT_PAGE", /* name */
1054 1.1 christos FALSE, /* partial_inplace */
1055 1.1 christos 0, /* src_mask */
1056 1.1 christos 0x0000ffff, /* dst_mask */
1057 1.1 christos FALSE), /* pcrel_offset */
1058 1.1 christos
1059 1.1 christos /* Offset from page pointer in the global offset table. */
1060 1.1 christos HOWTO (R_MIPS_GOT_OFST, /* type */
1061 1.1 christos 0, /* rightshift */
1062 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1063 1.1 christos 16, /* bitsize */
1064 1.1 christos FALSE, /* pc_relative */
1065 1.1 christos 0, /* bitpos */
1066 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1067 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1068 1.1 christos "R_MIPS_GOT_OFST", /* name */
1069 1.1 christos FALSE, /* partial_inplace */
1070 1.1 christos 0, /* src_mask */
1071 1.1 christos 0x0000ffff, /* dst_mask */
1072 1.1 christos FALSE), /* pcrel_offset */
1073 1.1 christos
1074 1.1 christos /* High 16 bits of displacement in global offset table. */
1075 1.1 christos HOWTO (R_MIPS_GOT_HI16, /* type */
1076 1.1 christos 0, /* rightshift */
1077 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1078 1.1 christos 16, /* bitsize */
1079 1.1 christos FALSE, /* pc_relative */
1080 1.1 christos 0, /* bitpos */
1081 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1082 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1083 1.1 christos "R_MIPS_GOT_HI16", /* name */
1084 1.1 christos FALSE, /* partial_inplace */
1085 1.1 christos 0, /* src_mask */
1086 1.1 christos 0x0000ffff, /* dst_mask */
1087 1.1 christos FALSE), /* pcrel_offset */
1088 1.1 christos
1089 1.1 christos /* Low 16 bits of displacement in global offset table. */
1090 1.1 christos HOWTO (R_MIPS_GOT_LO16, /* type */
1091 1.1 christos 0, /* rightshift */
1092 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1093 1.1 christos 16, /* bitsize */
1094 1.1 christos FALSE, /* pc_relative */
1095 1.1 christos 0, /* bitpos */
1096 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1097 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1098 1.1 christos "R_MIPS_GOT_LO16", /* name */
1099 1.1 christos FALSE, /* partial_inplace */
1100 1.1 christos 0, /* src_mask */
1101 1.1 christos 0x0000ffff, /* dst_mask */
1102 1.1 christos FALSE), /* pcrel_offset */
1103 1.1 christos
1104 1.1 christos /* 64 bit subtraction. */
1105 1.1 christos HOWTO (R_MIPS_SUB, /* type */
1106 1.1 christos 0, /* rightshift */
1107 1.1 christos 4, /* size (0 = byte, 1 = short, 2 = long) */
1108 1.1 christos 64, /* bitsize */
1109 1.1 christos FALSE, /* pc_relative */
1110 1.1 christos 0, /* bitpos */
1111 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1112 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1113 1.1 christos "R_MIPS_SUB", /* name */
1114 1.1 christos FALSE, /* partial_inplace */
1115 1.1 christos 0, /* src_mask */
1116 1.1 christos MINUS_ONE, /* dst_mask */
1117 1.1 christos FALSE), /* pcrel_offset */
1118 1.1 christos
1119 1.1 christos /* Insert the addend as an instruction. */
1120 1.1 christos /* FIXME: Not handled correctly. */
1121 1.1 christos HOWTO (R_MIPS_INSERT_A, /* type */
1122 1.1 christos 0, /* rightshift */
1123 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1124 1.1 christos 32, /* bitsize */
1125 1.1 christos FALSE, /* pc_relative */
1126 1.1 christos 0, /* bitpos */
1127 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1128 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1129 1.1 christos "R_MIPS_INSERT_A", /* name */
1130 1.1 christos FALSE, /* partial_inplace */
1131 1.1 christos 0, /* src_mask */
1132 1.1 christos 0xffffffff, /* dst_mask */
1133 1.1 christos FALSE), /* pcrel_offset */
1134 1.1 christos
1135 1.1 christos /* Insert the addend as an instruction, and change all relocations
1136 1.1 christos to refer to the old instruction at the address. */
1137 1.1 christos /* FIXME: Not handled correctly. */
1138 1.1 christos HOWTO (R_MIPS_INSERT_B, /* type */
1139 1.1 christos 0, /* rightshift */
1140 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1141 1.1 christos 32, /* bitsize */
1142 1.1 christos FALSE, /* pc_relative */
1143 1.1 christos 0, /* bitpos */
1144 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1145 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1146 1.1 christos "R_MIPS_INSERT_B", /* name */
1147 1.1 christos FALSE, /* partial_inplace */
1148 1.1 christos 0, /* src_mask */
1149 1.1 christos 0xffffffff, /* dst_mask */
1150 1.1 christos FALSE), /* pcrel_offset */
1151 1.1 christos
1152 1.1 christos /* Delete a 32 bit instruction. */
1153 1.1 christos /* FIXME: Not handled correctly. */
1154 1.1 christos HOWTO (R_MIPS_DELETE, /* type */
1155 1.1 christos 0, /* rightshift */
1156 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1157 1.1 christos 32, /* bitsize */
1158 1.1 christos FALSE, /* pc_relative */
1159 1.1 christos 0, /* bitpos */
1160 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1161 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1162 1.1 christos "R_MIPS_DELETE", /* name */
1163 1.1 christos FALSE, /* partial_inplace */
1164 1.1 christos 0, /* src_mask */
1165 1.1 christos 0xffffffff, /* dst_mask */
1166 1.1 christos FALSE), /* pcrel_offset */
1167 1.1 christos
1168 1.1 christos /* Get the higher value of a 64 bit addend. */
1169 1.1 christos HOWTO (R_MIPS_HIGHER, /* type */
1170 1.1 christos 0, /* rightshift */
1171 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1172 1.1 christos 16, /* bitsize */
1173 1.1 christos FALSE, /* pc_relative */
1174 1.1 christos 0, /* bitpos */
1175 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1176 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1177 1.1 christos "R_MIPS_HIGHER", /* name */
1178 1.1 christos FALSE, /* partial_inplace */
1179 1.1 christos 0, /* src_mask */
1180 1.1 christos 0x0000ffff, /* dst_mask */
1181 1.1 christos FALSE), /* pcrel_offset */
1182 1.1 christos
1183 1.1 christos /* Get the highest value of a 64 bit addend. */
1184 1.1 christos HOWTO (R_MIPS_HIGHEST, /* type */
1185 1.1 christos 0, /* rightshift */
1186 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1187 1.1 christos 16, /* bitsize */
1188 1.1 christos FALSE, /* pc_relative */
1189 1.1 christos 0, /* bitpos */
1190 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1191 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1192 1.1 christos "R_MIPS_HIGHEST", /* name */
1193 1.1 christos FALSE, /* partial_inplace */
1194 1.1 christos 0, /* src_mask */
1195 1.1 christos 0x0000ffff, /* dst_mask */
1196 1.1 christos FALSE), /* pcrel_offset */
1197 1.1 christos
1198 1.1 christos /* High 16 bits of displacement in global offset table. */
1199 1.1 christos HOWTO (R_MIPS_CALL_HI16, /* type */
1200 1.1 christos 0, /* rightshift */
1201 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1202 1.1 christos 16, /* bitsize */
1203 1.1 christos FALSE, /* pc_relative */
1204 1.1 christos 0, /* bitpos */
1205 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1206 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1207 1.1 christos "R_MIPS_CALL_HI16", /* name */
1208 1.1 christos FALSE, /* partial_inplace */
1209 1.1 christos 0, /* src_mask */
1210 1.1 christos 0x0000ffff, /* dst_mask */
1211 1.1 christos FALSE), /* pcrel_offset */
1212 1.1 christos
1213 1.1 christos /* Low 16 bits of displacement in global offset table. */
1214 1.1 christos HOWTO (R_MIPS_CALL_LO16, /* type */
1215 1.1 christos 0, /* rightshift */
1216 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1217 1.1 christos 16, /* bitsize */
1218 1.1 christos FALSE, /* pc_relative */
1219 1.1 christos 0, /* bitpos */
1220 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1221 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1222 1.1 christos "R_MIPS_CALL_LO16", /* name */
1223 1.1 christos FALSE, /* partial_inplace */
1224 1.1 christos 0, /* src_mask */
1225 1.1 christos 0x0000ffff, /* dst_mask */
1226 1.1 christos FALSE), /* pcrel_offset */
1227 1.1 christos
1228 1.1 christos /* Section displacement, used by an associated event location section. */
1229 1.1 christos HOWTO (R_MIPS_SCN_DISP, /* type */
1230 1.1 christos 0, /* rightshift */
1231 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1232 1.1 christos 32, /* bitsize */
1233 1.1 christos FALSE, /* pc_relative */
1234 1.1 christos 0, /* bitpos */
1235 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1236 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1237 1.1 christos "R_MIPS_SCN_DISP", /* name */
1238 1.1 christos FALSE, /* partial_inplace */
1239 1.1 christos 0, /* src_mask */
1240 1.1 christos 0xffffffff, /* dst_mask */
1241 1.1 christos FALSE), /* pcrel_offset */
1242 1.1 christos
1243 1.1 christos /* 16 bit relocation. */
1244 1.1 christos HOWTO (R_MIPS_REL16, /* type */
1245 1.1 christos 0, /* rightshift */
1246 1.1 christos 1, /* size (0 = byte, 1 = short, 2 = long) */
1247 1.1 christos 16, /* bitsize */
1248 1.1 christos FALSE, /* pc_relative */
1249 1.1 christos 0, /* bitpos */
1250 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1251 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1252 1.1 christos "R_MIPS_REL16", /* name */
1253 1.1 christos FALSE, /* partial_inplace */
1254 1.1 christos 0, /* src_mask */
1255 1.1 christos 0xffff, /* dst_mask */
1256 1.1 christos FALSE), /* pcrel_offset */
1257 1.1 christos
1258 1.1 christos /* These two are obsolete. */
1259 1.1 christos EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
1260 1.1 christos EMPTY_HOWTO (R_MIPS_PJUMP),
1261 1.1 christos
1262 1.1 christos /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
1263 1.1 christos It must be used for multigot GOT's (and only there). */
1264 1.1 christos HOWTO (R_MIPS_RELGOT, /* type */
1265 1.1 christos 0, /* rightshift */
1266 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1267 1.1 christos 32, /* bitsize */
1268 1.1 christos FALSE, /* pc_relative */
1269 1.1 christos 0, /* bitpos */
1270 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1271 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1272 1.1 christos "R_MIPS_RELGOT", /* name */
1273 1.1 christos FALSE, /* partial_inplace */
1274 1.1 christos 0, /* src_mask */
1275 1.1 christos 0xffffffff, /* dst_mask */
1276 1.1 christos FALSE), /* pcrel_offset */
1277 1.1 christos
1278 1.1 christos /* Protected jump conversion. This is an optimization hint. No
1279 1.1 christos relocation is required for correctness. */
1280 1.1 christos HOWTO (R_MIPS_JALR, /* type */
1281 1.1 christos 0, /* rightshift */
1282 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1283 1.1 christos 32, /* bitsize */
1284 1.1 christos FALSE, /* pc_relative */
1285 1.1 christos 0, /* bitpos */
1286 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1287 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1288 1.1 christos "R_MIPS_JALR", /* name */
1289 1.1 christos FALSE, /* partial_inplace */
1290 1.1 christos 0, /* src_mask */
1291 1.1 christos 0, /* dst_mask */
1292 1.1 christos FALSE), /* pcrel_offset */
1293 1.1 christos
1294 1.1 christos /* TLS GD/LD dynamic relocations. */
1295 1.1 christos HOWTO (R_MIPS_TLS_DTPMOD32, /* type */
1296 1.1 christos 0, /* rightshift */
1297 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1298 1.1 christos 32, /* bitsize */
1299 1.1 christos FALSE, /* pc_relative */
1300 1.1 christos 0, /* bitpos */
1301 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1302 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1303 1.1 christos "R_MIPS_TLS_DTPMOD32", /* name */
1304 1.1 christos FALSE, /* partial_inplace */
1305 1.1 christos 0, /* src_mask */
1306 1.1 christos 0xffffffff, /* dst_mask */
1307 1.1 christos FALSE), /* pcrel_offset */
1308 1.1 christos
1309 1.1 christos HOWTO (R_MIPS_TLS_DTPREL32, /* type */
1310 1.1 christos 0, /* rightshift */
1311 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1312 1.1 christos 32, /* bitsize */
1313 1.1 christos FALSE, /* pc_relative */
1314 1.1 christos 0, /* bitpos */
1315 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1316 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1317 1.1 christos "R_MIPS_TLS_DTPREL32", /* name */
1318 1.1 christos FALSE, /* partial_inplace */
1319 1.1 christos 0, /* src_mask */
1320 1.1 christos 0xffffffff, /* dst_mask */
1321 1.1 christos FALSE), /* pcrel_offset */
1322 1.1 christos
1323 1.1 christos EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
1324 1.1 christos EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
1325 1.1 christos
1326 1.1 christos /* TLS general dynamic variable reference. */
1327 1.1 christos HOWTO (R_MIPS_TLS_GD, /* type */
1328 1.1 christos 0, /* rightshift */
1329 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1330 1.1 christos 16, /* bitsize */
1331 1.1 christos FALSE, /* pc_relative */
1332 1.1 christos 0, /* bitpos */
1333 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1334 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1335 1.1 christos "R_MIPS_TLS_GD", /* name */
1336 1.1 christos FALSE, /* partial_inplace */
1337 1.1 christos 0, /* src_mask */
1338 1.1 christos 0x0000ffff, /* dst_mask */
1339 1.1 christos FALSE), /* pcrel_offset */
1340 1.1 christos
1341 1.1 christos /* TLS local dynamic variable reference. */
1342 1.1 christos HOWTO (R_MIPS_TLS_LDM, /* type */
1343 1.1 christos 0, /* rightshift */
1344 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1345 1.1 christos 16, /* bitsize */
1346 1.1 christos FALSE, /* pc_relative */
1347 1.1 christos 0, /* bitpos */
1348 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1349 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1350 1.1 christos "R_MIPS_TLS_LDM", /* name */
1351 1.1 christos FALSE, /* partial_inplace */
1352 1.1 christos 0, /* src_mask */
1353 1.1 christos 0x0000ffff, /* dst_mask */
1354 1.1 christos FALSE), /* pcrel_offset */
1355 1.1 christos
1356 1.1 christos /* TLS local dynamic offset. */
1357 1.1 christos HOWTO (R_MIPS_TLS_DTPREL_HI16, /* type */
1358 1.1 christos 0, /* rightshift */
1359 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1360 1.1 christos 16, /* bitsize */
1361 1.1 christos FALSE, /* pc_relative */
1362 1.1 christos 0, /* bitpos */
1363 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1364 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1365 1.1 christos "R_MIPS_TLS_DTPREL_HI16", /* name */
1366 1.1 christos FALSE, /* partial_inplace */
1367 1.1 christos 0, /* src_mask */
1368 1.1 christos 0x0000ffff, /* dst_mask */
1369 1.1 christos FALSE), /* pcrel_offset */
1370 1.1 christos
1371 1.1 christos /* TLS local dynamic offset. */
1372 1.1 christos HOWTO (R_MIPS_TLS_DTPREL_LO16, /* type */
1373 1.1 christos 0, /* rightshift */
1374 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1375 1.1 christos 16, /* bitsize */
1376 1.1 christos FALSE, /* pc_relative */
1377 1.1 christos 0, /* bitpos */
1378 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1379 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1380 1.1 christos "R_MIPS_TLS_DTPREL_LO16", /* name */
1381 1.1 christos FALSE, /* partial_inplace */
1382 1.1 christos 0, /* src_mask */
1383 1.1 christos 0x0000ffff, /* dst_mask */
1384 1.1 christos FALSE), /* pcrel_offset */
1385 1.1 christos
1386 1.1 christos /* TLS thread pointer offset. */
1387 1.1 christos HOWTO (R_MIPS_TLS_GOTTPREL, /* type */
1388 1.1 christos 0, /* rightshift */
1389 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1390 1.1 christos 16, /* bitsize */
1391 1.1 christos FALSE, /* pc_relative */
1392 1.1 christos 0, /* bitpos */
1393 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1394 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1395 1.1 christos "R_MIPS_TLS_GOTTPREL", /* name */
1396 1.1 christos FALSE, /* partial_inplace */
1397 1.1 christos 0, /* src_mask */
1398 1.1 christos 0x0000ffff, /* dst_mask */
1399 1.1 christos FALSE), /* pcrel_offset */
1400 1.1 christos
1401 1.1 christos /* TLS IE dynamic relocations. */
1402 1.1 christos HOWTO (R_MIPS_TLS_TPREL32, /* type */
1403 1.1 christos 0, /* rightshift */
1404 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1405 1.1 christos 32, /* bitsize */
1406 1.1 christos FALSE, /* pc_relative */
1407 1.1 christos 0, /* bitpos */
1408 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1409 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1410 1.1 christos "R_MIPS_TLS_TPREL32", /* name */
1411 1.1 christos FALSE, /* partial_inplace */
1412 1.1 christos 0, /* src_mask */
1413 1.1 christos 0xffffffff, /* dst_mask */
1414 1.1 christos FALSE), /* pcrel_offset */
1415 1.1 christos
1416 1.1 christos EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
1417 1.1 christos
1418 1.1 christos /* TLS thread pointer offset. */
1419 1.1 christos HOWTO (R_MIPS_TLS_TPREL_HI16, /* type */
1420 1.1 christos 0, /* rightshift */
1421 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1422 1.1 christos 16, /* bitsize */
1423 1.1 christos FALSE, /* pc_relative */
1424 1.1 christos 0, /* bitpos */
1425 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1426 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1427 1.1 christos "R_MIPS_TLS_TPREL_HI16", /* name */
1428 1.1 christos FALSE, /* partial_inplace */
1429 1.1 christos 0, /* src_mask */
1430 1.1 christos 0x0000ffff, /* dst_mask */
1431 1.1 christos FALSE), /* pcrel_offset */
1432 1.1 christos
1433 1.1 christos /* TLS thread pointer offset. */
1434 1.1 christos HOWTO (R_MIPS_TLS_TPREL_LO16, /* type */
1435 1.1 christos 0, /* rightshift */
1436 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1437 1.1 christos 16, /* bitsize */
1438 1.1 christos FALSE, /* pc_relative */
1439 1.1 christos 0, /* bitpos */
1440 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1441 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1442 1.1 christos "R_MIPS_TLS_TPREL_LO16", /* name */
1443 1.1 christos FALSE, /* partial_inplace */
1444 1.1 christos 0, /* src_mask */
1445 1.1 christos 0x0000ffff, /* dst_mask */
1446 1.1 christos FALSE), /* pcrel_offset */
1447 1.1 christos
1448 1.1 christos /* 32 bit relocation with no addend. */
1449 1.1 christos HOWTO (R_MIPS_GLOB_DAT, /* type */
1450 1.1 christos 0, /* rightshift */
1451 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1452 1.1 christos 32, /* bitsize */
1453 1.1 christos FALSE, /* pc_relative */
1454 1.1 christos 0, /* bitpos */
1455 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1456 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1457 1.1 christos "R_MIPS_GLOB_DAT", /* name */
1458 1.1 christos FALSE, /* partial_inplace */
1459 1.1 christos 0x0, /* src_mask */
1460 1.1 christos 0xffffffff, /* dst_mask */
1461 1.1 christos FALSE), /* pcrel_offset */
1462 1.1 christos };
1463 1.1 christos
1464 1.1 christos static reloc_howto_type elf_mips16_howto_table_rel[] =
1465 1.1 christos {
1466 1.1 christos /* The reloc used for the mips16 jump instruction. */
1467 1.1 christos HOWTO (R_MIPS16_26, /* type */
1468 1.1 christos 2, /* rightshift */
1469 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1470 1.1 christos 26, /* bitsize */
1471 1.1 christos FALSE, /* pc_relative */
1472 1.1 christos 0, /* bitpos */
1473 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1474 1.1 christos /* This needs complex overflow
1475 1.1 christos detection, because the upper four
1476 1.1 christos bits must match the PC. */
1477 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1478 1.1 christos "R_MIPS16_26", /* name */
1479 1.1 christos TRUE, /* partial_inplace */
1480 1.1 christos 0x3ffffff, /* src_mask */
1481 1.1 christos 0x3ffffff, /* dst_mask */
1482 1.1 christos FALSE), /* pcrel_offset */
1483 1.1 christos
1484 1.1 christos /* The reloc used for the mips16 gprel instruction. */
1485 1.1 christos HOWTO (R_MIPS16_GPREL, /* type */
1486 1.1 christos 0, /* rightshift */
1487 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1488 1.1 christos 16, /* bitsize */
1489 1.1 christos FALSE, /* pc_relative */
1490 1.1 christos 0, /* bitpos */
1491 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1492 1.1 christos mips16_gprel_reloc, /* special_function */
1493 1.1 christos "R_MIPS16_GPREL", /* name */
1494 1.1 christos TRUE, /* partial_inplace */
1495 1.1 christos 0x0000ffff, /* src_mask */
1496 1.1 christos 0x0000ffff, /* dst_mask */
1497 1.1 christos FALSE), /* pcrel_offset */
1498 1.1 christos
1499 1.1 christos /* A MIPS16 reference to the global offset table. */
1500 1.1 christos HOWTO (R_MIPS16_GOT16, /* type */
1501 1.1 christos 0, /* rightshift */
1502 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1503 1.1 christos 16, /* bitsize */
1504 1.1 christos FALSE, /* pc_relative */
1505 1.1 christos 0, /* bitpos */
1506 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1507 1.1 christos _bfd_mips_elf_got16_reloc, /* special_function */
1508 1.1 christos "R_MIPS16_GOT16", /* name */
1509 1.1 christos TRUE, /* partial_inplace */
1510 1.1 christos 0x0000ffff, /* src_mask */
1511 1.1 christos 0x0000ffff, /* dst_mask */
1512 1.1 christos FALSE), /* pcrel_offset */
1513 1.1 christos
1514 1.1 christos /* A MIPS16 call through the global offset table. */
1515 1.1 christos HOWTO (R_MIPS16_CALL16, /* type */
1516 1.1 christos 0, /* rightshift */
1517 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1518 1.1 christos 16, /* bitsize */
1519 1.1 christos FALSE, /* pc_relative */
1520 1.1 christos 0, /* bitpos */
1521 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1522 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1523 1.1 christos "R_MIPS16_CALL16", /* name */
1524 1.1 christos TRUE, /* partial_inplace */
1525 1.1 christos 0x0000ffff, /* src_mask */
1526 1.1 christos 0x0000ffff, /* dst_mask */
1527 1.1 christos FALSE), /* pcrel_offset */
1528 1.1 christos
1529 1.1 christos /* MIPS16 high 16 bits of symbol value. */
1530 1.1 christos HOWTO (R_MIPS16_HI16, /* type */
1531 1.1 christos 16, /* rightshift */
1532 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1533 1.1 christos 16, /* bitsize */
1534 1.1 christos FALSE, /* pc_relative */
1535 1.1 christos 0, /* bitpos */
1536 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1537 1.1 christos _bfd_mips_elf_hi16_reloc, /* special_function */
1538 1.1 christos "R_MIPS16_HI16", /* name */
1539 1.1 christos TRUE, /* partial_inplace */
1540 1.1 christos 0x0000ffff, /* src_mask */
1541 1.1 christos 0x0000ffff, /* dst_mask */
1542 1.1 christos FALSE), /* pcrel_offset */
1543 1.1 christos
1544 1.1 christos /* MIPS16 low 16 bits of symbol value. */
1545 1.1 christos HOWTO (R_MIPS16_LO16, /* type */
1546 1.1 christos 0, /* rightshift */
1547 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1548 1.1 christos 16, /* bitsize */
1549 1.1 christos FALSE, /* pc_relative */
1550 1.1 christos 0, /* bitpos */
1551 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1552 1.1 christos _bfd_mips_elf_lo16_reloc, /* special_function */
1553 1.1 christos "R_MIPS16_LO16", /* name */
1554 1.1 christos TRUE, /* partial_inplace */
1555 1.1 christos 0x0000ffff, /* src_mask */
1556 1.1 christos 0x0000ffff, /* dst_mask */
1557 1.1 christos FALSE), /* pcrel_offset */
1558 1.1 christos
1559 1.1 christos /* MIPS16 TLS general dynamic variable reference. */
1560 1.1 christos HOWTO (R_MIPS16_TLS_GD, /* type */
1561 1.1 christos 0, /* rightshift */
1562 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1563 1.1 christos 16, /* bitsize */
1564 1.1 christos FALSE, /* pc_relative */
1565 1.1 christos 0, /* bitpos */
1566 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1567 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1568 1.1 christos "R_MIPS16_TLS_GD", /* name */
1569 1.1 christos TRUE, /* partial_inplace */
1570 1.1 christos 0x0000ffff, /* src_mask */
1571 1.1 christos 0x0000ffff, /* dst_mask */
1572 1.1 christos FALSE), /* pcrel_offset */
1573 1.1 christos
1574 1.1 christos /* MIPS16 TLS local dynamic variable reference. */
1575 1.1 christos HOWTO (R_MIPS16_TLS_LDM, /* type */
1576 1.1 christos 0, /* rightshift */
1577 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1578 1.1 christos 16, /* bitsize */
1579 1.1 christos FALSE, /* pc_relative */
1580 1.1 christos 0, /* bitpos */
1581 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1582 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1583 1.1 christos "R_MIPS16_TLS_LDM", /* name */
1584 1.1 christos TRUE, /* partial_inplace */
1585 1.1 christos 0x0000ffff, /* src_mask */
1586 1.1 christos 0x0000ffff, /* dst_mask */
1587 1.1 christos FALSE), /* pcrel_offset */
1588 1.1 christos
1589 1.1 christos /* MIPS16 TLS local dynamic offset. */
1590 1.1 christos HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */
1591 1.1 christos 0, /* rightshift */
1592 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1593 1.1 christos 16, /* bitsize */
1594 1.1 christos FALSE, /* pc_relative */
1595 1.1 christos 0, /* bitpos */
1596 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1597 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1598 1.1 christos "R_MIPS16_TLS_DTPREL_HI16", /* name */
1599 1.1 christos TRUE, /* partial_inplace */
1600 1.1 christos 0x0000ffff, /* src_mask */
1601 1.1 christos 0x0000ffff, /* dst_mask */
1602 1.1 christos FALSE), /* pcrel_offset */
1603 1.1 christos
1604 1.1 christos /* MIPS16 TLS local dynamic offset. */
1605 1.1 christos HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */
1606 1.1 christos 0, /* rightshift */
1607 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1608 1.1 christos 16, /* bitsize */
1609 1.1 christos FALSE, /* pc_relative */
1610 1.1 christos 0, /* bitpos */
1611 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1612 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1613 1.1 christos "R_MIPS16_TLS_DTPREL_LO16", /* name */
1614 1.1 christos TRUE, /* partial_inplace */
1615 1.1 christos 0x0000ffff, /* src_mask */
1616 1.1 christos 0x0000ffff, /* dst_mask */
1617 1.1 christos FALSE), /* pcrel_offset */
1618 1.1 christos
1619 1.1 christos /* MIPS16 TLS thread pointer offset. */
1620 1.1 christos HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */
1621 1.1 christos 0, /* rightshift */
1622 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1623 1.1 christos 16, /* bitsize */
1624 1.1 christos FALSE, /* pc_relative */
1625 1.1 christos 0, /* bitpos */
1626 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1627 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1628 1.1 christos "R_MIPS16_TLS_GOTTPREL", /* name */
1629 1.1 christos TRUE, /* partial_inplace */
1630 1.1 christos 0x0000ffff, /* src_mask */
1631 1.1 christos 0x0000ffff, /* dst_mask */
1632 1.1 christos FALSE), /* pcrel_offset */
1633 1.1 christos
1634 1.1 christos /* MIPS16 TLS thread pointer offset. */
1635 1.1 christos HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */
1636 1.1 christos 0, /* rightshift */
1637 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1638 1.1 christos 16, /* bitsize */
1639 1.1 christos FALSE, /* pc_relative */
1640 1.1 christos 0, /* bitpos */
1641 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1642 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1643 1.1 christos "R_MIPS16_TLS_TPREL_HI16", /* name */
1644 1.1 christos TRUE, /* partial_inplace */
1645 1.1 christos 0x0000ffff, /* src_mask */
1646 1.1 christos 0x0000ffff, /* dst_mask */
1647 1.1 christos FALSE), /* pcrel_offset */
1648 1.1 christos
1649 1.1 christos /* MIPS16 TLS thread pointer offset. */
1650 1.1 christos HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */
1651 1.1 christos 0, /* rightshift */
1652 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1653 1.1 christos 16, /* bitsize */
1654 1.1 christos FALSE, /* pc_relative */
1655 1.1 christos 0, /* bitpos */
1656 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1657 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1658 1.1 christos "R_MIPS16_TLS_TPREL_LO16", /* name */
1659 1.1 christos TRUE, /* partial_inplace */
1660 1.1 christos 0x0000ffff, /* src_mask */
1661 1.1 christos 0x0000ffff, /* dst_mask */
1662 1.1 christos FALSE), /* pcrel_offset */
1663 1.1 christos };
1664 1.1 christos
1665 1.1 christos static reloc_howto_type elf_mips16_howto_table_rela[] =
1666 1.1 christos {
1667 1.1 christos /* The reloc used for the mips16 jump instruction. */
1668 1.1 christos HOWTO (R_MIPS16_26, /* type */
1669 1.1 christos 2, /* rightshift */
1670 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1671 1.1 christos 26, /* bitsize */
1672 1.1 christos FALSE, /* pc_relative */
1673 1.1 christos 0, /* bitpos */
1674 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1675 1.1 christos /* This needs complex overflow
1676 1.1 christos detection, because the upper four
1677 1.1 christos bits must match the PC. */
1678 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1679 1.1 christos "R_MIPS16_26", /* name */
1680 1.1 christos FALSE, /* partial_inplace */
1681 1.1 christos 0, /* src_mask */
1682 1.1 christos 0x3ffffff, /* dst_mask */
1683 1.1 christos FALSE), /* pcrel_offset */
1684 1.1 christos
1685 1.1 christos /* The reloc used for the mips16 gprel instruction. */
1686 1.1 christos HOWTO (R_MIPS16_GPREL, /* type */
1687 1.1 christos 0, /* rightshift */
1688 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1689 1.1 christos 16, /* bitsize */
1690 1.1 christos FALSE, /* pc_relative */
1691 1.1 christos 0, /* bitpos */
1692 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1693 1.1 christos mips16_gprel_reloc, /* special_function */
1694 1.1 christos "R_MIPS16_GPREL", /* name */
1695 1.1 christos FALSE, /* partial_inplace */
1696 1.1 christos 0, /* src_mask */
1697 1.1 christos 0x0000ffff, /* dst_mask */
1698 1.1 christos FALSE), /* pcrel_offset */
1699 1.1 christos
1700 1.1 christos /* A MIPS16 reference to the global offset table. */
1701 1.1 christos HOWTO (R_MIPS16_GOT16, /* type */
1702 1.1 christos 0, /* rightshift */
1703 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1704 1.1 christos 16, /* bitsize */
1705 1.1 christos FALSE, /* pc_relative */
1706 1.1 christos 0, /* bitpos */
1707 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1708 1.1 christos _bfd_mips_elf_got16_reloc, /* special_function */
1709 1.1 christos "R_MIPS16_GOT16", /* name */
1710 1.1 christos FALSE, /* partial_inplace */
1711 1.1 christos 0, /* src_mask */
1712 1.1 christos 0x0000ffff, /* dst_mask */
1713 1.1 christos FALSE), /* pcrel_offset */
1714 1.1 christos
1715 1.1 christos /* A MIPS16 call through the global offset table. */
1716 1.1 christos HOWTO (R_MIPS16_CALL16, /* type */
1717 1.1 christos 0, /* rightshift */
1718 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1719 1.1 christos 16, /* bitsize */
1720 1.1 christos FALSE, /* pc_relative */
1721 1.1 christos 0, /* bitpos */
1722 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1723 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1724 1.1 christos "R_MIPS16_CALL16", /* name */
1725 1.1 christos FALSE, /* partial_inplace */
1726 1.1 christos 0, /* src_mask */
1727 1.1 christos 0x0000ffff, /* dst_mask */
1728 1.1 christos FALSE), /* pcrel_offset */
1729 1.1 christos
1730 1.1 christos /* MIPS16 high 16 bits of symbol value. */
1731 1.1 christos HOWTO (R_MIPS16_HI16, /* type */
1732 1.1 christos 16, /* rightshift */
1733 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1734 1.1 christos 16, /* bitsize */
1735 1.1 christos FALSE, /* pc_relative */
1736 1.1 christos 0, /* bitpos */
1737 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1738 1.1 christos _bfd_mips_elf_hi16_reloc, /* special_function */
1739 1.1 christos "R_MIPS16_HI16", /* name */
1740 1.1 christos FALSE, /* partial_inplace */
1741 1.1 christos 0, /* src_mask */
1742 1.1 christos 0x0000ffff, /* dst_mask */
1743 1.1 christos FALSE), /* pcrel_offset */
1744 1.1 christos
1745 1.1 christos /* MIPS16 low 16 bits of symbol value. */
1746 1.1 christos HOWTO (R_MIPS16_LO16, /* type */
1747 1.1 christos 0, /* rightshift */
1748 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1749 1.1 christos 16, /* bitsize */
1750 1.1 christos FALSE, /* pc_relative */
1751 1.1 christos 0, /* bitpos */
1752 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1753 1.1 christos _bfd_mips_elf_lo16_reloc, /* special_function */
1754 1.1 christos "R_MIPS16_LO16", /* name */
1755 1.1 christos FALSE, /* partial_inplace */
1756 1.1 christos 0, /* src_mask */
1757 1.1 christos 0x0000ffff, /* dst_mask */
1758 1.1 christos FALSE), /* pcrel_offset */
1759 1.1 christos
1760 1.1 christos /* MIPS16 TLS general dynamic variable reference. */
1761 1.1 christos HOWTO (R_MIPS16_TLS_GD, /* type */
1762 1.1 christos 0, /* rightshift */
1763 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1764 1.1 christos 16, /* bitsize */
1765 1.1 christos FALSE, /* pc_relative */
1766 1.1 christos 0, /* bitpos */
1767 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1768 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1769 1.1 christos "R_MIPS16_TLS_GD", /* name */
1770 1.1 christos FALSE, /* partial_inplace */
1771 1.1 christos 0, /* src_mask */
1772 1.1 christos 0x0000ffff, /* dst_mask */
1773 1.1 christos FALSE), /* pcrel_offset */
1774 1.1 christos
1775 1.1 christos /* MIPS16 TLS local dynamic variable reference. */
1776 1.1 christos HOWTO (R_MIPS16_TLS_LDM, /* type */
1777 1.1 christos 0, /* rightshift */
1778 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1779 1.1 christos 16, /* bitsize */
1780 1.1 christos FALSE, /* pc_relative */
1781 1.1 christos 0, /* bitpos */
1782 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1783 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1784 1.1 christos "R_MIPS16_TLS_LDM", /* name */
1785 1.1 christos FALSE, /* partial_inplace */
1786 1.1 christos 0, /* src_mask */
1787 1.1 christos 0x0000ffff, /* dst_mask */
1788 1.1 christos FALSE), /* pcrel_offset */
1789 1.1 christos
1790 1.1 christos /* MIPS16 TLS local dynamic offset. */
1791 1.1 christos HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */
1792 1.1 christos 0, /* rightshift */
1793 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1794 1.1 christos 16, /* bitsize */
1795 1.1 christos FALSE, /* pc_relative */
1796 1.1 christos 0, /* bitpos */
1797 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1798 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1799 1.1 christos "R_MIPS16_TLS_DTPREL_HI16", /* name */
1800 1.1 christos FALSE, /* partial_inplace */
1801 1.1 christos 0, /* src_mask */
1802 1.1 christos 0x0000ffff, /* dst_mask */
1803 1.1 christos FALSE), /* pcrel_offset */
1804 1.1 christos
1805 1.1 christos /* MIPS16 TLS local dynamic offset. */
1806 1.1 christos HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */
1807 1.1 christos 0, /* rightshift */
1808 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1809 1.1 christos 16, /* bitsize */
1810 1.1 christos FALSE, /* pc_relative */
1811 1.1 christos 0, /* bitpos */
1812 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1813 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1814 1.1 christos "R_MIPS16_TLS_DTPREL_LO16", /* name */
1815 1.1 christos FALSE, /* partial_inplace */
1816 1.1 christos 0, /* src_mask */
1817 1.1 christos 0x0000ffff, /* dst_mask */
1818 1.1 christos FALSE), /* pcrel_offset */
1819 1.1 christos
1820 1.1 christos /* MIPS16 TLS thread pointer offset. */
1821 1.1 christos HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */
1822 1.1 christos 0, /* rightshift */
1823 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1824 1.1 christos 16, /* bitsize */
1825 1.1 christos FALSE, /* pc_relative */
1826 1.1 christos 0, /* bitpos */
1827 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1828 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1829 1.1 christos "R_MIPS16_TLS_GOTTPREL", /* name */
1830 1.1 christos FALSE, /* partial_inplace */
1831 1.1 christos 0, /* src_mask */
1832 1.1 christos 0x0000ffff, /* dst_mask */
1833 1.1 christos FALSE), /* pcrel_offset */
1834 1.1 christos
1835 1.1 christos /* MIPS16 TLS thread pointer offset. */
1836 1.1 christos HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */
1837 1.1 christos 0, /* rightshift */
1838 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1839 1.1 christos 16, /* bitsize */
1840 1.1 christos FALSE, /* pc_relative */
1841 1.1 christos 0, /* bitpos */
1842 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1843 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1844 1.1 christos "R_MIPS16_TLS_TPREL_HI16", /* name */
1845 1.1 christos FALSE, /* partial_inplace */
1846 1.1 christos 0, /* src_mask */
1847 1.1 christos 0x0000ffff, /* dst_mask */
1848 1.1 christos FALSE), /* pcrel_offset */
1849 1.1 christos
1850 1.1 christos /* MIPS16 TLS thread pointer offset. */
1851 1.1 christos HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */
1852 1.1 christos 0, /* rightshift */
1853 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1854 1.1 christos 16, /* bitsize */
1855 1.1 christos FALSE, /* pc_relative */
1856 1.1 christos 0, /* bitpos */
1857 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1858 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1859 1.1 christos "R_MIPS16_TLS_TPREL_LO16", /* name */
1860 1.1 christos FALSE, /* partial_inplace */
1861 1.1 christos 0, /* src_mask */
1862 1.1 christos 0x0000ffff, /* dst_mask */
1863 1.1 christos FALSE), /* pcrel_offset */
1864 1.1 christos };
1865 1.1 christos
1866 1.1 christos static reloc_howto_type elf_micromips_howto_table_rel[] =
1867 1.1 christos {
1868 1.1 christos EMPTY_HOWTO (130),
1869 1.1 christos EMPTY_HOWTO (131),
1870 1.1 christos EMPTY_HOWTO (132),
1871 1.1 christos
1872 1.1 christos /* 26 bit jump address. */
1873 1.1 christos HOWTO (R_MICROMIPS_26_S1, /* type */
1874 1.1 christos 1, /* rightshift */
1875 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1876 1.1 christos 26, /* bitsize */
1877 1.1 christos FALSE, /* pc_relative */
1878 1.1 christos 0, /* bitpos */
1879 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1880 1.1 christos /* This needs complex overflow
1881 1.1 christos detection, because the upper four
1882 1.1 christos bits must match the PC. */
1883 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1884 1.1 christos "R_MICROMIPS_26_S1", /* name */
1885 1.1 christos TRUE, /* partial_inplace */
1886 1.1 christos 0x3ffffff, /* src_mask */
1887 1.1 christos 0x3ffffff, /* dst_mask */
1888 1.1 christos FALSE), /* pcrel_offset */
1889 1.1 christos
1890 1.1 christos /* High 16 bits of symbol value. */
1891 1.1 christos HOWTO (R_MICROMIPS_HI16, /* type */
1892 1.1 christos 16, /* rightshift */
1893 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1894 1.1 christos 16, /* bitsize */
1895 1.1 christos FALSE, /* pc_relative */
1896 1.1 christos 0, /* bitpos */
1897 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1898 1.1 christos _bfd_mips_elf_hi16_reloc, /* special_function */
1899 1.1 christos "R_MICROMIPS_HI16", /* name */
1900 1.1 christos TRUE, /* partial_inplace */
1901 1.1 christos 0x0000ffff, /* src_mask */
1902 1.1 christos 0x0000ffff, /* dst_mask */
1903 1.1 christos FALSE), /* pcrel_offset */
1904 1.1 christos
1905 1.1 christos /* Low 16 bits of symbol value. */
1906 1.1 christos HOWTO (R_MICROMIPS_LO16, /* type */
1907 1.1 christos 0, /* rightshift */
1908 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1909 1.1 christos 16, /* bitsize */
1910 1.1 christos FALSE, /* pc_relative */
1911 1.1 christos 0, /* bitpos */
1912 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1913 1.1 christos _bfd_mips_elf_lo16_reloc, /* special_function */
1914 1.1 christos "R_MICROMIPS_LO16", /* name */
1915 1.1 christos TRUE, /* partial_inplace */
1916 1.1 christos 0x0000ffff, /* src_mask */
1917 1.1 christos 0x0000ffff, /* dst_mask */
1918 1.1 christos FALSE), /* pcrel_offset */
1919 1.1 christos
1920 1.1 christos /* GP relative reference. */
1921 1.1 christos HOWTO (R_MICROMIPS_GPREL16, /* type */
1922 1.1 christos 0, /* rightshift */
1923 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1924 1.1 christos 16, /* bitsize */
1925 1.1 christos FALSE, /* pc_relative */
1926 1.1 christos 0, /* bitpos */
1927 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1928 1.1 christos _bfd_mips_elf32_gprel16_reloc, /* special_function */
1929 1.1 christos "R_MICROMIPS_GPREL16", /* name */
1930 1.1 christos TRUE, /* partial_inplace */
1931 1.1 christos 0x0000ffff, /* src_mask */
1932 1.1 christos 0x0000ffff, /* dst_mask */
1933 1.1 christos FALSE), /* pcrel_offset */
1934 1.1 christos
1935 1.1 christos /* Reference to literal section. */
1936 1.1 christos HOWTO (R_MICROMIPS_LITERAL, /* type */
1937 1.1 christos 0, /* rightshift */
1938 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1939 1.1 christos 16, /* bitsize */
1940 1.1 christos FALSE, /* pc_relative */
1941 1.1 christos 0, /* bitpos */
1942 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1943 1.1 christos _bfd_mips_elf32_gprel16_reloc, /* special_function */
1944 1.1 christos "R_MICROMIPS_LITERAL", /* name */
1945 1.1 christos TRUE, /* partial_inplace */
1946 1.1 christos 0x0000ffff, /* src_mask */
1947 1.1 christos 0x0000ffff, /* dst_mask */
1948 1.1 christos FALSE), /* pcrel_offset */
1949 1.1 christos
1950 1.1 christos /* Reference to global offset table. */
1951 1.1 christos HOWTO (R_MICROMIPS_GOT16, /* type */
1952 1.1 christos 0, /* rightshift */
1953 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1954 1.1 christos 16, /* bitsize */
1955 1.1 christos FALSE, /* pc_relative */
1956 1.1 christos 0, /* bitpos */
1957 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1958 1.1 christos _bfd_mips_elf_got16_reloc, /* special_function */
1959 1.1 christos "R_MICROMIPS_GOT16", /* name */
1960 1.1 christos TRUE, /* partial_inplace */
1961 1.1 christos 0x0000ffff, /* src_mask */
1962 1.1 christos 0x0000ffff, /* dst_mask */
1963 1.1 christos FALSE), /* pcrel_offset */
1964 1.1 christos
1965 1.1 christos /* This is for microMIPS branches. */
1966 1.1 christos HOWTO (R_MICROMIPS_PC7_S1, /* type */
1967 1.1 christos 1, /* rightshift */
1968 1.1 christos 1, /* size (0 = byte, 1 = short, 2 = long) */
1969 1.1 christos 7, /* bitsize */
1970 1.1 christos TRUE, /* pc_relative */
1971 1.1 christos 0, /* bitpos */
1972 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1973 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1974 1.1 christos "R_MICROMIPS_PC7_S1", /* name */
1975 1.1 christos TRUE, /* partial_inplace */
1976 1.1 christos 0x0000007f, /* src_mask */
1977 1.1 christos 0x0000007f, /* dst_mask */
1978 1.1 christos TRUE), /* pcrel_offset */
1979 1.1 christos
1980 1.1 christos HOWTO (R_MICROMIPS_PC10_S1, /* type */
1981 1.1 christos 1, /* rightshift */
1982 1.1 christos 1, /* size (0 = byte, 1 = short, 2 = long) */
1983 1.1 christos 10, /* bitsize */
1984 1.1 christos TRUE, /* pc_relative */
1985 1.1 christos 0, /* bitpos */
1986 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1987 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1988 1.1 christos "R_MICROMIPS_PC10_S1", /* name */
1989 1.1 christos TRUE, /* partial_inplace */
1990 1.1 christos 0x000003ff, /* src_mask */
1991 1.1 christos 0x000003ff, /* dst_mask */
1992 1.1 christos TRUE), /* pcrel_offset */
1993 1.1 christos
1994 1.1 christos HOWTO (R_MICROMIPS_PC16_S1, /* type */
1995 1.1 christos 1, /* rightshift */
1996 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1997 1.1 christos 16, /* bitsize */
1998 1.1 christos TRUE, /* pc_relative */
1999 1.1 christos 0, /* bitpos */
2000 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2001 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2002 1.1 christos "R_MICROMIPS_PC16_S1", /* name */
2003 1.1 christos TRUE, /* partial_inplace */
2004 1.1 christos 0x0000ffff, /* src_mask */
2005 1.1 christos 0x0000ffff, /* dst_mask */
2006 1.1 christos TRUE), /* pcrel_offset */
2007 1.1 christos
2008 1.1 christos /* 16 bit call through global offset table. */
2009 1.1 christos HOWTO (R_MICROMIPS_CALL16, /* type */
2010 1.1 christos 0, /* rightshift */
2011 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2012 1.1 christos 16, /* bitsize */
2013 1.1 christos FALSE, /* pc_relative */
2014 1.1 christos 0, /* bitpos */
2015 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2016 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2017 1.1 christos "R_MICROMIPS_CALL16", /* name */
2018 1.1 christos TRUE, /* partial_inplace */
2019 1.1 christos 0x0000ffff, /* src_mask */
2020 1.1 christos 0x0000ffff, /* dst_mask */
2021 1.1 christos FALSE), /* pcrel_offset */
2022 1.1 christos
2023 1.1 christos EMPTY_HOWTO (143),
2024 1.1 christos EMPTY_HOWTO (144),
2025 1.1 christos
2026 1.1 christos /* Displacement in the global offset table. */
2027 1.1 christos HOWTO (R_MICROMIPS_GOT_DISP, /* type */
2028 1.1 christos 0, /* rightshift */
2029 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2030 1.1 christos 16, /* bitsize */
2031 1.1 christos FALSE, /* pc_relative */
2032 1.1 christos 0, /* bitpos */
2033 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2034 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2035 1.1 christos "R_MICROMIPS_GOT_DISP",/* name */
2036 1.1 christos TRUE, /* partial_inplace */
2037 1.1 christos 0x0000ffff, /* src_mask */
2038 1.1 christos 0x0000ffff, /* dst_mask */
2039 1.1 christos FALSE), /* pcrel_offset */
2040 1.1 christos
2041 1.1 christos /* Displacement to page pointer in the global offset table. */
2042 1.1 christos HOWTO (R_MICROMIPS_GOT_PAGE, /* type */
2043 1.1 christos 0, /* rightshift */
2044 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2045 1.1 christos 16, /* bitsize */
2046 1.1 christos FALSE, /* pc_relative */
2047 1.1 christos 0, /* bitpos */
2048 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2049 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2050 1.1 christos "R_MICROMIPS_GOT_PAGE",/* name */
2051 1.1 christos TRUE, /* partial_inplace */
2052 1.1 christos 0x0000ffff, /* src_mask */
2053 1.1 christos 0x0000ffff, /* dst_mask */
2054 1.1 christos FALSE), /* pcrel_offset */
2055 1.1 christos
2056 1.1 christos /* Offset from page pointer in the global offset table. */
2057 1.1 christos HOWTO (R_MICROMIPS_GOT_OFST, /* type */
2058 1.1 christos 0, /* rightshift */
2059 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2060 1.1 christos 16, /* bitsize */
2061 1.1 christos FALSE, /* pc_relative */
2062 1.1 christos 0, /* bitpos */
2063 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2064 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2065 1.1 christos "R_MICROMIPS_GOT_OFST",/* name */
2066 1.1 christos TRUE, /* partial_inplace */
2067 1.1 christos 0x0000ffff, /* src_mask */
2068 1.1 christos 0x0000ffff, /* dst_mask */
2069 1.1 christos FALSE), /* pcrel_offset */
2070 1.1 christos
2071 1.1 christos /* High 16 bits of displacement in global offset table. */
2072 1.1 christos HOWTO (R_MICROMIPS_GOT_HI16, /* type */
2073 1.1 christos 0, /* rightshift */
2074 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2075 1.1 christos 16, /* bitsize */
2076 1.1 christos FALSE, /* pc_relative */
2077 1.1 christos 0, /* bitpos */
2078 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2079 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2080 1.1 christos "R_MICROMIPS_GOT_HI16",/* name */
2081 1.1 christos TRUE, /* partial_inplace */
2082 1.1 christos 0x0000ffff, /* src_mask */
2083 1.1 christos 0x0000ffff, /* dst_mask */
2084 1.1 christos FALSE), /* pcrel_offset */
2085 1.1 christos
2086 1.1 christos /* Low 16 bits of displacement in global offset table. */
2087 1.1 christos HOWTO (R_MICROMIPS_GOT_LO16, /* type */
2088 1.1 christos 0, /* rightshift */
2089 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2090 1.1 christos 16, /* bitsize */
2091 1.1 christos FALSE, /* pc_relative */
2092 1.1 christos 0, /* bitpos */
2093 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2094 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2095 1.1 christos "R_MICROMIPS_GOT_LO16",/* name */
2096 1.1 christos TRUE, /* partial_inplace */
2097 1.1 christos 0x0000ffff, /* src_mask */
2098 1.1 christos 0x0000ffff, /* dst_mask */
2099 1.1 christos FALSE), /* pcrel_offset */
2100 1.1 christos
2101 1.1 christos /* 64 bit subtraction. Used in the N32 ABI. */
2102 1.1 christos HOWTO (R_MICROMIPS_SUB, /* type */
2103 1.1 christos 0, /* rightshift */
2104 1.1 christos 4, /* size (0 = byte, 1 = short, 2 = long) */
2105 1.1 christos 64, /* bitsize */
2106 1.1 christos FALSE, /* pc_relative */
2107 1.1 christos 0, /* bitpos */
2108 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2109 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2110 1.1 christos "R_MICROMIPS_SUB", /* name */
2111 1.1 christos TRUE, /* partial_inplace */
2112 1.1 christos MINUS_ONE, /* src_mask */
2113 1.1 christos MINUS_ONE, /* dst_mask */
2114 1.1 christos FALSE), /* pcrel_offset */
2115 1.1 christos
2116 1.1 christos /* We don't support these for REL relocations, because it means building
2117 1.1 christos the addend from a R_MICROMIPS_HIGHEST/R_MICROMIPS_HIGHER/
2118 1.1 christos R_MICROMIPS_HI16/R_MICROMIPS_LO16 sequence with varying ordering,
2119 1.1 christos using fallable heuristics. */
2120 1.1 christos EMPTY_HOWTO (R_MICROMIPS_HIGHER),
2121 1.1 christos EMPTY_HOWTO (R_MICROMIPS_HIGHEST),
2122 1.1 christos
2123 1.1 christos /* High 16 bits of displacement in global offset table. */
2124 1.1 christos HOWTO (R_MICROMIPS_CALL_HI16, /* type */
2125 1.1 christos 0, /* rightshift */
2126 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2127 1.1 christos 16, /* bitsize */
2128 1.1 christos FALSE, /* pc_relative */
2129 1.1 christos 0, /* bitpos */
2130 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2131 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2132 1.1 christos "R_MICROMIPS_CALL_HI16",/* name */
2133 1.1 christos TRUE, /* partial_inplace */
2134 1.1 christos 0x0000ffff, /* src_mask */
2135 1.1 christos 0x0000ffff, /* dst_mask */
2136 1.1 christos FALSE), /* pcrel_offset */
2137 1.1 christos
2138 1.1 christos /* Low 16 bits of displacement in global offset table. */
2139 1.1 christos HOWTO (R_MICROMIPS_CALL_LO16, /* type */
2140 1.1 christos 0, /* rightshift */
2141 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2142 1.1 christos 16, /* bitsize */
2143 1.1 christos FALSE, /* pc_relative */
2144 1.1 christos 0, /* bitpos */
2145 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2146 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2147 1.1 christos "R_MICROMIPS_CALL_LO16",/* name */
2148 1.1 christos TRUE, /* partial_inplace */
2149 1.1 christos 0x0000ffff, /* src_mask */
2150 1.1 christos 0x0000ffff, /* dst_mask */
2151 1.1 christos FALSE), /* pcrel_offset */
2152 1.1 christos
2153 1.1 christos /* Section displacement. */
2154 1.1 christos HOWTO (R_MICROMIPS_SCN_DISP, /* type */
2155 1.1 christos 0, /* rightshift */
2156 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2157 1.1 christos 32, /* bitsize */
2158 1.1 christos FALSE, /* pc_relative */
2159 1.1 christos 0, /* bitpos */
2160 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2161 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2162 1.1 christos "R_MICROMIPS_SCN_DISP", /* name */
2163 1.1 christos TRUE, /* partial_inplace */
2164 1.1 christos 0xffffffff, /* src_mask */
2165 1.1 christos 0xffffffff, /* dst_mask */
2166 1.1 christos FALSE), /* pcrel_offset */
2167 1.1 christos
2168 1.1 christos /* Protected jump conversion. This is an optimization hint. No
2169 1.1 christos relocation is required for correctness. */
2170 1.1 christos HOWTO (R_MICROMIPS_JALR, /* type */
2171 1.1 christos 0, /* rightshift */
2172 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2173 1.1 christos 32, /* bitsize */
2174 1.1 christos FALSE, /* pc_relative */
2175 1.1 christos 0, /* bitpos */
2176 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2177 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2178 1.1 christos "R_MICROMIPS_JALR", /* name */
2179 1.1 christos FALSE, /* partial_inplace */
2180 1.1 christos 0, /* src_mask */
2181 1.1 christos 0x00000000, /* dst_mask */
2182 1.1 christos FALSE), /* pcrel_offset */
2183 1.1 christos };
2184 1.1 christos
2185 1.1 christos static reloc_howto_type elf_micromips_howto_table_rela[] =
2186 1.1 christos {
2187 1.1 christos EMPTY_HOWTO (130),
2188 1.1 christos EMPTY_HOWTO (131),
2189 1.1 christos EMPTY_HOWTO (132),
2190 1.1 christos
2191 1.1 christos /* 26 bit jump address. */
2192 1.1 christos HOWTO (R_MICROMIPS_26_S1, /* type */
2193 1.1 christos 1, /* rightshift */
2194 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2195 1.1 christos 26, /* bitsize */
2196 1.1 christos FALSE, /* pc_relative */
2197 1.1 christos 0, /* bitpos */
2198 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2199 1.1 christos /* This needs complex overflow
2200 1.1 christos detection, because the upper four
2201 1.1 christos bits must match the PC. */
2202 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2203 1.1 christos "R_MICROMIPS_26_S1", /* name */
2204 1.1 christos FALSE, /* partial_inplace */
2205 1.1 christos 0, /* src_mask */
2206 1.1 christos 0x3ffffff, /* dst_mask */
2207 1.1 christos FALSE), /* pcrel_offset */
2208 1.1 christos
2209 1.1 christos /* High 16 bits of symbol value. */
2210 1.1 christos HOWTO (R_MICROMIPS_HI16, /* type */
2211 1.1 christos 16, /* rightshift */
2212 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2213 1.1 christos 16, /* bitsize */
2214 1.1 christos FALSE, /* pc_relative */
2215 1.1 christos 0, /* bitpos */
2216 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2217 1.1 christos _bfd_mips_elf_hi16_reloc, /* special_function */
2218 1.1 christos "R_MICROMIPS_HI16", /* name */
2219 1.1 christos FALSE, /* partial_inplace */
2220 1.1 christos 0, /* src_mask */
2221 1.1 christos 0x0000ffff, /* dst_mask */
2222 1.1 christos FALSE), /* pcrel_offset */
2223 1.1 christos
2224 1.1 christos /* Low 16 bits of symbol value. */
2225 1.1 christos HOWTO (R_MICROMIPS_LO16, /* type */
2226 1.1 christos 0, /* rightshift */
2227 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2228 1.1 christos 16, /* bitsize */
2229 1.1 christos FALSE, /* pc_relative */
2230 1.1 christos 0, /* bitpos */
2231 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2232 1.1 christos _bfd_mips_elf_lo16_reloc, /* special_function */
2233 1.1 christos "R_MICROMIPS_LO16", /* name */
2234 1.1 christos FALSE, /* partial_inplace */
2235 1.1 christos 0, /* src_mask */
2236 1.1 christos 0x0000ffff, /* dst_mask */
2237 1.1 christos FALSE), /* pcrel_offset */
2238 1.1 christos
2239 1.1 christos /* GP relative reference. */
2240 1.1 christos HOWTO (R_MICROMIPS_GPREL16, /* type */
2241 1.1 christos 0, /* rightshift */
2242 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2243 1.1 christos 16, /* bitsize */
2244 1.1 christos FALSE, /* pc_relative */
2245 1.1 christos 0, /* bitpos */
2246 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2247 1.1 christos _bfd_mips_elf32_gprel16_reloc, /* special_function */
2248 1.1 christos "R_MICROMIPS_GPREL16", /* name */
2249 1.1 christos FALSE, /* partial_inplace */
2250 1.1 christos 0, /* src_mask */
2251 1.1 christos 0x0000ffff, /* dst_mask */
2252 1.1 christos FALSE), /* pcrel_offset */
2253 1.1 christos
2254 1.1 christos /* Reference to literal section. */
2255 1.1 christos HOWTO (R_MICROMIPS_LITERAL, /* type */
2256 1.1 christos 0, /* rightshift */
2257 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2258 1.1 christos 16, /* bitsize */
2259 1.1 christos FALSE, /* pc_relative */
2260 1.1 christos 0, /* bitpos */
2261 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2262 1.1 christos _bfd_mips_elf32_gprel16_reloc, /* special_function */
2263 1.1 christos "R_MICROMIPS_LITERAL", /* name */
2264 1.1 christos FALSE, /* partial_inplace */
2265 1.1 christos 0, /* src_mask */
2266 1.1 christos 0x0000ffff, /* dst_mask */
2267 1.1 christos FALSE), /* pcrel_offset */
2268 1.1 christos
2269 1.1 christos /* Reference to global offset table. */
2270 1.1 christos HOWTO (R_MICROMIPS_GOT16, /* type */
2271 1.1 christos 0, /* rightshift */
2272 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2273 1.1 christos 16, /* bitsize */
2274 1.1 christos FALSE, /* pc_relative */
2275 1.1 christos 0, /* bitpos */
2276 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2277 1.1 christos _bfd_mips_elf_got16_reloc, /* special_function */
2278 1.1 christos "R_MICROMIPS_GOT16", /* name */
2279 1.1 christos FALSE, /* partial_inplace */
2280 1.1 christos 0, /* src_mask */
2281 1.1 christos 0x0000ffff, /* dst_mask */
2282 1.1 christos FALSE), /* pcrel_offset */
2283 1.1 christos
2284 1.1 christos /* This is for microMIPS branches. */
2285 1.1 christos HOWTO (R_MICROMIPS_PC7_S1, /* type */
2286 1.1 christos 1, /* rightshift */
2287 1.1 christos 1, /* size (0 = byte, 1 = short, 2 = long) */
2288 1.1 christos 7, /* bitsize */
2289 1.1 christos TRUE, /* pc_relative */
2290 1.1 christos 0, /* bitpos */
2291 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2292 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2293 1.1 christos "R_MICROMIPS_PC7_S1", /* name */
2294 1.1 christos FALSE, /* partial_inplace */
2295 1.1 christos 0, /* src_mask */
2296 1.1 christos 0x0000007f, /* dst_mask */
2297 1.1 christos TRUE), /* pcrel_offset */
2298 1.1 christos
2299 1.1 christos HOWTO (R_MICROMIPS_PC10_S1, /* type */
2300 1.1 christos 1, /* rightshift */
2301 1.1 christos 1, /* size (0 = byte, 1 = short, 2 = long) */
2302 1.1 christos 10, /* bitsize */
2303 1.1 christos TRUE, /* pc_relative */
2304 1.1 christos 0, /* bitpos */
2305 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2306 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2307 1.1 christos "R_MICROMIPS_PC10_S1", /* name */
2308 1.1 christos FALSE, /* partial_inplace */
2309 1.1 christos 0, /* src_mask */
2310 1.1 christos 0x000003ff, /* dst_mask */
2311 1.1 christos TRUE), /* pcrel_offset */
2312 1.1 christos
2313 1.1 christos HOWTO (R_MICROMIPS_PC16_S1, /* type */
2314 1.1 christos 1, /* rightshift */
2315 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2316 1.1 christos 16, /* bitsize */
2317 1.1 christos TRUE, /* pc_relative */
2318 1.1 christos 0, /* bitpos */
2319 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2320 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2321 1.1 christos "R_MICROMIPS_PC16_S1", /* name */
2322 1.1 christos FALSE, /* partial_inplace */
2323 1.1 christos 0, /* src_mask */
2324 1.1 christos 0x0000ffff, /* dst_mask */
2325 1.1 christos TRUE), /* pcrel_offset */
2326 1.1 christos
2327 1.1 christos /* 16 bit call through global offset table. */
2328 1.1 christos HOWTO (R_MICROMIPS_CALL16, /* type */
2329 1.1 christos 0, /* rightshift */
2330 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2331 1.1 christos 16, /* bitsize */
2332 1.1 christos FALSE, /* pc_relative */
2333 1.1 christos 0, /* bitpos */
2334 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2335 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2336 1.1 christos "R_MICROMIPS_CALL16", /* name */
2337 1.1 christos FALSE, /* partial_inplace */
2338 1.1 christos 0, /* src_mask */
2339 1.1 christos 0x0000ffff, /* dst_mask */
2340 1.1 christos FALSE), /* pcrel_offset */
2341 1.1 christos
2342 1.1 christos EMPTY_HOWTO (143),
2343 1.1 christos EMPTY_HOWTO (144),
2344 1.1 christos
2345 1.1 christos /* Displacement in the global offset table. */
2346 1.1 christos HOWTO (R_MICROMIPS_GOT_DISP, /* type */
2347 1.1 christos 0, /* rightshift */
2348 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2349 1.1 christos 16, /* bitsize */
2350 1.1 christos FALSE, /* pc_relative */
2351 1.1 christos 0, /* bitpos */
2352 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2353 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2354 1.1 christos "R_MICROMIPS_GOT_DISP",/* name */
2355 1.1 christos FALSE, /* partial_inplace */
2356 1.1 christos 0, /* src_mask */
2357 1.1 christos 0x0000ffff, /* dst_mask */
2358 1.1 christos FALSE), /* pcrel_offset */
2359 1.1 christos
2360 1.1 christos /* Displacement to page pointer in the global offset table. */
2361 1.1 christos HOWTO (R_MICROMIPS_GOT_PAGE, /* type */
2362 1.1 christos 0, /* rightshift */
2363 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2364 1.1 christos 16, /* bitsize */
2365 1.1 christos FALSE, /* pc_relative */
2366 1.1 christos 0, /* bitpos */
2367 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2368 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2369 1.1 christos "R_MICROMIPS_GOT_PAGE",/* name */
2370 1.1 christos FALSE, /* partial_inplace */
2371 1.1 christos 0, /* src_mask */
2372 1.1 christos 0x0000ffff, /* dst_mask */
2373 1.1 christos FALSE), /* pcrel_offset */
2374 1.1 christos
2375 1.1 christos /* Offset from page pointer in the global offset table. */
2376 1.1 christos HOWTO (R_MICROMIPS_GOT_OFST, /* type */
2377 1.1 christos 0, /* rightshift */
2378 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2379 1.1 christos 16, /* bitsize */
2380 1.1 christos FALSE, /* pc_relative */
2381 1.1 christos 0, /* bitpos */
2382 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2383 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2384 1.1 christos "R_MICROMIPS_GOT_OFST",/* name */
2385 1.1 christos FALSE, /* partial_inplace */
2386 1.1 christos 0, /* src_mask */
2387 1.1 christos 0x0000ffff, /* dst_mask */
2388 1.1 christos FALSE), /* pcrel_offset */
2389 1.1 christos
2390 1.1 christos /* High 16 bits of displacement in global offset table. */
2391 1.1 christos HOWTO (R_MICROMIPS_GOT_HI16, /* type */
2392 1.1 christos 0, /* rightshift */
2393 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2394 1.1 christos 16, /* bitsize */
2395 1.1 christos FALSE, /* pc_relative */
2396 1.1 christos 0, /* bitpos */
2397 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2398 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2399 1.1 christos "R_MICROMIPS_GOT_HI16",/* name */
2400 1.1 christos FALSE, /* partial_inplace */
2401 1.1 christos 0, /* src_mask */
2402 1.1 christos 0x0000ffff, /* dst_mask */
2403 1.1 christos FALSE), /* pcrel_offset */
2404 1.1 christos
2405 1.1 christos /* Low 16 bits of displacement in global offset table. */
2406 1.1 christos HOWTO (R_MICROMIPS_GOT_LO16, /* type */
2407 1.1 christos 0, /* rightshift */
2408 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2409 1.1 christos 16, /* bitsize */
2410 1.1 christos FALSE, /* pc_relative */
2411 1.1 christos 0, /* bitpos */
2412 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2413 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2414 1.1 christos "R_MICROMIPS_GOT_LO16",/* name */
2415 1.1 christos FALSE, /* partial_inplace */
2416 1.1 christos 0, /* src_mask */
2417 1.1 christos 0x0000ffff, /* dst_mask */
2418 1.1 christos FALSE), /* pcrel_offset */
2419 1.1 christos
2420 1.1 christos /* 64 bit subtraction. Used in the N32 ABI. */
2421 1.1 christos HOWTO (R_MICROMIPS_SUB, /* type */
2422 1.1 christos 0, /* rightshift */
2423 1.1 christos 4, /* size (0 = byte, 1 = short, 2 = long) */
2424 1.1 christos 64, /* bitsize */
2425 1.1 christos FALSE, /* pc_relative */
2426 1.1 christos 0, /* bitpos */
2427 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2428 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2429 1.1 christos "R_MICROMIPS_SUB", /* name */
2430 1.1 christos FALSE, /* partial_inplace */
2431 1.1 christos 0, /* src_mask */
2432 1.1 christos MINUS_ONE, /* dst_mask */
2433 1.1 christos FALSE), /* pcrel_offset */
2434 1.1 christos
2435 1.1 christos /* Get the higher value of a 64 bit addend. */
2436 1.1 christos HOWTO (R_MICROMIPS_HIGHER, /* type */
2437 1.1 christos 0, /* rightshift */
2438 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2439 1.1 christos 16, /* bitsize */
2440 1.1 christos FALSE, /* pc_relative */
2441 1.1 christos 0, /* bitpos */
2442 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2443 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2444 1.1 christos "R_MICROMIPS_HIGHER", /* name */
2445 1.1 christos FALSE, /* partial_inplace */
2446 1.1 christos 0, /* src_mask */
2447 1.1 christos 0x0000ffff, /* dst_mask */
2448 1.1 christos FALSE), /* pcrel_offset */
2449 1.1 christos
2450 1.1 christos /* Get the highest value of a 64 bit addend. */
2451 1.1 christos HOWTO (R_MICROMIPS_HIGHEST, /* type */
2452 1.1 christos 0, /* rightshift */
2453 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2454 1.1 christos 16, /* bitsize */
2455 1.1 christos FALSE, /* pc_relative */
2456 1.1 christos 0, /* bitpos */
2457 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2458 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2459 1.1 christos "R_MICROMIPS_HIGHEST", /* name */
2460 1.1 christos FALSE, /* partial_inplace */
2461 1.1 christos 0, /* src_mask */
2462 1.1 christos 0x0000ffff, /* dst_mask */
2463 1.1 christos FALSE), /* pcrel_offset */
2464 1.1 christos
2465 1.1 christos /* High 16 bits of displacement in global offset table. */
2466 1.1 christos HOWTO (R_MICROMIPS_CALL_HI16, /* type */
2467 1.1 christos 0, /* rightshift */
2468 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2469 1.1 christos 16, /* bitsize */
2470 1.1 christos FALSE, /* pc_relative */
2471 1.1 christos 0, /* bitpos */
2472 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2473 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2474 1.1 christos "R_MICROMIPS_CALL_HI16",/* name */
2475 1.1 christos FALSE, /* partial_inplace */
2476 1.1 christos 0, /* src_mask */
2477 1.1 christos 0x0000ffff, /* dst_mask */
2478 1.1 christos FALSE), /* pcrel_offset */
2479 1.1 christos
2480 1.1 christos /* Low 16 bits of displacement in global offset table. */
2481 1.1 christos HOWTO (R_MICROMIPS_CALL_LO16, /* type */
2482 1.1 christos 0, /* rightshift */
2483 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2484 1.1 christos 16, /* bitsize */
2485 1.1 christos FALSE, /* pc_relative */
2486 1.1 christos 0, /* bitpos */
2487 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2488 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2489 1.1 christos "R_MICROMIPS_CALL_LO16",/* name */
2490 1.1 christos FALSE, /* partial_inplace */
2491 1.1 christos 0, /* src_mask */
2492 1.1 christos 0x0000ffff, /* dst_mask */
2493 1.1 christos FALSE), /* pcrel_offset */
2494 1.1 christos
2495 1.1 christos /* Section displacement. */
2496 1.1 christos HOWTO (R_MICROMIPS_SCN_DISP, /* type */
2497 1.1 christos 0, /* rightshift */
2498 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2499 1.1 christos 32, /* bitsize */
2500 1.1 christos FALSE, /* pc_relative */
2501 1.1 christos 0, /* bitpos */
2502 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2503 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2504 1.1 christos "R_MICROMIPS_SCN_DISP", /* name */
2505 1.1 christos FALSE, /* partial_inplace */
2506 1.1 christos 0, /* src_mask */
2507 1.1 christos 0xffffffff, /* dst_mask */
2508 1.1 christos FALSE), /* pcrel_offset */
2509 1.1 christos
2510 1.1 christos /* Protected jump conversion. This is an optimization hint. No
2511 1.1 christos relocation is required for correctness. */
2512 1.1 christos HOWTO (R_MICROMIPS_JALR, /* type */
2513 1.1 christos 0, /* rightshift */
2514 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2515 1.1 christos 32, /* bitsize */
2516 1.1 christos FALSE, /* pc_relative */
2517 1.1 christos 0, /* bitpos */
2518 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2519 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2520 1.1 christos "R_MICROMIPS_JALR", /* name */
2521 1.1 christos FALSE, /* partial_inplace */
2522 1.1 christos 0, /* src_mask */
2523 1.1 christos 0x00000000, /* dst_mask */
2524 1.1 christos FALSE), /* pcrel_offset */
2525 1.1 christos };
2526 1.1 christos
2527 1.1 christos /* GNU extension to record C++ vtable hierarchy */
2528 1.1 christos static reloc_howto_type elf_mips_gnu_vtinherit_howto =
2529 1.1 christos HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
2530 1.1 christos 0, /* rightshift */
2531 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2532 1.1 christos 0, /* bitsize */
2533 1.1 christos FALSE, /* pc_relative */
2534 1.1 christos 0, /* bitpos */
2535 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2536 1.1 christos NULL, /* special_function */
2537 1.1 christos "R_MIPS_GNU_VTINHERIT", /* name */
2538 1.1 christos FALSE, /* partial_inplace */
2539 1.1 christos 0, /* src_mask */
2540 1.1 christos 0, /* dst_mask */
2541 1.1 christos FALSE); /* pcrel_offset */
2542 1.1 christos
2543 1.1 christos /* GNU extension to record C++ vtable member usage */
2544 1.1 christos static reloc_howto_type elf_mips_gnu_vtentry_howto =
2545 1.1 christos HOWTO (R_MIPS_GNU_VTENTRY, /* type */
2546 1.1 christos 0, /* rightshift */
2547 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2548 1.1 christos 0, /* bitsize */
2549 1.1 christos FALSE, /* pc_relative */
2550 1.1 christos 0, /* bitpos */
2551 1.1 christos complain_overflow_dont, /* complain_on_overflow */
2552 1.1 christos _bfd_elf_rel_vtable_reloc_fn, /* special_function */
2553 1.1 christos "R_MIPS_GNU_VTENTRY", /* name */
2554 1.1 christos FALSE, /* partial_inplace */
2555 1.1 christos 0, /* src_mask */
2556 1.1 christos 0, /* dst_mask */
2557 1.1 christos FALSE); /* pcrel_offset */
2558 1.1 christos
2559 1.1 christos /* 16 bit offset for pc-relative branches. */
2561 1.1 christos static reloc_howto_type elf_mips_gnu_rel16_s2 =
2562 1.1 christos HOWTO (R_MIPS_GNU_REL16_S2, /* type */
2563 1.1 christos 2, /* rightshift */
2564 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2565 1.1 christos 16, /* bitsize */
2566 1.1 christos TRUE, /* pc_relative */
2567 1.1 christos 0, /* bitpos */
2568 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2569 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2570 1.1 christos "R_MIPS_GNU_REL16_S2", /* name */
2571 1.1 christos TRUE, /* partial_inplace */
2572 1.1 christos 0x0000ffff, /* src_mask */
2573 1.1 christos 0x0000ffff, /* dst_mask */
2574 1.1 christos TRUE); /* pcrel_offset */
2575 1.1 christos
2576 1.1 christos /* 16 bit offset for pc-relative branches. */
2577 1.1 christos static reloc_howto_type elf_mips_gnu_rela16_s2 =
2578 1.1 christos HOWTO (R_MIPS_GNU_REL16_S2, /* type */
2579 1.1 christos 2, /* rightshift */
2580 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2581 1.1 christos 16, /* bitsize */
2582 1.1 christos TRUE, /* pc_relative */
2583 1.1 christos 0, /* bitpos */
2584 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2585 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2586 1.1 christos "R_MIPS_GNU_REL16_S2", /* name */
2587 1.1 christos FALSE, /* partial_inplace */
2588 1.1 christos 0, /* src_mask */
2589 1.1 christos 0x0000ffff, /* dst_mask */
2590 1.1 christos TRUE); /* pcrel_offset */
2591 1.1 christos
2592 1.1 christos /* 32 bit pc-relative. Used for compact EH tables. */
2593 1.1 christos static reloc_howto_type elf_mips_gnu_pcrel32 =
2594 1.1 christos HOWTO (R_MIPS_PC32, /* type */
2595 1.1 christos 0, /* rightshift */
2596 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2597 1.1 christos 32, /* bitsize */
2598 1.1 christos TRUE, /* pc_relative */
2599 1.1 christos 0, /* bitpos */
2600 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2601 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2602 1.1 christos "R_MIPS_PC32", /* name */
2603 1.1 christos TRUE, /* partial_inplace */
2604 1.1 christos 0xffffffff, /* src_mask */
2605 1.1 christos 0xffffffff, /* dst_mask */
2606 1.1 christos TRUE); /* pcrel_offset */
2607 1.1 christos
2608 1.1 christos
2609 1.1 christos /* Originally a VxWorks extension, but now used for other systems too. */
2611 1.1 christos static reloc_howto_type elf_mips_copy_howto =
2612 1.1 christos HOWTO (R_MIPS_COPY, /* type */
2613 1.1 christos 0, /* rightshift */
2614 1.1 christos 0, /* this one is variable size */
2615 1.1 christos 0, /* bitsize */
2616 1.1 christos FALSE, /* pc_relative */
2617 1.1 christos 0, /* bitpos */
2618 1.1 christos complain_overflow_bitfield, /* complain_on_overflow */
2619 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2620 1.1 christos "R_MIPS_COPY", /* name */
2621 1.1 christos FALSE, /* partial_inplace */
2622 1.1 christos 0x0, /* src_mask */
2623 1.1 christos 0x0, /* dst_mask */
2624 1.1 christos FALSE); /* pcrel_offset */
2625 1.1 christos
2626 1.1 christos /* Originally a VxWorks extension, but now used for other systems too. */
2627 1.1 christos static reloc_howto_type elf_mips_jump_slot_howto =
2628 1.1 christos HOWTO (R_MIPS_JUMP_SLOT, /* type */
2629 1.1 christos 0, /* rightshift */
2630 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2631 1.1 christos 32, /* bitsize */
2632 1.1 christos FALSE, /* pc_relative */
2633 1.1 christos 0, /* bitpos */
2634 1.1 christos complain_overflow_bitfield, /* complain_on_overflow */
2635 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2636 1.1 christos "R_MIPS_JUMP_SLOT", /* name */
2637 1.1 christos FALSE, /* partial_inplace */
2638 1.1 christos 0x0, /* src_mask */
2639 1.1 christos 0x0, /* dst_mask */
2640 1.1 christos FALSE); /* pcrel_offset */
2641 1.1 christos
2642 1.1 christos /* Used in EH tables. */
2643 1.1 christos static reloc_howto_type elf_mips_eh_howto =
2644 1.1 christos HOWTO (R_MIPS_EH, /* type */
2645 1.1 christos 0, /* rightshift */
2646 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
2647 1.1 christos 32, /* bitsize */
2648 1.1 christos FALSE, /* pc_relative */
2649 1.1 christos 0, /* bitpos */
2650 1.1 christos complain_overflow_signed, /* complain_on_overflow */
2651 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
2652 1.1 christos "R_MIPS_EH", /* name */
2653 1.1 christos TRUE, /* partial_inplace */
2654 1.1 christos 0xffffffff, /* src_mask */
2655 1.1 christos 0xffffffff, /* dst_mask */
2656 1.1 christos FALSE); /* pcrel_offset */
2657 1.1 christos
2658 1.1 christos
2659 1.1 christos /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
2661 1.1 christos dangerous relocation. */
2662 1.1 christos
2663 1.1 christos static bfd_boolean
2664 1.1 christos mips_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
2665 1.1 christos {
2666 1.1 christos unsigned int count;
2667 1.1 christos asymbol **sym;
2668 1.1 christos unsigned int i;
2669 1.1 christos
2670 1.1 christos /* If we've already figured out what GP will be, just return it. */
2671 1.1 christos *pgp = _bfd_get_gp_value (output_bfd);
2672 1.1 christos if (*pgp)
2673 1.1 christos return TRUE;
2674 1.1 christos
2675 1.1 christos count = bfd_get_symcount (output_bfd);
2676 1.1 christos sym = bfd_get_outsymbols (output_bfd);
2677 1.1 christos
2678 1.1 christos /* The linker script will have created a symbol named `_gp' with the
2679 1.1 christos appropriate value. */
2680 1.1 christos if (sym == NULL)
2681 1.1 christos i = count;
2682 1.1 christos else
2683 1.1 christos {
2684 1.1 christos for (i = 0; i < count; i++, sym++)
2685 1.1 christos {
2686 1.1 christos register const char *name;
2687 1.1 christos
2688 1.1 christos name = bfd_asymbol_name (*sym);
2689 1.1 christos if (*name == '_' && strcmp (name, "_gp") == 0)
2690 1.1 christos {
2691 1.1 christos *pgp = bfd_asymbol_value (*sym);
2692 1.1 christos _bfd_set_gp_value (output_bfd, *pgp);
2693 1.1 christos break;
2694 1.1 christos }
2695 1.1 christos }
2696 1.1 christos }
2697 1.1 christos
2698 1.1 christos if (i >= count)
2699 1.1 christos {
2700 1.1 christos /* Only get the error once. */
2701 1.1 christos *pgp = 4;
2702 1.1 christos _bfd_set_gp_value (output_bfd, *pgp);
2703 1.1 christos return FALSE;
2704 1.1 christos }
2705 1.1 christos
2706 1.1 christos return TRUE;
2707 1.1 christos }
2708 1.1 christos
2709 1.1 christos /* We have to figure out the gp value, so that we can adjust the
2710 1.1 christos symbol value correctly. We look up the symbol _gp in the output
2711 1.1 christos BFD. If we can't find it, we're stuck. We cache it in the ELF
2712 1.1 christos target data. We don't need to adjust the symbol value for an
2713 1.1 christos external symbol if we are producing relocatable output. */
2714 1.1 christos
2715 1.1 christos static bfd_reloc_status_type
2716 1.1 christos mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
2717 1.1 christos char **error_message, bfd_vma *pgp)
2718 1.1 christos {
2719 1.1 christos if (bfd_is_und_section (symbol->section)
2720 1.1 christos && ! relocatable)
2721 1.1 christos {
2722 1.1 christos *pgp = 0;
2723 1.1 christos return bfd_reloc_undefined;
2724 1.1 christos }
2725 1.1 christos
2726 1.1 christos *pgp = _bfd_get_gp_value (output_bfd);
2727 1.1 christos if (*pgp == 0
2728 1.1 christos && (! relocatable
2729 1.1 christos || (symbol->flags & BSF_SECTION_SYM) != 0))
2730 1.1 christos {
2731 1.1 christos if (relocatable)
2732 1.1 christos {
2733 1.1 christos /* Make up a value. */
2734 1.1 christos *pgp = symbol->section->output_section->vma /*+ 0x4000*/;
2735 1.1 christos _bfd_set_gp_value (output_bfd, *pgp);
2736 1.1 christos }
2737 1.1 christos else if (!mips_elf_assign_gp (output_bfd, pgp))
2738 1.1 christos {
2739 1.1 christos *error_message =
2740 1.1 christos (char *) _("GP relative relocation when _gp not defined");
2741 1.1 christos return bfd_reloc_dangerous;
2742 1.1 christos }
2743 1.1 christos }
2744 1.1 christos
2745 1.1 christos return bfd_reloc_ok;
2746 1.1 christos }
2747 1.1 christos
2748 1.1 christos /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
2749 1.1 christos become the offset from the gp register. */
2750 1.1 christos
2751 1.1 christos static bfd_reloc_status_type
2752 1.1 christos mips_elf_gprel16_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
2753 1.1 christos asymbol *symbol, void *data ATTRIBUTE_UNUSED,
2754 1.1 christos asection *input_section, bfd *output_bfd,
2755 1.1 christos char **error_message ATTRIBUTE_UNUSED)
2756 1.1 christos {
2757 1.1 christos bfd_boolean relocatable;
2758 1.1 christos bfd_reloc_status_type ret;
2759 1.1 christos bfd_vma gp;
2760 1.1 christos
2761 1.1 christos if (output_bfd != NULL)
2762 1.1 christos relocatable = TRUE;
2763 1.1 christos else
2764 1.1 christos {
2765 1.1 christos relocatable = FALSE;
2766 1.1 christos output_bfd = symbol->section->output_section->owner;
2767 1.1 christos }
2768 1.1 christos
2769 1.1 christos ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
2770 1.1 christos &gp);
2771 1.1 christos if (ret != bfd_reloc_ok)
2772 1.1 christos return ret;
2773 1.1 christos
2774 1.1 christos return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
2775 1.1 christos input_section, relocatable,
2776 1.1 christos data, gp);
2777 1.1 christos }
2778 1.1 christos
2779 1.1 christos /* Do a R_MIPS_LITERAL relocation. */
2780 1.1 christos
2781 1.1 christos static bfd_reloc_status_type
2782 1.1 christos mips_elf_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
2783 1.1 christos void *data, asection *input_section, bfd *output_bfd,
2784 1.1 christos char **error_message)
2785 1.1 christos {
2786 1.1 christos bfd_boolean relocatable;
2787 1.1 christos bfd_reloc_status_type ret;
2788 1.1 christos bfd_vma gp;
2789 1.1 christos
2790 1.1 christos /* R_MIPS_LITERAL relocations are defined for local symbols only. */
2791 1.1 christos if (output_bfd != NULL
2792 1.1 christos && (symbol->flags & BSF_SECTION_SYM) == 0
2793 1.1 christos && (symbol->flags & BSF_LOCAL) != 0)
2794 1.1 christos {
2795 1.1 christos *error_message = (char *)
2796 1.1 christos _("literal relocation occurs for an external symbol");
2797 1.1 christos return bfd_reloc_outofrange;
2798 1.1 christos }
2799 1.1 christos
2800 1.1 christos /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */
2801 1.1 christos if (output_bfd != NULL)
2802 1.1 christos relocatable = TRUE;
2803 1.1 christos else
2804 1.1 christos {
2805 1.1 christos relocatable = FALSE;
2806 1.1 christos output_bfd = symbol->section->output_section->owner;
2807 1.1 christos }
2808 1.1 christos
2809 1.1 christos ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
2810 1.1 christos &gp);
2811 1.1 christos if (ret != bfd_reloc_ok)
2812 1.1 christos return ret;
2813 1.1 christos
2814 1.1 christos return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
2815 1.1 christos input_section, relocatable,
2816 1.1 christos data, gp);
2817 1.1 christos }
2818 1.1 christos
2819 1.1 christos /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
2820 1.1 christos become the offset from the gp register. */
2821 1.1 christos
2822 1.1 christos static bfd_reloc_status_type
2823 1.1 christos mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
2824 1.1 christos void *data, asection *input_section, bfd *output_bfd,
2825 1.1 christos char **error_message)
2826 1.1 christos {
2827 1.1 christos bfd_boolean relocatable;
2828 1.1 christos bfd_reloc_status_type ret;
2829 1.1 christos bfd_vma gp;
2830 1.1 christos
2831 1.1 christos /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
2832 1.1 christos if (output_bfd != NULL
2833 1.1 christos && (symbol->flags & BSF_SECTION_SYM) == 0
2834 1.1 christos && (symbol->flags & BSF_LOCAL) != 0)
2835 1.1 christos {
2836 1.1 christos *error_message = (char *)
2837 1.1 christos _("32bits gp relative relocation occurs for an external symbol");
2838 1.1 christos return bfd_reloc_outofrange;
2839 1.1 christos }
2840 1.1 christos
2841 1.1 christos if (output_bfd != NULL)
2842 1.1 christos {
2843 1.1 christos relocatable = TRUE;
2844 1.1 christos gp = _bfd_get_gp_value (output_bfd);
2845 1.1 christos }
2846 1.1 christos else
2847 1.1 christos {
2848 1.1 christos relocatable = FALSE;
2849 1.1 christos output_bfd = symbol->section->output_section->owner;
2850 1.1 christos
2851 1.1 christos ret = mips_elf_final_gp (output_bfd, symbol, relocatable,
2852 1.1 christos error_message, &gp);
2853 1.1 christos if (ret != bfd_reloc_ok)
2854 1.1 christos return ret;
2855 1.1 christos }
2856 1.1 christos
2857 1.1 christos return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
2858 1.1 christos relocatable, data, gp);
2859 1.1 christos }
2860 1.1 christos
2861 1.1 christos static bfd_reloc_status_type
2862 1.1 christos gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
2863 1.1 christos asection *input_section, bfd_boolean relocatable,
2864 1.1 christos void *data, bfd_vma gp)
2865 1.1 christos {
2866 1.1 christos bfd_vma relocation;
2867 1.1 christos unsigned long val;
2868 1.1 christos
2869 1.1 christos if (bfd_is_com_section (symbol->section))
2870 1.1 christos relocation = 0;
2871 1.1 christos else
2872 1.1 christos relocation = symbol->value;
2873 1.1 christos
2874 1.1 christos relocation += symbol->section->output_section->vma;
2875 1.1 christos relocation += symbol->section->output_offset;
2876 1.1 christos
2877 1.1 christos if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
2878 1.1 christos return bfd_reloc_outofrange;
2879 1.1 christos
2880 1.1 christos if (reloc_entry->howto->src_mask == 0)
2881 1.1 christos val = 0;
2882 1.1 christos else
2883 1.1 christos val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
2884 1.1 christos
2885 1.1 christos /* Set val to the offset into the section or symbol. */
2886 1.1 christos val += reloc_entry->addend;
2887 1.1 christos
2888 1.1 christos /* Adjust val for the final section location and GP value. If we
2889 1.1 christos are producing relocatable output, we don't want to do this for
2890 1.1 christos an external symbol. */
2891 1.1 christos if (! relocatable
2892 1.1 christos || (symbol->flags & BSF_SECTION_SYM) != 0)
2893 1.1 christos val += relocation - gp;
2894 1.1 christos
2895 1.1 christos bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
2896 1.1 christos
2897 1.1 christos if (relocatable)
2898 1.1 christos reloc_entry->address += input_section->output_offset;
2899 1.1 christos
2900 1.1 christos return bfd_reloc_ok;
2901 1.1 christos }
2902 1.1 christos
2903 1.1 christos /* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
2904 1.1 christos the rest is at bits 6-10. The bitpos already got right by the howto. */
2905 1.1 christos
2906 1.1 christos static bfd_reloc_status_type
2907 1.1 christos mips_elf_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
2908 1.1 christos void *data, asection *input_section, bfd *output_bfd,
2909 1.1 christos char **error_message)
2910 1.1 christos {
2911 1.1 christos if (reloc_entry->howto->partial_inplace)
2912 1.1 christos {
2913 1.1 christos reloc_entry->addend = ((reloc_entry->addend & 0x00007c0)
2914 1.1 christos | (reloc_entry->addend & 0x00000800) >> 9);
2915 1.1 christos }
2916 1.1 christos
2917 1.1 christos return _bfd_mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
2918 1.1 christos input_section, output_bfd,
2919 1.1 christos error_message);
2920 1.1 christos }
2921 1.1 christos
2922 1.1 christos /* Handle a mips16 GP relative reloc. */
2924 1.1 christos
2925 1.1 christos static bfd_reloc_status_type
2926 1.1 christos mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
2927 1.1 christos void *data, asection *input_section, bfd *output_bfd,
2928 1.1 christos char **error_message)
2929 1.1 christos {
2930 1.1 christos bfd_boolean relocatable;
2931 1.1 christos bfd_reloc_status_type ret;
2932 1.1 christos bfd_byte *location;
2933 1.1 christos bfd_vma gp;
2934 1.1 christos
2935 1.1 christos /* If we're relocating, and this is an external symbol, we don't want
2936 1.1 christos to change anything. */
2937 1.1 christos if (output_bfd != NULL
2938 1.1 christos && (symbol->flags & BSF_SECTION_SYM) == 0
2939 1.1 christos && (symbol->flags & BSF_LOCAL) != 0)
2940 1.1 christos {
2941 1.1 christos reloc_entry->address += input_section->output_offset;
2942 1.1 christos return bfd_reloc_ok;
2943 1.1 christos }
2944 1.1 christos
2945 1.1 christos if (output_bfd != NULL)
2946 1.1 christos relocatable = TRUE;
2947 1.1 christos else
2948 1.1 christos {
2949 1.1 christos relocatable = FALSE;
2950 1.1 christos output_bfd = symbol->section->output_section->owner;
2951 1.1 christos }
2952 1.1 christos
2953 1.1 christos ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
2954 1.1 christos &gp);
2955 1.1 christos if (ret != bfd_reloc_ok)
2956 1.1 christos return ret;
2957 1.1 christos
2958 1.1 christos location = (bfd_byte *) data + reloc_entry->address;
2959 1.1 christos _bfd_mips_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE,
2960 1.1 christos location);
2961 1.1 christos ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
2962 1.1 christos input_section, relocatable,
2963 1.1 christos data, gp);
2964 1.1 christos _bfd_mips_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
2965 1.1 christos location);
2966 1.1 christos
2967 1.1 christos return ret;
2968 1.1 christos }
2969 1.1 christos
2970 1.1 christos /* A mapping from BFD reloc types to MIPS ELF reloc types. */
2972 1.1 christos
2973 1.1 christos struct elf_reloc_map {
2974 1.1 christos bfd_reloc_code_real_type bfd_val;
2975 1.1 christos enum elf_mips_reloc_type elf_val;
2976 1.1 christos };
2977 1.1 christos
2978 1.1 christos static const struct elf_reloc_map mips_reloc_map[] =
2979 1.1 christos {
2980 1.1 christos { BFD_RELOC_NONE, R_MIPS_NONE },
2981 1.1 christos { BFD_RELOC_16, R_MIPS_16 },
2982 1.1 christos { BFD_RELOC_32, R_MIPS_32 },
2983 1.1 christos /* There is no BFD reloc for R_MIPS_REL32. */
2984 1.1 christos { BFD_RELOC_CTOR, R_MIPS_32 },
2985 1.1 christos { BFD_RELOC_64, R_MIPS_64 },
2986 1.1 christos { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
2987 1.1 christos { BFD_RELOC_HI16_S, R_MIPS_HI16 },
2988 1.1 christos { BFD_RELOC_LO16, R_MIPS_LO16 },
2989 1.1 christos { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
2990 1.1 christos { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
2991 1.1 christos { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
2992 1.1 christos { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
2993 1.1 christos { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
2994 1.1 christos { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
2995 1.1 christos { BFD_RELOC_MIPS_SHIFT5, R_MIPS_SHIFT5 },
2996 1.1 christos { BFD_RELOC_MIPS_SHIFT6, R_MIPS_SHIFT6 },
2997 1.1 christos { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
2998 1.1 christos { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
2999 1.1 christos { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
3000 1.1 christos { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
3001 1.1 christos { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
3002 1.1 christos { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
3003 1.1 christos { BFD_RELOC_MIPS_INSERT_A, R_MIPS_INSERT_A },
3004 1.1 christos { BFD_RELOC_MIPS_INSERT_B, R_MIPS_INSERT_B },
3005 1.1 christos { BFD_RELOC_MIPS_DELETE, R_MIPS_DELETE },
3006 1.1 christos { BFD_RELOC_MIPS_HIGHEST, R_MIPS_HIGHEST },
3007 1.1 christos { BFD_RELOC_MIPS_HIGHER, R_MIPS_HIGHER },
3008 1.1 christos { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
3009 1.1 christos { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
3010 1.1 christos { BFD_RELOC_MIPS_SCN_DISP, R_MIPS_SCN_DISP },
3011 1.1 christos { BFD_RELOC_MIPS_REL16, R_MIPS_REL16 },
3012 1.1 christos /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated. */
3013 1.1 christos { BFD_RELOC_MIPS_RELGOT, R_MIPS_RELGOT },
3014 1.1 christos { BFD_RELOC_MIPS_JALR, R_MIPS_JALR },
3015 1.1 christos { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
3016 1.1 christos { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
3017 1.1 christos { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
3018 1.1 christos { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 },
3019 1.1 christos { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD },
3020 1.1 christos { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM },
3021 1.1 christos { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 },
3022 1.1 christos { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 },
3023 1.1 christos { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL },
3024 1.1 christos { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 },
3025 1.1 christos { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 },
3026 1.1 christos { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 },
3027 1.1 christos { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 }
3028 1.1 christos };
3029 1.1 christos
3030 1.1 christos static const struct elf_reloc_map mips16_reloc_map[] =
3031 1.1 christos {
3032 1.1 christos { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
3033 1.1 christos { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
3034 1.1 christos { BFD_RELOC_MIPS16_GOT16, R_MIPS16_GOT16 - R_MIPS16_min },
3035 1.1 christos { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min },
3036 1.1 christos { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
3037 1.1 christos { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
3038 1.1 christos { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min },
3039 1.1 christos { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min },
3040 1.1 christos { BFD_RELOC_MIPS16_TLS_DTPREL_HI16,
3041 1.1 christos R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min },
3042 1.1 christos { BFD_RELOC_MIPS16_TLS_DTPREL_LO16,
3043 1.1 christos R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min },
3044 1.1 christos { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min },
3045 1.1 christos { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min },
3046 1.1 christos { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min }
3047 1.1 christos };
3048 1.1 christos
3049 1.1 christos static const struct elf_reloc_map micromips_reloc_map[] =
3050 1.1 christos {
3051 1.1 christos { BFD_RELOC_MICROMIPS_JMP, R_MICROMIPS_26_S1 - R_MICROMIPS_min },
3052 1.1 christos { BFD_RELOC_MICROMIPS_HI16_S, R_MICROMIPS_HI16 - R_MICROMIPS_min },
3053 1.1 christos { BFD_RELOC_MICROMIPS_LO16, R_MICROMIPS_LO16 - R_MICROMIPS_min },
3054 1.1 christos { BFD_RELOC_MICROMIPS_GPREL16, R_MICROMIPS_GPREL16 - R_MICROMIPS_min },
3055 1.1 christos { BFD_RELOC_MICROMIPS_LITERAL, R_MICROMIPS_LITERAL - R_MICROMIPS_min },
3056 1.1 christos { BFD_RELOC_MICROMIPS_GOT16, R_MICROMIPS_GOT16 - R_MICROMIPS_min },
3057 1.1 christos { BFD_RELOC_MICROMIPS_7_PCREL_S1, R_MICROMIPS_PC7_S1 - R_MICROMIPS_min },
3058 1.1 christos { BFD_RELOC_MICROMIPS_10_PCREL_S1, R_MICROMIPS_PC10_S1 - R_MICROMIPS_min },
3059 1.1 christos { BFD_RELOC_MICROMIPS_16_PCREL_S1, R_MICROMIPS_PC16_S1 - R_MICROMIPS_min },
3060 1.1 christos { BFD_RELOC_MICROMIPS_CALL16, R_MICROMIPS_CALL16 - R_MICROMIPS_min },
3061 1.1 christos { BFD_RELOC_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_DISP - R_MICROMIPS_min },
3062 1.1 christos { BFD_RELOC_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_PAGE - R_MICROMIPS_min },
3063 1.1 christos { BFD_RELOC_MICROMIPS_GOT_OFST, R_MICROMIPS_GOT_OFST - R_MICROMIPS_min },
3064 1.1 christos { BFD_RELOC_MICROMIPS_GOT_HI16, R_MICROMIPS_GOT_HI16 - R_MICROMIPS_min },
3065 1.1 christos { BFD_RELOC_MICROMIPS_GOT_LO16, R_MICROMIPS_GOT_LO16 - R_MICROMIPS_min },
3066 1.1 christos { BFD_RELOC_MICROMIPS_SUB, R_MICROMIPS_SUB - R_MICROMIPS_min },
3067 1.1 christos { BFD_RELOC_MICROMIPS_HIGHER, R_MICROMIPS_HIGHER - R_MICROMIPS_min },
3068 1.1 christos { BFD_RELOC_MICROMIPS_HIGHEST, R_MICROMIPS_HIGHEST - R_MICROMIPS_min },
3069 1.1 christos { BFD_RELOC_MICROMIPS_CALL_HI16, R_MICROMIPS_CALL_HI16 - R_MICROMIPS_min },
3070 1.1 christos { BFD_RELOC_MICROMIPS_CALL_LO16, R_MICROMIPS_CALL_LO16 - R_MICROMIPS_min },
3071 1.1 christos { BFD_RELOC_MICROMIPS_SCN_DISP, R_MICROMIPS_SCN_DISP - R_MICROMIPS_min },
3072 1.1 christos { BFD_RELOC_MICROMIPS_JALR, R_MICROMIPS_JALR - R_MICROMIPS_min },
3073 1.1 christos };
3074 1.1 christos
3075 1.1 christos /* Given a BFD reloc type, return a howto structure. */
3076 1.1 christos
3077 1.1 christos static reloc_howto_type *
3078 1.1 christos bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
3079 1.1 christos bfd_reloc_code_real_type code)
3080 1.1 christos {
3081 1.1 christos unsigned int i;
3082 1.1 christos /* FIXME: We default to RELA here instead of choosing the right
3083 1.1 christos relocation variant. */
3084 1.1 christos reloc_howto_type *howto_table = elf_mips_howto_table_rela;
3085 1.1 christos reloc_howto_type *howto16_table = elf_mips16_howto_table_rela;
3086 1.1 christos reloc_howto_type *howto_micromips_table = elf_micromips_howto_table_rela;
3087 1.1 christos
3088 1.1 christos for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
3089 1.1 christos i++)
3090 1.1 christos {
3091 1.1 christos if (mips_reloc_map[i].bfd_val == code)
3092 1.1 christos return &howto_table[(int) mips_reloc_map[i].elf_val];
3093 1.1 christos }
3094 1.1 christos
3095 1.1 christos for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
3096 1.1 christos i++)
3097 1.1 christos {
3098 1.1 christos if (mips16_reloc_map[i].bfd_val == code)
3099 1.1 christos return &howto16_table[(int) mips16_reloc_map[i].elf_val];
3100 1.1 christos }
3101 1.1 christos
3102 1.1 christos for (i = 0; i < sizeof (micromips_reloc_map) / sizeof (struct elf_reloc_map);
3103 1.1 christos i++)
3104 1.1 christos {
3105 1.1 christos if (micromips_reloc_map[i].bfd_val == code)
3106 1.1 christos return &howto_micromips_table[(int) micromips_reloc_map[i].elf_val];
3107 1.1 christos }
3108 1.1 christos
3109 1.1 christos switch (code)
3110 1.1 christos {
3111 1.1 christos case BFD_RELOC_VTABLE_INHERIT:
3112 1.1 christos return &elf_mips_gnu_vtinherit_howto;
3113 1.1 christos case BFD_RELOC_VTABLE_ENTRY:
3114 1.1 christos return &elf_mips_gnu_vtentry_howto;
3115 1.1 christos case BFD_RELOC_32_PCREL:
3116 1.1 christos return &elf_mips_gnu_pcrel32;
3117 1.1 christos case BFD_RELOC_MIPS_EH:
3118 1.1 christos return &elf_mips_eh_howto;
3119 1.1 christos case BFD_RELOC_MIPS_COPY:
3120 1.1 christos return &elf_mips_copy_howto;
3121 1.1 christos case BFD_RELOC_MIPS_JUMP_SLOT:
3122 1.1 christos return &elf_mips_jump_slot_howto;
3123 1.1 christos default:
3124 1.1 christos bfd_set_error (bfd_error_bad_value);
3125 1.1 christos return NULL;
3126 1.1 christos }
3127 1.1 christos }
3128 1.1 christos
3129 1.1 christos static reloc_howto_type *
3130 1.1 christos bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
3131 1.1 christos const char *r_name)
3132 1.1 christos {
3133 1.1 christos unsigned int i;
3134 1.1 christos
3135 1.1 christos for (i = 0;
3136 1.1 christos i < (sizeof (elf_mips_howto_table_rela)
3137 1.1 christos / sizeof (elf_mips_howto_table_rela[0]));
3138 1.1 christos i++)
3139 1.1 christos if (elf_mips_howto_table_rela[i].name != NULL
3140 1.1 christos && strcasecmp (elf_mips_howto_table_rela[i].name, r_name) == 0)
3141 1.1 christos return &elf_mips_howto_table_rela[i];
3142 1.1 christos
3143 1.1 christos for (i = 0;
3144 1.1 christos i < (sizeof (elf_mips16_howto_table_rela)
3145 1.1 christos / sizeof (elf_mips16_howto_table_rela[0]));
3146 1.1 christos i++)
3147 1.1 christos if (elf_mips16_howto_table_rela[i].name != NULL
3148 1.1 christos && strcasecmp (elf_mips16_howto_table_rela[i].name, r_name) == 0)
3149 1.1 christos return &elf_mips16_howto_table_rela[i];
3150 1.1 christos
3151 1.1 christos for (i = 0;
3152 1.1 christos i < (sizeof (elf_micromips_howto_table_rela)
3153 1.1 christos / sizeof (elf_micromips_howto_table_rela[0]));
3154 1.1 christos i++)
3155 1.1 christos if (elf_micromips_howto_table_rela[i].name != NULL
3156 1.1 christos && strcasecmp (elf_micromips_howto_table_rela[i].name, r_name) == 0)
3157 1.1 christos return &elf_micromips_howto_table_rela[i];
3158 1.1 christos
3159 1.1 christos if (strcasecmp (elf_mips_gnu_vtinherit_howto.name, r_name) == 0)
3160 1.1 christos return &elf_mips_gnu_vtinherit_howto;
3161 1.1 christos if (strcasecmp (elf_mips_gnu_vtentry_howto.name, r_name) == 0)
3162 1.1 christos return &elf_mips_gnu_vtentry_howto;
3163 1.1 christos if (strcasecmp (elf_mips_gnu_rel16_s2.name, r_name) == 0)
3164 1.1 christos return &elf_mips_gnu_rel16_s2;
3165 1.1 christos if (strcasecmp (elf_mips_gnu_rela16_s2.name, r_name) == 0)
3166 1.1 christos return &elf_mips_gnu_rela16_s2;
3167 1.1 christos if (strcasecmp (elf_mips_gnu_pcrel32.name, r_name) == 0)
3168 1.1 christos return &elf_mips_gnu_pcrel32;
3169 1.1 christos if (strcasecmp (elf_mips_eh_howto.name, r_name) == 0)
3170 1.1 christos return &elf_mips_eh_howto;
3171 1.1 christos if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0)
3172 1.1 christos return &elf_mips_copy_howto;
3173 1.1 christos if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
3174 1.1 christos return &elf_mips_jump_slot_howto;
3175 1.1 christos
3176 1.1 christos return NULL;
3177 1.1 christos }
3178 1.1 christos
3179 1.1 christos /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
3180 1.1 christos
3181 1.1 christos static reloc_howto_type *
3182 1.1 christos mips_elf_n32_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p)
3183 1.1 christos {
3184 1.1 christos switch (r_type)
3185 1.1 christos {
3186 1.1 christos case R_MIPS_GNU_VTINHERIT:
3187 1.1 christos return &elf_mips_gnu_vtinherit_howto;
3188 1.1 christos case R_MIPS_GNU_VTENTRY:
3189 1.1 christos return &elf_mips_gnu_vtentry_howto;
3190 1.1 christos case R_MIPS_GNU_REL16_S2:
3191 1.1 christos if (rela_p)
3192 1.1 christos return &elf_mips_gnu_rela16_s2;
3193 1.1 christos else
3194 1.1 christos return &elf_mips_gnu_rel16_s2;
3195 1.1 christos case R_MIPS_PC32:
3196 1.1 christos return &elf_mips_gnu_pcrel32;
3197 1.1 christos case R_MIPS_EH:
3198 1.1 christos return &elf_mips_eh_howto;
3199 1.1 christos case R_MIPS_COPY:
3200 1.1 christos return &elf_mips_copy_howto;
3201 1.1 christos case R_MIPS_JUMP_SLOT:
3202 1.1 christos return &elf_mips_jump_slot_howto;
3203 1.1 christos default:
3204 1.1 christos if (r_type >= R_MICROMIPS_min && r_type < R_MICROMIPS_max)
3205 1.1 christos {
3206 1.1 christos if (rela_p)
3207 1.1 christos return &elf_micromips_howto_table_rela[r_type - R_MICROMIPS_min];
3208 1.1 christos else
3209 1.1 christos return &elf_micromips_howto_table_rel[r_type - R_MICROMIPS_min];
3210 1.1 christos }
3211 1.1 christos if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
3212 1.1 christos {
3213 1.1 christos if (rela_p)
3214 1.1 christos return &elf_mips16_howto_table_rela[r_type - R_MIPS16_min];
3215 1.1 christos else
3216 1.1 christos return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
3217 1.1 christos }
3218 1.1 christos BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
3219 1.1 christos if (rela_p)
3220 1.1 christos return &elf_mips_howto_table_rela[r_type];
3221 1.1 christos else
3222 1.1 christos return &elf_mips_howto_table_rel[r_type];
3223 1.1 christos break;
3224 1.1 christos }
3225 1.1 christos }
3226 1.1 christos
3227 1.1 christos /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
3228 1.1 christos
3229 1.1 christos static void
3230 1.1 christos mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
3231 1.1 christos {
3232 1.1 christos unsigned int r_type;
3233 1.1 christos
3234 1.1 christos r_type = ELF32_R_TYPE (dst->r_info);
3235 1.1 christos cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, FALSE);
3236 1.1 christos
3237 1.1 christos /* The addend for a GPREL16 or LITERAL relocation comes from the GP
3238 1.1 christos value for the object file. We get the addend now, rather than
3239 1.1 christos when we do the relocation, because the symbol manipulations done
3240 1.1 christos by the linker may cause us to lose track of the input BFD. */
3241 1.1 christos if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
3242 1.1 christos && (gprel16_reloc_p (r_type) || r_type == (unsigned int) R_MIPS_LITERAL))
3243 1.1 christos cache_ptr->addend = elf_gp (abfd);
3244 1.1 christos }
3245 1.1 christos
3246 1.1 christos /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */
3247 1.1 christos
3248 1.1 christos static void
3249 1.1 christos mips_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
3250 1.1 christos arelent *cache_ptr, Elf_Internal_Rela *dst)
3251 1.1 christos {
3252 1.1 christos unsigned int r_type;
3253 1.1 christos
3254 1.1 christos r_type = ELF32_R_TYPE (dst->r_info);
3255 1.1 christos cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, TRUE);
3256 1.1 christos cache_ptr->addend = dst->r_addend;
3257 1.1 christos }
3258 1.1 christos
3259 1.1 christos /* Determine whether a symbol is global for the purposes of splitting
3261 1.1 christos the symbol table into global symbols and local symbols. At least
3262 1.1 christos on Irix 5, this split must be between section symbols and all other
3263 1.1 christos symbols. On most ELF targets the split is between static symbols
3264 1.1 christos and externally visible symbols. */
3265 1.1 christos
3266 1.1 christos static bfd_boolean
3267 1.1 christos mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
3268 1.1 christos {
3269 1.1 christos if (SGI_COMPAT (abfd))
3270 1.1 christos return (sym->flags & BSF_SECTION_SYM) == 0;
3271 1.1 christos else
3272 1.1 christos return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
3273 1.1 christos || bfd_is_und_section (bfd_get_section (sym))
3274 1.1 christos || bfd_is_com_section (bfd_get_section (sym)));
3275 1.1 christos }
3276 1.1 christos
3277 1.1 christos /* Set the right machine number for a MIPS ELF file. */
3279 1.1 christos
3280 1.1 christos static bfd_boolean
3281 1.1 christos mips_elf_n32_object_p (bfd *abfd)
3282 1.1 christos {
3283 1.1 christos unsigned long mach;
3284 1.1 christos
3285 1.1 christos if (!ABI_N32_P (abfd))
3286 1.1 christos return FALSE;
3287 1.1 christos
3288 1.1 christos /* Irix 5 and 6 are broken. Object file symbol tables are not always
3289 1.1 christos sorted correctly such that local symbols precede global symbols,
3290 1.1 christos and the sh_info field in the symbol table is not always right. */
3291 1.1 christos if (SGI_COMPAT (abfd))
3292 1.1 christos elf_bad_symtab (abfd) = TRUE;
3293 1.1 christos
3294 1.1 christos mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
3295 1.1 christos bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
3296 1.1 christos return TRUE;
3297 1.1 christos }
3298 1.1 christos
3299 1.1 christos /* Support for core dump NOTE sections. */
3301 1.1 christos static bfd_boolean
3302 1.1 christos elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
3303 1.1 christos {
3304 1.1 christos int offset;
3305 1.1 christos unsigned int size;
3306 1.1 christos
3307 1.1 christos switch (note->descsz)
3308 1.1 christos {
3309 1.1 christos default:
3310 1.1 christos return FALSE;
3311 1.1 christos
3312 1.1 christos case 440: /* Linux/MIPS N32 */
3313 1.1 christos /* pr_cursig */
3314 1.1 christos elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
3315 1.1 christos
3316 1.1 christos /* pr_pid */
3317 1.1 christos elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
3318 1.1 christos
3319 1.1 christos /* pr_reg */
3320 1.1 christos offset = 72;
3321 1.1 christos size = 360;
3322 1.1 christos
3323 1.1 christos break;
3324 1.1 christos }
3325 1.1 christos
3326 1.1 christos /* Make a ".reg/999" section. */
3327 1.1 christos return _bfd_elfcore_make_pseudosection (abfd, ".reg", size,
3328 1.1 christos note->descpos + offset);
3329 1.1 christos }
3330 1.1 christos
3331 1.1 christos static bfd_boolean
3332 1.1 christos elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
3333 1.1 christos {
3334 1.1 christos switch (note->descsz)
3335 1.1 christos {
3336 1.1 christos default:
3337 1.1 christos return FALSE;
3338 1.1 christos
3339 1.1 christos case 128: /* Linux/MIPS elf_prpsinfo */
3340 1.1 christos elf_tdata (abfd)->core->program
3341 1.1 christos = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
3342 1.1 christos elf_tdata (abfd)->core->command
3343 1.1 christos = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
3344 1.1 christos }
3345 1.1 christos
3346 1.1 christos /* Note that for some reason, a spurious space is tacked
3347 1.1 christos onto the end of the args in some (at least one anyway)
3348 1.1 christos implementations, so strip it off if it exists. */
3349 1.1 christos
3350 1.1 christos {
3351 1.1 christos char *command = elf_tdata (abfd)->core->command;
3352 1.1 christos int n = strlen (command);
3353 1.1 christos
3354 1.1 christos if (0 < n && command[n - 1] == ' ')
3355 1.1 christos command[n - 1] = '\0';
3356 1.1 christos }
3357 1.1 christos
3358 1.1 christos return TRUE;
3359 1.1 christos }
3360 1.1 christos
3361 1.1 christos /* Depending on the target vector we generate some version of Irix
3363 1.1 christos executables or "normal" MIPS ELF ABI executables. */
3364 1.1 christos static irix_compat_t
3365 1.1 christos elf_n32_mips_irix_compat (bfd *abfd)
3366 1.1 christos {
3367 1.1 christos if ((abfd->xvec == &bfd_elf32_nbigmips_vec)
3368 1.1 christos || (abfd->xvec == &bfd_elf32_nlittlemips_vec))
3369 1.1 christos return ict_irix6;
3370 1.1 christos else
3371 1.1 christos return ict_none;
3372 1.1 christos }
3373 1.1 christos
3374 1.1 christos /* ECOFF swapping routines. These are used when dealing with the
3376 1.1 christos .mdebug section, which is in the ECOFF debugging format. */
3377 1.1 christos static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
3378 1.1 christos /* Symbol table magic number. */
3379 1.1 christos magicSym,
3380 1.1 christos /* Alignment of debugging information. E.g., 4. */
3381 1.1 christos 4,
3382 1.1 christos /* Sizes of external symbolic information. */
3383 1.1 christos sizeof (struct hdr_ext),
3384 1.1 christos sizeof (struct dnr_ext),
3385 1.1 christos sizeof (struct pdr_ext),
3386 1.1 christos sizeof (struct sym_ext),
3387 1.1 christos sizeof (struct opt_ext),
3388 1.1 christos sizeof (struct fdr_ext),
3389 1.1 christos sizeof (struct rfd_ext),
3390 1.1 christos sizeof (struct ext_ext),
3391 1.1 christos /* Functions to swap in external symbolic data. */
3392 1.1 christos ecoff_swap_hdr_in,
3393 1.1 christos ecoff_swap_dnr_in,
3394 1.1 christos ecoff_swap_pdr_in,
3395 1.1 christos ecoff_swap_sym_in,
3396 1.1 christos ecoff_swap_opt_in,
3397 1.1 christos ecoff_swap_fdr_in,
3398 1.1 christos ecoff_swap_rfd_in,
3399 1.1 christos ecoff_swap_ext_in,
3400 1.1 christos _bfd_ecoff_swap_tir_in,
3401 1.1 christos _bfd_ecoff_swap_rndx_in,
3402 1.1 christos /* Functions to swap out external symbolic data. */
3403 1.1 christos ecoff_swap_hdr_out,
3404 1.1 christos ecoff_swap_dnr_out,
3405 1.1 christos ecoff_swap_pdr_out,
3406 1.1 christos ecoff_swap_sym_out,
3407 1.1 christos ecoff_swap_opt_out,
3408 1.1 christos ecoff_swap_fdr_out,
3409 1.1 christos ecoff_swap_rfd_out,
3410 1.1 christos ecoff_swap_ext_out,
3411 1.1 christos _bfd_ecoff_swap_tir_out,
3412 1.1 christos _bfd_ecoff_swap_rndx_out,
3413 1.1 christos /* Function to read in symbolic data. */
3414 1.1 christos _bfd_mips_elf_read_ecoff_info
3415 1.1 christos };
3416 1.1 christos
3417 1.1 christos #define ELF_ARCH bfd_arch_mips
3419 1.1 christos #define ELF_TARGET_ID MIPS_ELF_DATA
3420 1.1 christos #define ELF_MACHINE_CODE EM_MIPS
3421 1.1 christos
3422 1.1 christos #define elf_backend_collect TRUE
3423 1.1 christos #define elf_backend_type_change_ok TRUE
3424 1.1 christos #define elf_backend_can_gc_sections TRUE
3425 1.1 christos #define elf_info_to_howto mips_info_to_howto_rela
3426 1.1 christos #define elf_info_to_howto_rel mips_info_to_howto_rel
3427 1.1 christos #define elf_backend_sym_is_global mips_elf_sym_is_global
3428 1.1 christos #define elf_backend_object_p mips_elf_n32_object_p
3429 1.1 christos #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
3430 1.1 christos #define elf_backend_section_processing _bfd_mips_elf_section_processing
3431 1.1 christos #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
3432 1.1 christos #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
3433 1.1 christos #define elf_backend_section_from_bfd_section \
3434 1.1 christos _bfd_mips_elf_section_from_bfd_section
3435 1.1 christos #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
3436 1.1 christos #define elf_backend_link_output_symbol_hook \
3437 1.1 christos _bfd_mips_elf_link_output_symbol_hook
3438 1.1 christos #define elf_backend_create_dynamic_sections \
3439 1.1 christos _bfd_mips_elf_create_dynamic_sections
3440 1.1 christos #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
3441 1.1 christos #define elf_backend_merge_symbol_attribute \
3442 1.1 christos _bfd_mips_elf_merge_symbol_attribute
3443 1.1 christos #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
3444 1.1 christos #define elf_backend_adjust_dynamic_symbol \
3445 1.1 christos _bfd_mips_elf_adjust_dynamic_symbol
3446 1.1 christos #define elf_backend_always_size_sections \
3447 1.1 christos _bfd_mips_elf_always_size_sections
3448 1.1 christos #define elf_backend_size_dynamic_sections \
3449 1.1 christos _bfd_mips_elf_size_dynamic_sections
3450 1.1 christos #define elf_backend_init_index_section _bfd_elf_init_1_index_section
3451 1.1 christos #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
3452 1.1 christos #define elf_backend_finish_dynamic_symbol \
3453 1.1 christos _bfd_mips_elf_finish_dynamic_symbol
3454 1.1 christos #define elf_backend_finish_dynamic_sections \
3455 1.1 christos _bfd_mips_elf_finish_dynamic_sections
3456 1.1 christos #define elf_backend_final_write_processing \
3457 1.1 christos _bfd_mips_elf_final_write_processing
3458 1.1 christos #define elf_backend_additional_program_headers \
3459 1.1 christos _bfd_mips_elf_additional_program_headers
3460 1.1 christos #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
3461 1.1 christos #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
3462 1.1 christos #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
3463 1.1 christos #define elf_backend_copy_indirect_symbol \
3464 1.1 christos _bfd_mips_elf_copy_indirect_symbol
3465 1.1 christos #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
3466 1.1 christos #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
3467 1.1 christos #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
3468 1.1 christos
3469 1.1 christos #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
3470 1.1 christos
3471 1.1 christos /* MIPS n32 ELF can use a mixture of REL and RELA, but some Relocations
3472 1.1 christos work better/work only in RELA, so we default to this. */
3473 1.1 christos #define elf_backend_may_use_rel_p 1
3474 1.1 christos #define elf_backend_may_use_rela_p 1
3475 1.1 christos #define elf_backend_default_use_rela_p 1
3476 1.1 christos #define elf_backend_rela_plts_and_copies_p 0
3477 1.1 christos #define elf_backend_sign_extend_vma TRUE
3478 1.1 christos #define elf_backend_plt_readonly 1
3479 1.1 christos #define elf_backend_plt_sym_val _bfd_mips_elf_plt_sym_val
3480 1.1 christos
3481 1.1 christos #define elf_backend_discard_info _bfd_mips_elf_discard_info
3482 1.1 christos #define elf_backend_ignore_discarded_relocs \
3483 1.1 christos _bfd_mips_elf_ignore_discarded_relocs
3484 1.1 christos #define elf_backend_write_section _bfd_mips_elf_write_section
3485 1.1 christos #define elf_backend_mips_irix_compat elf_n32_mips_irix_compat
3486 1.1 christos #define elf_backend_mips_rtype_to_howto mips_elf_n32_rtype_to_howto
3487 1.1 christos #define bfd_elf32_bfd_is_target_special_symbol \
3488 1.1 christos _bfd_mips_elf_is_target_special_symbol
3489 1.1 christos #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
3490 1.1 christos #define bfd_elf32_find_inliner_info _bfd_mips_elf_find_inliner_info
3491 1.1 christos #define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook
3492 1.1 christos #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
3493 1.1 christos #define bfd_elf32_bfd_get_relocated_section_contents \
3494 1.1 christos _bfd_elf_mips_get_relocated_section_contents
3495 1.1 christos #define bfd_elf32_bfd_link_hash_table_create \
3496 1.1 christos _bfd_mips_elf_link_hash_table_create
3497 1.1 christos #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
3498 1.1 christos #define bfd_elf32_bfd_merge_private_bfd_data \
3499 1.1 christos _bfd_mips_elf_merge_private_bfd_data
3500 1.1 christos #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
3501 1.1 christos #define bfd_elf32_bfd_print_private_bfd_data \
3502 1.1 christos _bfd_mips_elf_print_private_bfd_data
3503 1.1 christos #define bfd_elf32_bfd_relax_section _bfd_mips_relax_section
3504 1.1 christos #define bfd_elf32_mkobject _bfd_mips_elf_mkobject
3505 1.1 christos
3506 1.1 christos /* Support for SGI-ish mips targets using n32 ABI. */
3507 1.1 christos
3508 1.1 christos #define TARGET_LITTLE_SYM bfd_elf32_nlittlemips_vec
3509 1.1 christos #define TARGET_LITTLE_NAME "elf32-nlittlemips"
3510 1.1 christos #define TARGET_BIG_SYM bfd_elf32_nbigmips_vec
3511 1.1 christos #define TARGET_BIG_NAME "elf32-nbigmips"
3512 1.1 christos
3513 1.1 christos #define ELF_MAXPAGESIZE 0x10000
3514 1.1 christos #define ELF_COMMONPAGESIZE 0x1000
3515 1.1 christos
3516 1.1 christos #include "elf32-target.h"
3517 1.1 christos
3518 1.1 christos /* Support for traditional mips targets using n32 ABI. */
3519 1.1 christos #undef TARGET_LITTLE_SYM
3520 1.1 christos #undef TARGET_LITTLE_NAME
3521 1.1 christos #undef TARGET_BIG_SYM
3522 1.1 christos #undef TARGET_BIG_NAME
3523 1.1 christos
3524 1.1 christos #undef ELF_MAXPAGESIZE
3525 1.1 christos #undef ELF_COMMONPAGESIZE
3526 1.1 christos
3527 1.1 christos #define TARGET_LITTLE_SYM bfd_elf32_ntradlittlemips_vec
3528 1.1 christos #define TARGET_LITTLE_NAME "elf32-ntradlittlemips"
3529 1.1 christos #define TARGET_BIG_SYM bfd_elf32_ntradbigmips_vec
3530 1.1 christos #define TARGET_BIG_NAME "elf32-ntradbigmips"
3531 1.1 christos
3532 1.1 christos #define ELF_MAXPAGESIZE 0x10000
3533 1.1 christos #define ELF_COMMONPAGESIZE 0x1000
3534 1.1 christos #define elf32_bed elf32_tradbed
3535 1.1 christos
3536 1.1 christos /* Include the target file again for this target. */
3537 1.1 christos #include "elf32-target.h"
3538 1.1 christos
3539 1.1 christos
3540 1.1 christos /* FreeBSD support. */
3541 1.1 christos
3542 1.1 christos #undef TARGET_LITTLE_SYM
3543 1.1 christos #undef TARGET_LITTLE_NAME
3544 1.1 christos #undef TARGET_BIG_SYM
3545 1.1 christos #undef TARGET_BIG_NAME
3546 1.1 christos
3547 1.1 christos #define TARGET_LITTLE_SYM bfd_elf32_ntradlittlemips_freebsd_vec
3548 #define TARGET_LITTLE_NAME "elf32-ntradlittlemips-freebsd"
3549 #define TARGET_BIG_SYM bfd_elf32_ntradbigmips_freebsd_vec
3550 #define TARGET_BIG_NAME "elf32-ntradbigmips-freebsd"
3551
3552 #undef ELF_OSABI
3553 #define ELF_OSABI ELFOSABI_FREEBSD
3554
3555 #undef elf32_bed
3556 #define elf32_bed elf32_fbsd_tradbed
3557
3558 #include "elf32-target.h"
3559