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 0xffffffff, /* 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 0xffffffff, /* 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 0x0000ffff, /* 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 0x0000ffff, /* 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 0x0000ffff, /* 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 0x0000ffff, /* 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 0x0000ffff, /* 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 0xffffffff, /* 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 0x0000ffff, /* 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 0x0000ffff, /* 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
1560 1.1 christos static reloc_howto_type elf_mips16_howto_table_rela[] =
1561 1.1 christos {
1562 1.1 christos /* The reloc used for the mips16 jump instruction. */
1563 1.1 christos HOWTO (R_MIPS16_26, /* type */
1564 1.1 christos 2, /* rightshift */
1565 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1566 1.1 christos 26, /* bitsize */
1567 1.1 christos FALSE, /* pc_relative */
1568 1.1 christos 0, /* bitpos */
1569 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1570 1.1 christos /* This needs complex overflow
1571 1.1 christos detection, because the upper four
1572 1.1 christos bits must match the PC. */
1573 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1574 1.1 christos "R_MIPS16_26", /* name */
1575 1.1 christos FALSE, /* partial_inplace */
1576 1.1 christos 0x3ffffff, /* src_mask */
1577 1.1 christos 0x3ffffff, /* dst_mask */
1578 1.1 christos FALSE), /* pcrel_offset */
1579 1.1 christos
1580 1.1 christos /* The reloc used for the mips16 gprel instruction. */
1581 1.1 christos HOWTO (R_MIPS16_GPREL, /* type */
1582 1.1 christos 0, /* rightshift */
1583 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1584 1.1 christos 16, /* bitsize */
1585 1.1 christos FALSE, /* pc_relative */
1586 1.1 christos 0, /* bitpos */
1587 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1588 1.1 christos mips16_gprel_reloc, /* special_function */
1589 1.1 christos "R_MIPS16_GPREL", /* name */
1590 1.1 christos FALSE, /* partial_inplace */
1591 1.1 christos 0x0000ffff, /* src_mask */
1592 1.1 christos 0x0000ffff, /* dst_mask */
1593 1.1 christos FALSE), /* pcrel_offset */
1594 1.1 christos
1595 1.1 christos /* A MIPS16 reference to the global offset table. */
1596 1.1 christos HOWTO (R_MIPS16_GOT16, /* type */
1597 1.1 christos 0, /* rightshift */
1598 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1599 1.1 christos 16, /* bitsize */
1600 1.1 christos FALSE, /* pc_relative */
1601 1.1 christos 0, /* bitpos */
1602 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1603 1.1 christos _bfd_mips_elf_got16_reloc, /* special_function */
1604 1.1 christos "R_MIPS16_GOT16", /* name */
1605 1.1 christos FALSE, /* partial_inplace */
1606 1.1 christos 0x0000ffff, /* src_mask */
1607 1.1 christos 0x0000ffff, /* dst_mask */
1608 1.1 christos FALSE), /* pcrel_offset */
1609 1.1 christos
1610 1.1 christos /* A MIPS16 call through the global offset table. */
1611 1.1 christos HOWTO (R_MIPS16_CALL16, /* type */
1612 1.1 christos 0, /* rightshift */
1613 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1614 1.1 christos 16, /* bitsize */
1615 1.1 christos FALSE, /* pc_relative */
1616 1.1 christos 0, /* bitpos */
1617 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1618 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1619 1.1 christos "R_MIPS16_CALL16", /* name */
1620 1.1 christos FALSE, /* partial_inplace */
1621 1.1 christos 0x0000ffff, /* src_mask */
1622 1.1 christos 0x0000ffff, /* dst_mask */
1623 1.1 christos FALSE), /* pcrel_offset */
1624 1.1 christos
1625 1.1 christos /* MIPS16 high 16 bits of symbol value. */
1626 1.1 christos HOWTO (R_MIPS16_HI16, /* type */
1627 1.1 christos 16, /* rightshift */
1628 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1629 1.1 christos 16, /* bitsize */
1630 1.1 christos FALSE, /* pc_relative */
1631 1.1 christos 0, /* bitpos */
1632 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1633 1.1 christos _bfd_mips_elf_hi16_reloc, /* special_function */
1634 1.1 christos "R_MIPS16_HI16", /* name */
1635 1.1 christos FALSE, /* partial_inplace */
1636 1.1 christos 0x0000ffff, /* src_mask */
1637 1.1 christos 0x0000ffff, /* dst_mask */
1638 1.1 christos FALSE), /* pcrel_offset */
1639 1.1 christos
1640 1.1 christos /* MIPS16 low 16 bits of symbol value. */
1641 1.1 christos HOWTO (R_MIPS16_LO16, /* type */
1642 1.1 christos 0, /* rightshift */
1643 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1644 1.1 christos 16, /* bitsize */
1645 1.1 christos FALSE, /* pc_relative */
1646 1.1 christos 0, /* bitpos */
1647 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1648 1.1 christos _bfd_mips_elf_lo16_reloc, /* special_function */
1649 1.1 christos "R_MIPS16_LO16", /* name */
1650 1.1 christos FALSE, /* partial_inplace */
1651 1.1 christos 0x0000ffff, /* src_mask */
1652 1.1 christos 0x0000ffff, /* dst_mask */
1653 1.1 christos FALSE), /* pcrel_offset */
1654 1.1 christos };
1655 1.1 christos
1656 1.1 christos /* GNU extension to record C++ vtable hierarchy */
1657 1.1 christos static reloc_howto_type elf_mips_gnu_vtinherit_howto =
1658 1.1 christos HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
1659 1.1 christos 0, /* rightshift */
1660 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1661 1.1 christos 0, /* bitsize */
1662 1.1 christos FALSE, /* pc_relative */
1663 1.1 christos 0, /* bitpos */
1664 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1665 1.1 christos NULL, /* special_function */
1666 1.1 christos "R_MIPS_GNU_VTINHERIT", /* name */
1667 1.1 christos FALSE, /* partial_inplace */
1668 1.1 christos 0, /* src_mask */
1669 1.1 christos 0, /* dst_mask */
1670 1.1 christos FALSE); /* pcrel_offset */
1671 1.1 christos
1672 1.1 christos /* GNU extension to record C++ vtable member usage */
1673 1.1 christos static reloc_howto_type elf_mips_gnu_vtentry_howto =
1674 1.1 christos HOWTO (R_MIPS_GNU_VTENTRY, /* type */
1675 1.1 christos 0, /* rightshift */
1676 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1677 1.1 christos 0, /* bitsize */
1678 1.1 christos FALSE, /* pc_relative */
1679 1.1 christos 0, /* bitpos */
1680 1.1 christos complain_overflow_dont, /* complain_on_overflow */
1681 1.1 christos _bfd_elf_rel_vtable_reloc_fn, /* special_function */
1682 1.1 christos "R_MIPS_GNU_VTENTRY", /* name */
1683 1.1 christos FALSE, /* partial_inplace */
1684 1.1 christos 0, /* src_mask */
1685 1.1 christos 0, /* dst_mask */
1686 1.1 christos FALSE); /* pcrel_offset */
1687 1.1 christos
1688 1.1 christos /* 16 bit offset for pc-relative branches. */
1690 1.1 christos static reloc_howto_type elf_mips_gnu_rel16_s2 =
1691 1.1 christos HOWTO (R_MIPS_GNU_REL16_S2, /* type */
1692 1.1 christos 2, /* rightshift */
1693 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1694 1.1 christos 16, /* bitsize */
1695 1.1 christos TRUE, /* pc_relative */
1696 1.1 christos 0, /* bitpos */
1697 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1698 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1699 1.1 christos "R_MIPS_GNU_REL16_S2", /* name */
1700 1.1 christos TRUE, /* partial_inplace */
1701 1.1 christos 0x0000ffff, /* src_mask */
1702 1.1 christos 0x0000ffff, /* dst_mask */
1703 1.1 christos TRUE); /* pcrel_offset */
1704 1.1 christos
1705 1.1 christos /* 16 bit offset for pc-relative branches. */
1706 1.1 christos static reloc_howto_type elf_mips_gnu_rela16_s2 =
1707 1.1 christos HOWTO (R_MIPS_GNU_REL16_S2, /* type */
1708 1.1 christos 2, /* rightshift */
1709 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1710 1.1 christos 16, /* bitsize */
1711 1.1 christos TRUE, /* pc_relative */
1712 1.1 christos 0, /* bitpos */
1713 1.1 christos complain_overflow_signed, /* complain_on_overflow */
1714 1.1 christos _bfd_mips_elf_generic_reloc, /* special_function */
1715 1.1 christos "R_MIPS_GNU_REL16_S2", /* name */
1716 1.1 christos FALSE, /* partial_inplace */
1717 1.1 christos 0, /* src_mask */
1718 1.1 christos 0x0000ffff, /* dst_mask */
1719 1.1 christos TRUE); /* pcrel_offset */
1720 1.1 christos
1721 1.1 christos /* Originally a VxWorks extension, but now used for other systems too. */
1723 1.1 christos static reloc_howto_type elf_mips_copy_howto =
1724 1.1 christos HOWTO (R_MIPS_COPY, /* type */
1725 1.1 christos 0, /* rightshift */
1726 1.1 christos 0, /* this one is variable size */
1727 1.1 christos 0, /* bitsize */
1728 1.1 christos FALSE, /* pc_relative */
1729 1.1 christos 0, /* bitpos */
1730 1.1 christos complain_overflow_bitfield, /* complain_on_overflow */
1731 1.1 christos bfd_elf_generic_reloc, /* special_function */
1732 1.1 christos "R_MIPS_COPY", /* name */
1733 1.1 christos FALSE, /* partial_inplace */
1734 1.1 christos 0x0, /* src_mask */
1735 1.1 christos 0x0, /* dst_mask */
1736 1.1 christos FALSE); /* pcrel_offset */
1737 1.1 christos
1738 1.1 christos /* Originally a VxWorks extension, but now used for other systems too. */
1739 1.1 christos static reloc_howto_type elf_mips_jump_slot_howto =
1740 1.1 christos HOWTO (R_MIPS_JUMP_SLOT, /* type */
1741 1.1 christos 0, /* rightshift */
1742 1.1 christos 2, /* size (0 = byte, 1 = short, 2 = long) */
1743 1.1 christos 32, /* bitsize */
1744 1.1 christos FALSE, /* pc_relative */
1745 1.1 christos 0, /* bitpos */
1746 1.1 christos complain_overflow_bitfield, /* complain_on_overflow */
1747 1.1 christos bfd_elf_generic_reloc, /* special_function */
1748 1.1 christos "R_MIPS_JUMP_SLOT", /* name */
1749 1.1 christos FALSE, /* partial_inplace */
1750 1.1 christos 0x0, /* src_mask */
1751 1.1 christos 0x0, /* dst_mask */
1752 1.1 christos FALSE); /* pcrel_offset */
1753 1.1 christos
1754 1.1 christos /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
1756 1.1 christos dangerous relocation. */
1757 1.1 christos
1758 1.1 christos static bfd_boolean
1759 1.1 christos mips_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
1760 1.1 christos {
1761 1.1 christos unsigned int count;
1762 1.1 christos asymbol **sym;
1763 1.1 christos unsigned int i;
1764 1.1 christos
1765 1.1 christos /* If we've already figured out what GP will be, just return it. */
1766 1.1 christos *pgp = _bfd_get_gp_value (output_bfd);
1767 1.1 christos if (*pgp)
1768 1.1 christos return TRUE;
1769 1.1 christos
1770 1.1 christos count = bfd_get_symcount (output_bfd);
1771 1.1 christos sym = bfd_get_outsymbols (output_bfd);
1772 1.1 christos
1773 1.1 christos /* The linker script will have created a symbol named `_gp' with the
1774 1.1 christos appropriate value. */
1775 1.1 christos if (sym == NULL)
1776 1.1 christos i = count;
1777 1.1 christos else
1778 1.1 christos {
1779 1.1 christos for (i = 0; i < count; i++, sym++)
1780 1.1 christos {
1781 1.1 christos register const char *name;
1782 1.1 christos
1783 1.1 christos name = bfd_asymbol_name (*sym);
1784 1.1 christos if (*name == '_' && strcmp (name, "_gp") == 0)
1785 1.1 christos {
1786 1.1 christos *pgp = bfd_asymbol_value (*sym);
1787 1.1 christos _bfd_set_gp_value (output_bfd, *pgp);
1788 1.1 christos break;
1789 1.1 christos }
1790 1.1 christos }
1791 1.1 christos }
1792 1.1 christos
1793 1.1 christos if (i >= count)
1794 1.1 christos {
1795 1.1 christos /* Only get the error once. */
1796 1.1 christos *pgp = 4;
1797 1.1 christos _bfd_set_gp_value (output_bfd, *pgp);
1798 1.1 christos return FALSE;
1799 1.1 christos }
1800 1.1 christos
1801 1.1 christos return TRUE;
1802 1.1 christos }
1803 1.1 christos
1804 1.1 christos /* We have to figure out the gp value, so that we can adjust the
1805 1.1 christos symbol value correctly. We look up the symbol _gp in the output
1806 1.1 christos BFD. If we can't find it, we're stuck. We cache it in the ELF
1807 1.1 christos target data. We don't need to adjust the symbol value for an
1808 1.1 christos external symbol if we are producing relocatable output. */
1809 1.1 christos
1810 1.1 christos static bfd_reloc_status_type
1811 1.1 christos mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
1812 1.1 christos char **error_message, bfd_vma *pgp)
1813 1.1 christos {
1814 1.1 christos if (bfd_is_und_section (symbol->section)
1815 1.1 christos && ! relocatable)
1816 1.1 christos {
1817 1.1 christos *pgp = 0;
1818 1.1 christos return bfd_reloc_undefined;
1819 1.1 christos }
1820 1.1 christos
1821 1.1 christos *pgp = _bfd_get_gp_value (output_bfd);
1822 1.1 christos if (*pgp == 0
1823 1.1 christos && (! relocatable
1824 1.1 christos || (symbol->flags & BSF_SECTION_SYM) != 0))
1825 1.1 christos {
1826 1.1 christos if (relocatable)
1827 1.1 christos {
1828 1.1 christos /* Make up a value. */
1829 1.1 christos *pgp = symbol->section->output_section->vma /*+ 0x4000*/;
1830 1.1 christos _bfd_set_gp_value (output_bfd, *pgp);
1831 1.1 christos }
1832 1.1 christos else if (!mips_elf_assign_gp (output_bfd, pgp))
1833 1.1 christos {
1834 1.1 christos *error_message =
1835 1.1 christos (char *) _("GP relative relocation when _gp not defined");
1836 1.1 christos return bfd_reloc_dangerous;
1837 1.1 christos }
1838 1.1 christos }
1839 1.1 christos
1840 1.1 christos return bfd_reloc_ok;
1841 1.1 christos }
1842 1.1 christos
1843 1.1 christos /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
1844 1.1 christos become the offset from the gp register. */
1845 1.1 christos
1846 1.1 christos static bfd_reloc_status_type
1847 1.1 christos mips_elf_gprel16_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
1848 1.1 christos asymbol *symbol, void *data ATTRIBUTE_UNUSED,
1849 1.1 christos asection *input_section, bfd *output_bfd,
1850 1.1 christos char **error_message ATTRIBUTE_UNUSED)
1851 1.1 christos {
1852 1.1 christos bfd_boolean relocatable;
1853 1.1 christos bfd_reloc_status_type ret;
1854 1.1 christos bfd_vma gp;
1855 1.1 christos
1856 1.1 christos if (output_bfd != NULL)
1857 1.1 christos relocatable = TRUE;
1858 1.1 christos else
1859 1.1 christos {
1860 1.1 christos relocatable = FALSE;
1861 1.1 christos output_bfd = symbol->section->output_section->owner;
1862 1.1 christos }
1863 1.1 christos
1864 1.1 christos ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
1865 1.1 christos &gp);
1866 1.1 christos if (ret != bfd_reloc_ok)
1867 1.1 christos return ret;
1868 1.1 christos
1869 1.1 christos return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1870 1.1 christos input_section, relocatable,
1871 1.1 christos data, gp);
1872 1.1 christos }
1873 1.1 christos
1874 1.1 christos /* Do a R_MIPS_LITERAL relocation. */
1875 1.1 christos
1876 1.1 christos static bfd_reloc_status_type
1877 1.1 christos mips_elf_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
1878 1.1 christos void *data, asection *input_section, bfd *output_bfd,
1879 1.1 christos char **error_message)
1880 1.1 christos {
1881 1.1 christos bfd_boolean relocatable;
1882 1.1 christos bfd_reloc_status_type ret;
1883 1.1 christos bfd_vma gp;
1884 1.1 christos
1885 1.1 christos /* R_MIPS_LITERAL relocations are defined for local symbols only. */
1886 1.1 christos if (output_bfd != NULL
1887 1.1 christos && (symbol->flags & BSF_SECTION_SYM) == 0
1888 1.1 christos && (symbol->flags & BSF_LOCAL) != 0)
1889 1.1 christos {
1890 1.1 christos *error_message = (char *)
1891 1.1 christos _("literal relocation occurs for an external symbol");
1892 1.1 christos return bfd_reloc_outofrange;
1893 1.1 christos }
1894 1.1 christos
1895 1.1 christos /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */
1896 1.1 christos if (output_bfd != NULL)
1897 1.1 christos relocatable = TRUE;
1898 1.1 christos else
1899 1.1 christos {
1900 1.1 christos relocatable = FALSE;
1901 1.1 christos output_bfd = symbol->section->output_section->owner;
1902 1.1 christos }
1903 1.1 christos
1904 1.1 christos ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
1905 1.1 christos &gp);
1906 1.1 christos if (ret != bfd_reloc_ok)
1907 1.1 christos return ret;
1908 1.1 christos
1909 1.1 christos return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
1910 1.1 christos input_section, relocatable,
1911 1.1 christos data, gp);
1912 1.1 christos }
1913 1.1 christos
1914 1.1 christos /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
1915 1.1 christos become the offset from the gp register. */
1916 1.1 christos
1917 1.1 christos static bfd_reloc_status_type
1918 1.1 christos mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
1919 1.1 christos void *data, asection *input_section, bfd *output_bfd,
1920 1.1 christos char **error_message)
1921 1.1 christos {
1922 1.1 christos bfd_boolean relocatable;
1923 1.1 christos bfd_reloc_status_type ret;
1924 1.1 christos bfd_vma gp;
1925 1.1 christos
1926 1.1 christos /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
1927 1.1 christos if (output_bfd != NULL
1928 1.1 christos && (symbol->flags & BSF_SECTION_SYM) == 0
1929 1.1 christos && (symbol->flags & BSF_LOCAL) != 0)
1930 1.1 christos {
1931 1.1 christos *error_message = (char *)
1932 1.1 christos _("32bits gp relative relocation occurs for an external symbol");
1933 1.1 christos return bfd_reloc_outofrange;
1934 1.1 christos }
1935 1.1 christos
1936 1.1 christos if (output_bfd != NULL)
1937 1.1 christos {
1938 1.1 christos relocatable = TRUE;
1939 1.1 christos gp = _bfd_get_gp_value (output_bfd);
1940 1.1 christos }
1941 1.1 christos else
1942 1.1 christos {
1943 1.1 christos relocatable = FALSE;
1944 1.1 christos output_bfd = symbol->section->output_section->owner;
1945 1.1 christos
1946 1.1 christos ret = mips_elf_final_gp (output_bfd, symbol, relocatable,
1947 1.1 christos error_message, &gp);
1948 1.1 christos if (ret != bfd_reloc_ok)
1949 1.1 christos return ret;
1950 1.1 christos }
1951 1.1 christos
1952 1.1 christos return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
1953 1.1 christos relocatable, data, gp);
1954 1.1 christos }
1955 1.1 christos
1956 1.1 christos static bfd_reloc_status_type
1957 1.1 christos gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
1958 1.1 christos asection *input_section, bfd_boolean relocatable,
1959 1.1 christos void *data, bfd_vma gp)
1960 1.1 christos {
1961 1.1 christos bfd_vma relocation;
1962 1.1 christos unsigned long val;
1963 1.1 christos
1964 1.1 christos if (bfd_is_com_section (symbol->section))
1965 1.1 christos relocation = 0;
1966 1.1 christos else
1967 1.1 christos relocation = symbol->value;
1968 1.1 christos
1969 1.1 christos relocation += symbol->section->output_section->vma;
1970 1.1 christos relocation += symbol->section->output_offset;
1971 1.1 christos
1972 1.1 christos if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
1973 1.1 christos return bfd_reloc_outofrange;
1974 1.1 christos
1975 1.1 christos if (reloc_entry->howto->src_mask == 0)
1976 1.1 christos val = 0;
1977 1.1 christos else
1978 1.1 christos val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
1979 1.1 christos
1980 1.1 christos /* Set val to the offset into the section or symbol. */
1981 1.1 christos val += reloc_entry->addend;
1982 1.1 christos
1983 1.1 christos /* Adjust val for the final section location and GP value. If we
1984 1.1 christos are producing relocatable output, we don't want to do this for
1985 1.1 christos an external symbol. */
1986 1.1 christos if (! relocatable
1987 1.1 christos || (symbol->flags & BSF_SECTION_SYM) != 0)
1988 1.1 christos val += relocation - gp;
1989 1.1 christos
1990 1.1 christos bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
1991 1.1 christos
1992 1.1 christos if (relocatable)
1993 1.1 christos reloc_entry->address += input_section->output_offset;
1994 1.1 christos
1995 1.1 christos return bfd_reloc_ok;
1996 1.1 christos }
1997 1.1 christos
1998 1.1 christos /* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
1999 1.1 christos the rest is at bits 6-10. The bitpos already got right by the howto. */
2000 1.1 christos
2001 1.1 christos static bfd_reloc_status_type
2002 1.1 christos mips_elf_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
2003 1.1 christos void *data, asection *input_section, bfd *output_bfd,
2004 1.1 christos char **error_message)
2005 1.1 christos {
2006 1.1 christos if (reloc_entry->howto->partial_inplace)
2007 1.1 christos {
2008 1.1 christos reloc_entry->addend = ((reloc_entry->addend & 0x00007c0)
2009 1.1 christos | (reloc_entry->addend & 0x00000800) >> 9);
2010 1.1 christos }
2011 1.1 christos
2012 1.1 christos return _bfd_mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
2013 1.1 christos input_section, output_bfd,
2014 1.1 christos error_message);
2015 1.1 christos }
2016 1.1 christos
2017 1.1 christos /* Handle a mips16 GP relative reloc. */
2019 1.1 christos
2020 1.1 christos static bfd_reloc_status_type
2021 1.1 christos mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
2022 1.1 christos void *data, asection *input_section, bfd *output_bfd,
2023 1.1 christos char **error_message)
2024 1.1 christos {
2025 1.1 christos bfd_boolean relocatable;
2026 1.1 christos bfd_reloc_status_type ret;
2027 1.1 christos bfd_byte *location;
2028 1.1 christos bfd_vma gp;
2029 1.1 christos
2030 1.1 christos /* If we're relocating, and this is an external symbol, we don't want
2031 1.1 christos to change anything. */
2032 1.1 christos if (output_bfd != NULL
2033 1.1 christos && (symbol->flags & BSF_SECTION_SYM) == 0
2034 1.1 christos && (symbol->flags & BSF_LOCAL) != 0)
2035 1.1 christos {
2036 1.1 christos reloc_entry->address += input_section->output_offset;
2037 1.1 christos return bfd_reloc_ok;
2038 1.1 christos }
2039 1.1 christos
2040 1.1 christos if (output_bfd != NULL)
2041 1.1 christos relocatable = TRUE;
2042 1.1 christos else
2043 1.1 christos {
2044 1.1 christos relocatable = FALSE;
2045 1.1 christos output_bfd = symbol->section->output_section->owner;
2046 1.1 christos }
2047 1.1 christos
2048 1.1 christos ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
2049 1.1 christos &gp);
2050 1.1 christos if (ret != bfd_reloc_ok)
2051 1.1 christos return ret;
2052 1.1 christos
2053 1.1 christos location = (bfd_byte *) data + reloc_entry->address;
2054 1.1 christos _bfd_mips16_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE,
2055 1.1 christos location);
2056 1.1 christos ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
2057 1.1 christos input_section, relocatable,
2058 1.1 christos data, gp);
2059 1.1 christos _bfd_mips16_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
2060 1.1 christos location);
2061 1.1 christos
2062 1.1 christos return ret;
2063 1.1 christos }
2064 1.1 christos
2065 1.1 christos /* A mapping from BFD reloc types to MIPS ELF reloc types. */
2067 1.1 christos
2068 1.1 christos struct elf_reloc_map {
2069 1.1 christos bfd_reloc_code_real_type bfd_val;
2070 1.1 christos enum elf_mips_reloc_type elf_val;
2071 1.1 christos };
2072 1.1 christos
2073 1.1 christos static const struct elf_reloc_map mips_reloc_map[] =
2074 1.1 christos {
2075 1.1 christos { BFD_RELOC_NONE, R_MIPS_NONE },
2076 1.1 christos { BFD_RELOC_16, R_MIPS_16 },
2077 1.1 christos { BFD_RELOC_32, R_MIPS_32 },
2078 1.1 christos /* There is no BFD reloc for R_MIPS_REL32. */
2079 1.1 christos { BFD_RELOC_CTOR, R_MIPS_32 },
2080 1.1 christos { BFD_RELOC_64, R_MIPS_64 },
2081 1.1 christos { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
2082 1.1 christos { BFD_RELOC_HI16_S, R_MIPS_HI16 },
2083 1.1 christos { BFD_RELOC_LO16, R_MIPS_LO16 },
2084 1.1 christos { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
2085 1.1 christos { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
2086 1.1 christos { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
2087 1.1 christos { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
2088 1.1 christos { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
2089 1.1 christos { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
2090 1.1 christos { BFD_RELOC_MIPS_SHIFT5, R_MIPS_SHIFT5 },
2091 1.1 christos { BFD_RELOC_MIPS_SHIFT6, R_MIPS_SHIFT6 },
2092 1.1 christos { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
2093 1.1 christos { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
2094 1.1 christos { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
2095 1.1 christos { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
2096 1.1 christos { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
2097 1.1 christos { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
2098 1.1 christos { BFD_RELOC_MIPS_INSERT_A, R_MIPS_INSERT_A },
2099 1.1 christos { BFD_RELOC_MIPS_INSERT_B, R_MIPS_INSERT_B },
2100 1.1 christos { BFD_RELOC_MIPS_DELETE, R_MIPS_DELETE },
2101 1.1 christos { BFD_RELOC_MIPS_HIGHEST, R_MIPS_HIGHEST },
2102 1.1 christos { BFD_RELOC_MIPS_HIGHER, R_MIPS_HIGHER },
2103 1.1 christos { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
2104 1.1 christos { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
2105 1.1 christos { BFD_RELOC_MIPS_SCN_DISP, R_MIPS_SCN_DISP },
2106 1.1 christos { BFD_RELOC_MIPS_REL16, R_MIPS_REL16 },
2107 1.1 christos /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated. */
2108 1.1 christos { BFD_RELOC_MIPS_RELGOT, R_MIPS_RELGOT },
2109 1.1 christos { BFD_RELOC_MIPS_JALR, R_MIPS_JALR },
2110 1.1 christos { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
2111 1.1 christos { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
2112 1.1 christos { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
2113 1.1 christos { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 },
2114 1.1 christos { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD },
2115 1.1 christos { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM },
2116 1.1 christos { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 },
2117 1.1 christos { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 },
2118 1.1 christos { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL },
2119 1.1 christos { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 },
2120 1.1 christos { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 },
2121 1.1 christos { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 },
2122 1.1 christos { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 }
2123 1.1 christos };
2124 1.1 christos
2125 1.1 christos static const struct elf_reloc_map mips16_reloc_map[] =
2126 1.1 christos {
2127 1.1 christos { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
2128 1.1 christos { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
2129 1.1 christos { BFD_RELOC_MIPS16_GOT16, R_MIPS16_GOT16 - R_MIPS16_min },
2130 1.1 christos { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min },
2131 1.1 christos { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
2132 1.1 christos { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
2133 1.1 christos };
2134 1.1 christos
2135 1.1 christos /* Given a BFD reloc type, return a howto structure. */
2136 1.1 christos
2137 1.1 christos static reloc_howto_type *
2138 1.1 christos bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
2139 1.1 christos bfd_reloc_code_real_type code)
2140 1.1 christos {
2141 1.1 christos unsigned int i;
2142 1.1 christos /* FIXME: We default to RELA here instead of choosing the right
2143 1.1 christos relocation variant. */
2144 1.1 christos reloc_howto_type *howto_table = elf_mips_howto_table_rela;
2145 1.1 christos reloc_howto_type *howto16_table = elf_mips16_howto_table_rela;
2146 1.1 christos
2147 1.1 christos for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
2148 1.1 christos i++)
2149 1.1 christos {
2150 1.1 christos if (mips_reloc_map[i].bfd_val == code)
2151 1.1 christos return &howto_table[(int) mips_reloc_map[i].elf_val];
2152 1.1 christos }
2153 1.1 christos
2154 1.1 christos for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
2155 1.1 christos i++)
2156 1.1 christos {
2157 1.1 christos if (mips16_reloc_map[i].bfd_val == code)
2158 1.1 christos return &howto16_table[(int) mips16_reloc_map[i].elf_val];
2159 1.1 christos }
2160 1.1 christos
2161 1.1 christos switch (code)
2162 1.1 christos {
2163 1.1 christos case BFD_RELOC_VTABLE_INHERIT:
2164 1.1 christos return &elf_mips_gnu_vtinherit_howto;
2165 1.1 christos case BFD_RELOC_VTABLE_ENTRY:
2166 1.1 christos return &elf_mips_gnu_vtentry_howto;
2167 1.1 christos case BFD_RELOC_MIPS_COPY:
2168 1.1 christos return &elf_mips_copy_howto;
2169 1.1 christos case BFD_RELOC_MIPS_JUMP_SLOT:
2170 1.1 christos return &elf_mips_jump_slot_howto;
2171 1.1 christos default:
2172 1.1 christos bfd_set_error (bfd_error_bad_value);
2173 1.1 christos return NULL;
2174 1.1 christos }
2175 1.1 christos }
2176 1.1 christos
2177 1.1 christos static reloc_howto_type *
2178 1.1 christos bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
2179 1.1 christos const char *r_name)
2180 1.1 christos {
2181 1.1 christos unsigned int i;
2182 1.1 christos
2183 1.1 christos for (i = 0;
2184 1.1 christos i < (sizeof (elf_mips_howto_table_rela)
2185 1.1 christos / sizeof (elf_mips_howto_table_rela[0]));
2186 1.1 christos i++)
2187 1.1 christos if (elf_mips_howto_table_rela[i].name != NULL
2188 1.1 christos && strcasecmp (elf_mips_howto_table_rela[i].name, r_name) == 0)
2189 1.1 christos return &elf_mips_howto_table_rela[i];
2190 1.1 christos
2191 1.1 christos for (i = 0;
2192 1.1 christos i < (sizeof (elf_mips16_howto_table_rela)
2193 1.1 christos / sizeof (elf_mips16_howto_table_rela[0]));
2194 1.1 christos i++)
2195 1.1 christos if (elf_mips16_howto_table_rela[i].name != NULL
2196 1.1 christos && strcasecmp (elf_mips16_howto_table_rela[i].name, r_name) == 0)
2197 1.1 christos return &elf_mips16_howto_table_rela[i];
2198 1.1 christos
2199 1.1 christos if (strcasecmp (elf_mips_gnu_vtinherit_howto.name, r_name) == 0)
2200 1.1 christos return &elf_mips_gnu_vtinherit_howto;
2201 1.1 christos if (strcasecmp (elf_mips_gnu_vtentry_howto.name, r_name) == 0)
2202 1.1 christos return &elf_mips_gnu_vtentry_howto;
2203 1.1 christos if (strcasecmp (elf_mips_gnu_rel16_s2.name, r_name) == 0)
2204 1.1 christos return &elf_mips_gnu_rel16_s2;
2205 1.1 christos if (strcasecmp (elf_mips_gnu_rela16_s2.name, r_name) == 0)
2206 1.1 christos return &elf_mips_gnu_rela16_s2;
2207 1.1 christos if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0)
2208 1.1 christos return &elf_mips_copy_howto;
2209 1.1 christos if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
2210 1.1 christos return &elf_mips_jump_slot_howto;
2211 1.1 christos
2212 1.1 christos return NULL;
2213 1.1 christos }
2214 1.1 christos
2215 1.1 christos /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
2216 1.1 christos
2217 1.1 christos static reloc_howto_type *
2218 1.1 christos mips_elf_n32_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p)
2219 1.1 christos {
2220 1.1 christos switch (r_type)
2221 1.1 christos {
2222 1.1 christos case R_MIPS_GNU_VTINHERIT:
2223 1.1 christos return &elf_mips_gnu_vtinherit_howto;
2224 1.1 christos case R_MIPS_GNU_VTENTRY:
2225 1.1 christos return &elf_mips_gnu_vtentry_howto;
2226 1.1 christos case R_MIPS_GNU_REL16_S2:
2227 1.1 christos if (rela_p)
2228 1.1 christos return &elf_mips_gnu_rela16_s2;
2229 1.1 christos else
2230 1.1 christos return &elf_mips_gnu_rel16_s2;
2231 1.1 christos case R_MIPS_COPY:
2232 1.1 christos return &elf_mips_copy_howto;
2233 1.1 christos case R_MIPS_JUMP_SLOT:
2234 1.1 christos return &elf_mips_jump_slot_howto;
2235 1.1 christos default:
2236 1.1 christos if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
2237 1.1 christos {
2238 1.1 christos if (rela_p)
2239 1.1 christos return &elf_mips16_howto_table_rela[r_type - R_MIPS16_min];
2240 1.1 christos else
2241 1.1 christos return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
2242 1.1 christos }
2243 1.1 christos BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
2244 1.1 christos if (rela_p)
2245 1.1 christos return &elf_mips_howto_table_rela[r_type];
2246 1.1 christos else
2247 1.1 christos return &elf_mips_howto_table_rel[r_type];
2248 1.1 christos break;
2249 1.1 christos }
2250 1.1 christos }
2251 1.1 christos
2252 1.1 christos /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
2253 1.1 christos
2254 1.1 christos static void
2255 1.1 christos mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
2256 1.1 christos {
2257 1.1 christos unsigned int r_type;
2258 1.1 christos
2259 1.1 christos r_type = ELF32_R_TYPE (dst->r_info);
2260 1.1 christos cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, FALSE);
2261 1.1 christos
2262 1.1 christos /* The addend for a GPREL16 or LITERAL relocation comes from the GP
2263 1.1 christos value for the object file. We get the addend now, rather than
2264 1.1 christos when we do the relocation, because the symbol manipulations done
2265 1.1 christos by the linker may cause us to lose track of the input BFD. */
2266 1.1 christos if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
2267 1.1 christos && (gprel16_reloc_p (r_type) || r_type == (unsigned int) R_MIPS_LITERAL))
2268 1.1 christos cache_ptr->addend = elf_gp (abfd);
2269 1.1 christos }
2270 1.1 christos
2271 1.1 christos /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */
2272 1.1 christos
2273 1.1 christos static void
2274 1.1 christos mips_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
2275 1.1 christos arelent *cache_ptr, Elf_Internal_Rela *dst)
2276 1.1 christos {
2277 1.1 christos unsigned int r_type;
2278 1.1 christos
2279 1.1 christos r_type = ELF32_R_TYPE (dst->r_info);
2280 1.1 christos cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, TRUE);
2281 1.1 christos cache_ptr->addend = dst->r_addend;
2282 1.1 christos }
2283 1.1 christos
2284 1.1 christos /* Determine whether a symbol is global for the purposes of splitting
2286 1.1 christos the symbol table into global symbols and local symbols. At least
2287 1.1 christos on Irix 5, this split must be between section symbols and all other
2288 1.1 christos symbols. On most ELF targets the split is between static symbols
2289 1.1 christos and externally visible symbols. */
2290 1.1 christos
2291 1.1 christos static bfd_boolean
2292 1.1 christos mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
2293 1.1 christos {
2294 1.1 christos if (SGI_COMPAT (abfd))
2295 1.1 christos return (sym->flags & BSF_SECTION_SYM) == 0;
2296 1.1 christos else
2297 1.1 christos return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
2298 1.1 christos || bfd_is_und_section (bfd_get_section (sym))
2299 1.1 christos || bfd_is_com_section (bfd_get_section (sym)));
2300 1.1 christos }
2301 1.1 christos
2302 1.1 christos /* Set the right machine number for a MIPS ELF file. */
2304 1.1 christos
2305 1.1 christos static bfd_boolean
2306 1.1 christos mips_elf_n32_object_p (bfd *abfd)
2307 1.1 christos {
2308 1.1 christos unsigned long mach;
2309 1.1 christos
2310 1.1 christos /* Irix 5 and 6 are broken. Object file symbol tables are not always
2311 1.1 christos sorted correctly such that local symbols precede global symbols,
2312 1.1 christos and the sh_info field in the symbol table is not always right. */
2313 1.1 christos if (SGI_COMPAT (abfd))
2314 1.1 christos elf_bad_symtab (abfd) = TRUE;
2315 1.1 christos
2316 1.1 christos mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
2317 1.1 christos bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
2318 1.1 christos
2319 1.1 christos if (! ABI_N32_P(abfd))
2320 1.1 christos return FALSE;
2321 1.1 christos
2322 1.1 christos return TRUE;
2323 1.1 christos }
2324 1.1 christos
2325 1.1 christos /* Support for core dump NOTE sections. */
2327 1.1 christos static bfd_boolean
2328 1.1 christos elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
2329 1.1 christos {
2330 1.1 christos int offset;
2331 1.1 christos unsigned int size;
2332 1.1 christos
2333 1.1 christos switch (note->descsz)
2334 1.1 christos {
2335 1.1 christos default:
2336 1.1 christos return FALSE;
2337 1.1 christos
2338 1.1 christos case 440: /* Linux/MIPS N32 */
2339 1.1 christos /* pr_cursig */
2340 1.1 christos elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
2341 1.1 christos
2342 1.1 christos /* pr_pid */
2343 1.1 christos elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
2344 1.1 christos
2345 1.1 christos /* pr_reg */
2346 1.1 christos offset = 72;
2347 1.1 christos size = 360;
2348 1.1 christos
2349 1.1 christos break;
2350 1.1 christos }
2351 1.1 christos
2352 1.1 christos /* Make a ".reg/999" section. */
2353 1.1 christos return _bfd_elfcore_make_pseudosection (abfd, ".reg", size,
2354 1.1 christos note->descpos + offset);
2355 1.1 christos }
2356 1.1 christos
2357 1.1 christos static bfd_boolean
2358 1.1 christos elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
2359 1.1 christos {
2360 1.1 christos switch (note->descsz)
2361 1.1 christos {
2362 1.1 christos default:
2363 1.1 christos return FALSE;
2364 1.1 christos
2365 1.1 christos case 128: /* Linux/MIPS elf_prpsinfo */
2366 1.1 christos elf_tdata (abfd)->core_program
2367 1.1 christos = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
2368 1.1 christos elf_tdata (abfd)->core_command
2369 1.1 christos = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
2370 1.1 christos }
2371 1.1 christos
2372 1.1 christos /* Note that for some reason, a spurious space is tacked
2373 1.1 christos onto the end of the args in some (at least one anyway)
2374 1.1 christos implementations, so strip it off if it exists. */
2375 1.1 christos
2376 1.1 christos {
2377 1.1 christos char *command = elf_tdata (abfd)->core_command;
2378 1.1 christos int n = strlen (command);
2379 1.1 christos
2380 1.1 christos if (0 < n && command[n - 1] == ' ')
2381 1.1 christos command[n - 1] = '\0';
2382 1.1 christos }
2383 1.1 christos
2384 1.1 christos return TRUE;
2385 1.1 christos }
2386 1.1 christos
2387 1.1 christos /* Depending on the target vector we generate some version of Irix
2389 1.1 christos executables or "normal" MIPS ELF ABI executables. */
2390 1.1 christos static irix_compat_t
2391 1.1 christos elf_n32_mips_irix_compat (bfd *abfd)
2392 1.1 christos {
2393 1.1 christos if ((abfd->xvec == &bfd_elf32_nbigmips_vec)
2394 1.1 christos || (abfd->xvec == &bfd_elf32_nlittlemips_vec))
2395 1.1 christos return ict_irix6;
2396 1.1 christos else
2397 1.1 christos return ict_none;
2398 1.1 christos }
2399 1.1 christos
2400 1.1 christos /* ECOFF swapping routines. These are used when dealing with the
2402 1.1 christos .mdebug section, which is in the ECOFF debugging format. */
2403 1.1 christos static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
2404 1.1 christos /* Symbol table magic number. */
2405 1.1 christos magicSym,
2406 1.1 christos /* Alignment of debugging information. E.g., 4. */
2407 1.1 christos 4,
2408 1.1 christos /* Sizes of external symbolic information. */
2409 1.1 christos sizeof (struct hdr_ext),
2410 1.1 christos sizeof (struct dnr_ext),
2411 1.1 christos sizeof (struct pdr_ext),
2412 1.1 christos sizeof (struct sym_ext),
2413 1.1 christos sizeof (struct opt_ext),
2414 1.1 christos sizeof (struct fdr_ext),
2415 1.1 christos sizeof (struct rfd_ext),
2416 1.1 christos sizeof (struct ext_ext),
2417 1.1 christos /* Functions to swap in external symbolic data. */
2418 1.1 christos ecoff_swap_hdr_in,
2419 1.1 christos ecoff_swap_dnr_in,
2420 1.1 christos ecoff_swap_pdr_in,
2421 1.1 christos ecoff_swap_sym_in,
2422 1.1 christos ecoff_swap_opt_in,
2423 1.1 christos ecoff_swap_fdr_in,
2424 1.1 christos ecoff_swap_rfd_in,
2425 1.1 christos ecoff_swap_ext_in,
2426 1.1 christos _bfd_ecoff_swap_tir_in,
2427 1.1 christos _bfd_ecoff_swap_rndx_in,
2428 1.1 christos /* Functions to swap out external symbolic data. */
2429 1.1 christos ecoff_swap_hdr_out,
2430 1.1 christos ecoff_swap_dnr_out,
2431 1.1 christos ecoff_swap_pdr_out,
2432 1.1 christos ecoff_swap_sym_out,
2433 1.1 christos ecoff_swap_opt_out,
2434 1.1 christos ecoff_swap_fdr_out,
2435 1.1 christos ecoff_swap_rfd_out,
2436 1.1 christos ecoff_swap_ext_out,
2437 1.1 christos _bfd_ecoff_swap_tir_out,
2438 1.1 christos _bfd_ecoff_swap_rndx_out,
2439 1.1 christos /* Function to read in symbolic data. */
2440 1.1 christos _bfd_mips_elf_read_ecoff_info
2441 1.1 christos };
2442 1.1 christos
2443 1.1 christos #define ELF_ARCH bfd_arch_mips
2445 1.1 christos #define ELF_TARGET_ID MIPS_ELF_DATA
2446 1.1 christos #define ELF_MACHINE_CODE EM_MIPS
2447 1.1 christos
2448 1.1 christos #define elf_backend_collect TRUE
2449 1.1 christos #define elf_backend_type_change_ok TRUE
2450 1.1 christos #define elf_backend_can_gc_sections TRUE
2451 1.1 christos #define elf_info_to_howto mips_info_to_howto_rela
2452 1.1 christos #define elf_info_to_howto_rel mips_info_to_howto_rel
2453 1.1 christos #define elf_backend_sym_is_global mips_elf_sym_is_global
2454 1.1 christos #define elf_backend_object_p mips_elf_n32_object_p
2455 1.1 christos #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
2456 1.1 christos #define elf_backend_section_processing _bfd_mips_elf_section_processing
2457 1.1 christos #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
2458 1.1 christos #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
2459 1.1 christos #define elf_backend_section_from_bfd_section \
2460 1.1 christos _bfd_mips_elf_section_from_bfd_section
2461 1.1 christos #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
2462 1.1 christos #define elf_backend_link_output_symbol_hook \
2463 1.1 christos _bfd_mips_elf_link_output_symbol_hook
2464 1.1 christos #define elf_backend_create_dynamic_sections \
2465 1.1 christos _bfd_mips_elf_create_dynamic_sections
2466 1.1 christos #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
2467 1.1 christos #define elf_backend_merge_symbol_attribute \
2468 1.1 christos _bfd_mips_elf_merge_symbol_attribute
2469 1.1 christos #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
2470 1.1 christos #define elf_backend_adjust_dynamic_symbol \
2471 1.1 christos _bfd_mips_elf_adjust_dynamic_symbol
2472 1.1 christos #define elf_backend_always_size_sections \
2473 1.1 christos _bfd_mips_elf_always_size_sections
2474 1.1 christos #define elf_backend_size_dynamic_sections \
2475 1.1 christos _bfd_mips_elf_size_dynamic_sections
2476 1.1 christos #define elf_backend_init_index_section _bfd_elf_init_1_index_section
2477 1.1 christos #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
2478 1.1 christos #define elf_backend_finish_dynamic_symbol \
2479 1.1 christos _bfd_mips_elf_finish_dynamic_symbol
2480 1.1 christos #define elf_backend_finish_dynamic_sections \
2481 1.1 christos _bfd_mips_elf_finish_dynamic_sections
2482 1.1 christos #define elf_backend_final_write_processing \
2483 1.1 christos _bfd_mips_elf_final_write_processing
2484 1.1 christos #define elf_backend_additional_program_headers \
2485 1.1 christos _bfd_mips_elf_additional_program_headers
2486 1.1 christos #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
2487 1.1 christos #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
2488 1.1 christos #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
2489 1.1 christos #define elf_backend_copy_indirect_symbol \
2490 1.1 christos _bfd_mips_elf_copy_indirect_symbol
2491 1.1 christos #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
2492 1.1 christos #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
2493 1.1 christos #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
2494 1.1 christos
2495 1.1 christos #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
2496 1.1 christos
2497 1.1 christos /* MIPS n32 ELF can use a mixture of REL and RELA, but some Relocations
2498 1.1 christos work better/work only in RELA, so we default to this. */
2499 1.1 christos #define elf_backend_may_use_rel_p 1
2500 1.1 christos #define elf_backend_may_use_rela_p 1
2501 1.1 christos #define elf_backend_default_use_rela_p 1
2502 1.1 christos #define elf_backend_rela_plts_and_copies_p 0
2503 1.1 christos #define elf_backend_sign_extend_vma TRUE
2504 1.1 christos #define elf_backend_plt_readonly 1
2505 1.1 christos #define elf_backend_plt_sym_val _bfd_mips_elf_plt_sym_val
2506 1.1 christos
2507 1.1 christos #define elf_backend_discard_info _bfd_mips_elf_discard_info
2508 1.1 christos #define elf_backend_ignore_discarded_relocs \
2509 1.1 christos _bfd_mips_elf_ignore_discarded_relocs
2510 1.1 christos #define elf_backend_write_section _bfd_mips_elf_write_section
2511 1.1 christos #define elf_backend_mips_irix_compat elf_n32_mips_irix_compat
2512 1.1 christos #define elf_backend_mips_rtype_to_howto mips_elf_n32_rtype_to_howto
2513 1.1 christos #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
2514 1.1 christos #define bfd_elf32_find_inliner_info _bfd_mips_elf_find_inliner_info
2515 1.1 christos #define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook
2516 1.1 christos #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
2517 1.1 christos #define bfd_elf32_bfd_get_relocated_section_contents \
2518 1.1 christos _bfd_elf_mips_get_relocated_section_contents
2519 1.1 christos #define bfd_elf32_bfd_link_hash_table_create \
2520 1.1 christos _bfd_mips_elf_link_hash_table_create
2521 1.1 christos #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
2522 1.1 christos #define bfd_elf32_bfd_merge_private_bfd_data \
2523 1.1 christos _bfd_mips_elf_merge_private_bfd_data
2524 1.1 christos #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
2525 1.1 christos #define bfd_elf32_bfd_print_private_bfd_data \
2526 1.1 christos _bfd_mips_elf_print_private_bfd_data
2527 1.1 christos #define bfd_elf32_bfd_relax_section _bfd_mips_relax_section
2528 1.1 christos
2529 1.1 christos /* Support for SGI-ish mips targets using n32 ABI. */
2530 1.1 christos
2531 1.1 christos #define TARGET_LITTLE_SYM bfd_elf32_nlittlemips_vec
2532 1.1 christos #define TARGET_LITTLE_NAME "elf32-nlittlemips"
2533 1.1 christos #define TARGET_BIG_SYM bfd_elf32_nbigmips_vec
2534 1.1 christos #define TARGET_BIG_NAME "elf32-nbigmips"
2535 1.1 christos
2536 1.1 christos #define ELF_MAXPAGESIZE 0x10000
2537 1.1 christos #define ELF_COMMONPAGESIZE 0x1000
2538 1.1 christos
2539 1.1 christos #include "elf32-target.h"
2540 1.1 christos
2541 1.1 christos /* Support for traditional mips targets using n32 ABI. */
2542 1.1 christos #undef TARGET_LITTLE_SYM
2543 1.1 christos #undef TARGET_LITTLE_NAME
2544 1.1 christos #undef TARGET_BIG_SYM
2545 1.1 christos #undef TARGET_BIG_NAME
2546 1.1 christos
2547 1.1 christos #undef ELF_MAXPAGESIZE
2548 1.1 christos #undef ELF_COMMONPAGESIZE
2549 1.1 christos
2550 1.1 christos #define TARGET_LITTLE_SYM bfd_elf32_ntradlittlemips_vec
2551 1.1 christos #define TARGET_LITTLE_NAME "elf32-ntradlittlemips"
2552 1.1 christos #define TARGET_BIG_SYM bfd_elf32_ntradbigmips_vec
2553 1.1 christos #define TARGET_BIG_NAME "elf32-ntradbigmips"
2554 1.1 christos
2555 1.1 christos #define ELF_MAXPAGESIZE 0x10000
2556 1.1 christos #define ELF_COMMONPAGESIZE 0x1000
2557 1.1 christos #define elf32_bed elf32_tradbed
2558 1.1 christos
2559 1.1 christos /* Include the target file again for this target. */
2560 1.1 christos #include "elf32-target.h"
2561 1.1 christos
2562 1.1 christos
2563 1.1 christos /* FreeBSD support. */
2564 1.1 christos
2565 1.1 christos #undef TARGET_LITTLE_SYM
2566 1.1 christos #undef TARGET_LITTLE_NAME
2567 1.1 christos #undef TARGET_BIG_SYM
2568 1.1 christos #undef TARGET_BIG_NAME
2569 1.1 christos
2570 1.1 christos #define TARGET_LITTLE_SYM bfd_elf32_ntradlittlemips_freebsd_vec
2571 1.1 christos #define TARGET_LITTLE_NAME "elf32-ntradlittlemips-freebsd"
2572 1.1 christos #define TARGET_BIG_SYM bfd_elf32_ntradbigmips_freebsd_vec
2573 1.1 christos #define TARGET_BIG_NAME "elf32-ntradbigmips-freebsd"
2574 1.1 christos
2575 1.1 christos #undef ELF_OSABI
2576 1.1 christos #define ELF_OSABI ELFOSABI_FREEBSD
2577 1.1 christos
2578 1.1 christos /* The kernel recognizes executables as valid only if they carry a
2579 1.1 christos "FreeBSD" label in the ELF header. So we put this label on all
2580 1.1 christos executables and (for simplicity) also all other object files. */
2581 1.1 christos
2582 1.1 christos static void
2583 elf_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info)
2584 {
2585 _bfd_elf_set_osabi (abfd, info);
2586 }
2587
2588 #undef elf_backend_post_process_headers
2589 #define elf_backend_post_process_headers elf_fbsd_post_process_headers
2590 #undef elf32_bed
2591 #define elf32_bed elf32_fbsd_tradbed
2592
2593 #include "elf32-target.h"
2594