1 /* LoongArch-specific support for ELF.
2 Copyright (C) 2021-2024 Free Software Foundation, Inc.
3 Contributed by Loongson Ltd.
5 Based on RISC-V target.
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; see the file COPYING3. If not,
21 see <http://www.gnu.org/licenses/>. */
27 #include "elf/loongarch.h"
28 #include "elfxx-loongarch.h"
30 #define ALL_ONES (~ (bfd_vma) 0)
32 typedef struct loongarch_reloc_howto_type_struct
34 /* The first must be reloc_howto_type! */
35 reloc_howto_type howto
;
36 bfd_reloc_code_real_type bfd_type
;
37 bool (*adjust_reloc_bits
)(bfd
*, reloc_howto_type
*, bfd_vma
*);
38 const char *larch_reloc_type_name
;
39 } loongarch_reloc_howto_type
;
41 #define LOONGARCH_DEFAULT_HOWTO(r_name) \
42 { HOWTO (R_LARCH_##r_name, 0, 4, 32, false, 0, complain_overflow_signed, \
43 bfd_elf_generic_reloc, "R_LARCH_" #r_name, false, 0, ALL_ONES, \
44 false), BFD_RELOC_LARCH_##r_name, NULL, NULL }
46 #define LOONGARCH_HOWTO(type, right, size, bits, pcrel, left, ovf, func, \
47 name, inplace, src_mask, dst_mask, pcrel_off, btype, afunc,lname) \
48 { HOWTO(type, right, size, bits, pcrel, left, ovf, func, name, \
49 inplace, src_mask, dst_mask, pcrel_off), btype, afunc, lname }
51 #define LOONGARCH_EMPTY_HOWTO(C) \
52 { EMPTY_HOWTO (C), BFD_RELOC_NONE, NULL, NULL }
55 reloc_bits (bfd
*abfd
, reloc_howto_type
*howto
, bfd_vma
*val
);
57 reloc_sign_bits (bfd
*abfd
, reloc_howto_type
*howto
, bfd_vma
*fix_val
);
59 reloc_unsign_bits (bfd
*abfd
, reloc_howto_type
*howto
, bfd_vma
*fix_val
);
61 static bfd_reloc_status_type
62 loongarch_elf_add_sub_reloc (bfd
*, arelent
*, asymbol
*, void *,
63 asection
*, bfd
*, char **);
65 static bfd_reloc_status_type
66 loongarch_elf_add_sub_reloc_uleb128 (bfd
*, arelent
*, asymbol
*, void *,
67 asection
*, bfd
*, char **);
69 /* This does not include any relocation information, but should be
70 good enough for GDB or objdump to read the file. */
71 static loongarch_reloc_howto_type loongarch_howto_table
[] =
74 LOONGARCH_HOWTO (R_LARCH_NONE
, /* type (0). */
78 false, /* pc_relative */
80 complain_overflow_dont
, /* complain_on_overflow */
81 bfd_elf_generic_reloc
, /* special_function */
82 "R_LARCH_NONE", /* name */
83 false, /* partial_inplace */
86 false, /* pcrel_offset */
87 BFD_RELOC_NONE
, /* bfd_reloc_code_real_type */
88 NULL
, /* adjust_reloc_bits */
89 NULL
), /* larch_reloc_type_name */
91 /* 32 bit relocation. */
92 LOONGARCH_HOWTO (R_LARCH_32
, /* type (1). */
96 false, /* pc_relative */
98 complain_overflow_dont
, /* complain_on_overflow */
99 bfd_elf_generic_reloc
, /* special_function */
100 "R_LARCH_32", /* name */
101 false, /* partial_inplace */
103 ALL_ONES
, /* dst_mask */
104 false, /* pcrel_offset */
105 BFD_RELOC_32
, /* bfd_reloc_code_real_type */
106 NULL
, /* adjust_reloc_bits */
107 NULL
), /* larch_reloc_type_name */
109 /* 64 bit relocation. */
110 LOONGARCH_HOWTO (R_LARCH_64
, /* type (2). */
114 false, /* pc_relative */
116 complain_overflow_dont
, /* complain_on_overflow */
117 bfd_elf_generic_reloc
, /* special_function */
118 "R_LARCH_64", /* name */
119 false, /* partial_inplace */
121 ALL_ONES
, /* dst_mask */
122 false, /* pcrel_offset */
123 BFD_RELOC_64
, /* bfd_reloc_code_real_type */
124 NULL
, /* adjust_reloc_bits */
125 NULL
), /* larch_reloc_type_name */
127 LOONGARCH_HOWTO (R_LARCH_RELATIVE
, /* type (3). */
131 false, /* pc_relative */
133 complain_overflow_dont
, /* complain_on_overflow */
134 bfd_elf_generic_reloc
, /* special_function */
135 "R_LARCH_RELATIVE", /* name */
136 false, /* partial_inplace */
138 ALL_ONES
, /* dst_mask */
139 false, /* pcrel_offset */
140 BFD_RELOC_NONE
, /* undefined? */
141 NULL
, /* adjust_reloc_bits */
142 NULL
), /* larch_reloc_type_name */
144 LOONGARCH_HOWTO (R_LARCH_COPY
, /* type (4). */
146 0, /* this one is variable size */
148 false, /* pc_relative */
150 complain_overflow_bitfield
, /* complain_on_overflow */
151 bfd_elf_generic_reloc
, /* special_function */
152 "R_LARCH_COPY", /* name */
153 false, /* partial_inplace */
156 false, /* pcrel_offset */
157 BFD_RELOC_NONE
, /* undefined? */
158 NULL
, /* adjust_reloc_bits */
159 NULL
), /* larch_reloc_type_name */
161 LOONGARCH_HOWTO (R_LARCH_JUMP_SLOT
, /* type (5). */
165 false, /* pc_relative */
167 complain_overflow_bitfield
, /* complain_on_overflow */
168 bfd_elf_generic_reloc
, /* special_function */
169 "R_LARCH_JUMP_SLOT", /* name */
170 false, /* partial_inplace */
173 false, /* pcrel_offset */
174 BFD_RELOC_NONE
, /* undefined? */
175 NULL
, /* adjust_reloc_bits */
176 NULL
), /* larch_reloc_type_name */
178 /* Dynamic TLS relocations. */
179 LOONGARCH_HOWTO (R_LARCH_TLS_DTPMOD32
, /* type (6). */
183 false, /* pc_relative */
185 complain_overflow_dont
, /* complain_on_overflow */
186 bfd_elf_generic_reloc
, /* special_function */
187 "R_LARCH_TLS_DTPMOD32", /* name */
188 false, /* partial_inplace */
190 ALL_ONES
, /* dst_mask */
191 false, /* pcrel_offset */
192 BFD_RELOC_LARCH_TLS_DTPMOD32
, /* bfd_reloc_code_real_type */
193 NULL
, /* adjust_reloc_bits */
194 NULL
), /* larch_reloc_type_name */
196 LOONGARCH_HOWTO (R_LARCH_TLS_DTPMOD64
, /* type (7). */
200 false, /* pc_relative */
202 complain_overflow_dont
, /* complain_on_overflow */
203 bfd_elf_generic_reloc
, /* special_function */
204 "R_LARCH_TLS_DTPMOD64", /* name */
205 false, /* partial_inplace */
207 ALL_ONES
, /* dst_mask */
208 false, /* pcrel_offset */
209 BFD_RELOC_LARCH_TLS_DTPMOD64
, /* bfd_reloc_code_real_type */
210 NULL
, /* adjust_reloc_bits */
211 NULL
), /* larch_reloc_type_name */
213 LOONGARCH_HOWTO (R_LARCH_TLS_DTPREL32
, /* type (8). */
217 false, /* pc_relative */
219 complain_overflow_dont
, /* complain_on_overflow */
220 bfd_elf_generic_reloc
, /* special_function */
221 "R_LARCH_TLS_DTPREL32", /* name */
222 true, /* partial_inplace */
224 ALL_ONES
, /* dst_mask */
225 false, /* pcrel_offset */
226 BFD_RELOC_LARCH_TLS_DTPREL32
, /* bfd_reloc_code_real_type */
227 NULL
, /* adjust_reloc_bits */
228 NULL
), /* larch_reloc_type_name */
230 LOONGARCH_HOWTO (R_LARCH_TLS_DTPREL64
, /* type (9). */
234 false, /* pc_relative */
236 complain_overflow_dont
, /* complain_on_overflow */
237 bfd_elf_generic_reloc
, /* special_function */
238 "R_LARCH_TLS_DTPREL64", /* name */
239 true, /* partial_inplace */
241 ALL_ONES
, /* dst_mask */
242 false, /* pcrel_offset */
243 BFD_RELOC_LARCH_TLS_DTPREL64
, /* bfd_reloc_code_real_type */
244 NULL
, /* adjust_reloc_bits */
245 NULL
), /* larch_reloc_type_name */
247 LOONGARCH_HOWTO (R_LARCH_TLS_TPREL32
, /* type (10). */
251 false, /* pc_relative */
253 complain_overflow_dont
, /* complain_on_overflow */
254 bfd_elf_generic_reloc
, /* special_function */
255 "R_LARCH_TLS_TPREL32", /* name */
256 false, /* partial_inplace */
258 ALL_ONES
, /* dst_mask */
259 false, /* pcrel_offset */
260 BFD_RELOC_LARCH_TLS_TPREL32
, /* bfd_reloc_code_real_type */
261 NULL
, /* adjust_reloc_bits */
262 NULL
), /* larch_reloc_type_name */
264 LOONGARCH_HOWTO (R_LARCH_TLS_TPREL64
, /* type (11). */
268 false, /* pc_relative */
270 complain_overflow_dont
, /* complain_on_overflow */
271 bfd_elf_generic_reloc
, /* special_function */
272 "R_LARCH_TLS_TPREL64", /* name */
273 false, /* partial_inplace */
275 ALL_ONES
, /* dst_mask */
276 false, /* pcrel_offset */
277 BFD_RELOC_LARCH_TLS_TPREL64
, /* bfd_reloc_code_real_type */
278 NULL
, /* adjust_reloc_bits */
279 NULL
), /* larch_reloc_type_name */
281 LOONGARCH_HOWTO (R_LARCH_IRELATIVE
, /* type (12). */
285 false, /* pc_relative */
287 complain_overflow_dont
, /* complain_on_overflow */
288 bfd_elf_generic_reloc
, /* special_function */
289 "R_LARCH_IRELATIVE", /* name */
290 false, /* partial_inplace */
292 ALL_ONES
, /* dst_mask */
293 false, /* pcrel_offset */
294 BFD_RELOC_NONE
, /* undefined? */
295 NULL
, /* adjust_reloc_bits */
296 NULL
), /* larch_reloc_type_name */
298 LOONGARCH_HOWTO (R_LARCH_TLS_DESC32
, /* type (13). */
302 false, /* pc_relative. */
304 complain_overflow_dont
, /* complain_on_overflow. */
305 bfd_elf_generic_reloc
, /* special_function. */
306 "R_LARCH_TLS_DESC32", /* name. */
307 false, /* partial_inplace. */
309 ALL_ONES
, /* dst_mask. */
310 false, /* pcrel_offset. */
311 BFD_RELOC_LARCH_TLS_DESC32
, /* bfd_reloc_code_real_type. */
312 NULL
, /* adjust_reloc_bits. */
313 NULL
), /* larch_reloc_type_name. */
315 LOONGARCH_HOWTO (R_LARCH_TLS_DESC64
, /* type (14). */
319 false, /* pc_relative. */
321 complain_overflow_dont
, /* complain_on_overflow. */
322 bfd_elf_generic_reloc
, /* special_function. */
323 "R_LARCH_TLS_DESC64", /* name. */
324 false, /* partial_inplace. */
326 ALL_ONES
, /* dst_mask. */
327 false, /* pcrel_offset. */
328 BFD_RELOC_LARCH_TLS_DESC64
, /* bfd_reloc_code_real_type. */
329 NULL
, /* adjust_reloc_bits. */
330 NULL
), /* larch_reloc_type_name. */
332 LOONGARCH_EMPTY_HOWTO (15),
333 LOONGARCH_EMPTY_HOWTO (16),
334 LOONGARCH_EMPTY_HOWTO (17),
335 LOONGARCH_EMPTY_HOWTO (18),
336 LOONGARCH_EMPTY_HOWTO (19),
338 LOONGARCH_HOWTO (R_LARCH_MARK_LA
, /* type (20). */
342 false, /* pc_relative. */
344 complain_overflow_signed
, /* complain_on_overflow. */
345 bfd_elf_generic_reloc
, /* special_function. */
346 "R_LARCH_MARK_LA", /* name. */
347 false, /* partial_inplace. */
350 false, /* pcrel_offset */
351 BFD_RELOC_LARCH_MARK_LA
, /* bfd_reloc_code_real_type */
352 NULL
, /* adjust_reloc_bits */
353 NULL
), /* larch_reloc_type_name */
355 LOONGARCH_HOWTO (R_LARCH_MARK_PCREL
, /* type (21). */
359 false, /* pc_relative. */
361 complain_overflow_signed
, /* complain_on_overflow. */
362 bfd_elf_generic_reloc
, /* special_function. */
363 "R_LARCH_MARK_PCREL", /* name. */
364 false, /* partial_inplace. */
367 false, /* pcrel_offset */
368 BFD_RELOC_LARCH_MARK_PCREL
, /* bfd_reloc_code_real_type */
369 NULL
, /* adjust_reloc_bits */
370 NULL
), /* larch_reloc_type_name */
372 LOONGARCH_HOWTO (R_LARCH_SOP_PUSH_PCREL
, /* type (22). */
376 true /* FIXME: somewhat use this. */, /* pc_relative. */
378 complain_overflow_signed
, /* complain_on_overflow. */
379 bfd_elf_generic_reloc
, /* special_function. */
380 "R_LARCH_SOP_PUSH_PCREL", /* name. */
381 false, /* partial_inplace. */
382 0x03ffffff, /* src_mask. */
383 0x03ffffff, /* dst_mask. */
384 false, /* pcrel_offset */
385 BFD_RELOC_LARCH_SOP_PUSH_PCREL
, /* bfd_reloc_code_real_type */
386 NULL
, /* adjust_reloc_bits */
387 NULL
), /* larch_reloc_type_name */
390 LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_ABSOLUTE
),
391 LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_DUP
),
392 LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_GPREL
),
393 LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_TLS_TPREL
),
394 LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_TLS_GOT
),
395 LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_TLS_GD
),
396 LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_PLT_PCREL
),
397 LOONGARCH_DEFAULT_HOWTO (SOP_ASSERT
),
398 LOONGARCH_DEFAULT_HOWTO (SOP_NOT
),
399 LOONGARCH_DEFAULT_HOWTO (SOP_SUB
),
400 LOONGARCH_DEFAULT_HOWTO (SOP_SL
),
401 LOONGARCH_DEFAULT_HOWTO (SOP_SR
),
402 LOONGARCH_DEFAULT_HOWTO (SOP_ADD
),
403 LOONGARCH_DEFAULT_HOWTO (SOP_AND
),
404 LOONGARCH_DEFAULT_HOWTO (SOP_IF_ELSE
),
406 LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_10_5
, /* type (38). */
410 false, /* pc_relative. */
412 complain_overflow_signed
, /* complain_on_overflow. */
413 bfd_elf_generic_reloc
, /* special_function. */
414 "R_LARCH_SOP_POP_32_S_10_5", /* name. */
415 false, /* partial_inplace. */
417 0x7c00, /* dst_mask */
418 false, /* pcrel_offset */
419 BFD_RELOC_LARCH_SOP_POP_32_S_10_5
, /* bfd_reloc_code_real_type */
420 reloc_sign_bits
, /* adjust_reloc_bits */
421 NULL
), /* larch_reloc_type_name */
423 LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_U_10_12
, /* type (39). */
427 false, /* pc_relative. */
429 complain_overflow_unsigned
, /* complain_on_overflow. */
430 bfd_elf_generic_reloc
, /* special_function. */
431 "R_LARCH_SOP_POP_32_U_10_12", /* name. */
432 false, /* partial_inplace. */
434 0x3ffc00, /* dst_mask */
435 false, /* pcrel_offset */
436 BFD_RELOC_LARCH_SOP_POP_32_U_10_12
, /* bfd_reloc_code_real_type */
437 reloc_unsign_bits
, /* adjust_reloc_bits */
438 NULL
), /* larch_reloc_type_name */
440 LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_10_12
, /* type (40). */
444 false, /* pc_relative. */
446 complain_overflow_signed
, /* complain_on_overflow. */
447 bfd_elf_generic_reloc
, /* special_function. */
448 "R_LARCH_SOP_POP_32_S_10_12", /* name. */
449 false, /* partial_inplace. */
451 0x3ffc00, /* dst_mask */
452 false, /* pcrel_offset */
453 BFD_RELOC_LARCH_SOP_POP_32_S_10_12
, /* bfd_reloc_code_real_type */
454 reloc_sign_bits
, /* adjust_reloc_bits */
455 NULL
), /* larch_reloc_type_name */
457 LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_10_16
, /* type (41). */
461 false, /* pc_relative. */
463 complain_overflow_signed
, /* complain_on_overflow. */
464 bfd_elf_generic_reloc
, /* special_function. */
465 "R_LARCH_SOP_POP_32_S_10_16", /* name. */
466 false, /* partial_inplace. */
468 0x3fffc00, /* dst_mask */
469 false, /* pcrel_offset */
470 BFD_RELOC_LARCH_SOP_POP_32_S_10_16
, /* bfd_reloc_code_real_type */
471 reloc_sign_bits
, /* adjust_reloc_bits */
472 NULL
), /* larch_reloc_type_name */
474 LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_10_16_S2
, /* type (42). */
478 false, /* pc_relative. */
480 complain_overflow_signed
, /* complain_on_overflow. */
481 bfd_elf_generic_reloc
, /* special_function. */
482 "R_LARCH_SOP_POP_32_S_10_16_S2", /* name. */
483 false, /* partial_inplace. */
485 0x3fffc00, /* dst_mask */
486 false, /* pcrel_offset */
487 BFD_RELOC_LARCH_SOP_POP_32_S_10_16_S2
, /* bfd_reloc_code_real_type */
488 reloc_sign_bits
, /* adjust_reloc_bits */
489 NULL
), /* larch_reloc_type_name */
491 LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_5_20
, /* type (43). */
495 false, /* pc_relative. */
497 complain_overflow_signed
, /* complain_on_overflow. */
498 bfd_elf_generic_reloc
, /* special_function. */
499 "R_LARCH_SOP_POP_32_S_5_20", /* name. */
500 false, /* partial_inplace. */
502 0x1ffffe0, /* dst_mask */
503 false, /* pcrel_offset */
504 BFD_RELOC_LARCH_SOP_POP_32_S_5_20
, /* bfd_reloc_code_real_type */
505 reloc_sign_bits
, /* adjust_reloc_bits */
506 NULL
), /* larch_reloc_type_name */
508 LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_0_5_10_16_S2
,
513 false, /* pc_relative. */
515 complain_overflow_signed
, /* complain_on_overflow. */
516 bfd_elf_generic_reloc
, /* special_function. */
517 "R_LARCH_SOP_POP_32_S_0_5_10_16_S2", /* name. */
518 false, /* partial_inplace. */
520 0x03fffc1f, /* dst_mask */
521 false, /* pcrel_offset */
522 BFD_RELOC_LARCH_SOP_POP_32_S_0_5_10_16_S2
,
523 /* bfd_reloc_code_real_type */
524 reloc_sign_bits
, /* adjust_reloc_bits */
525 NULL
), /* larch_reloc_type_name */
527 LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_0_10_10_16_S2
, /* type (45). */
531 false, /* pc_relative. */
533 complain_overflow_signed
, /* complain_on_overflow. */
534 bfd_elf_generic_reloc
, /* special_function. */
535 "R_LARCH_SOP_POP_32_S_0_10_10_16_S2", /* name. */
536 false, /* partial_inplace. */
538 0x03ffffff, /* dst_mask */
539 false, /* pcrel_offset */
540 BFD_RELOC_LARCH_SOP_POP_32_S_0_10_10_16_S2
,
541 /* bfd_reloc_code_real_type */
542 reloc_sign_bits
, /* adjust_reloc_bits */
543 NULL
), /* larch_reloc_type_name */
545 LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_U
, /* type (46). */
549 false, /* pc_relative. */
551 complain_overflow_unsigned
, /* complain_on_overflow. */
552 bfd_elf_generic_reloc
, /* special_function. */
553 "R_LARCH_SOP_POP_32_U", /* name. */
554 false, /* partial_inplace. */
555 0xffffffff00000000, /* src_mask */
556 0x00000000ffffffff, /* dst_mask */
557 false, /* pcrel_offset */
558 BFD_RELOC_LARCH_SOP_POP_32_U
, /* bfd_reloc_code_real_type */
559 reloc_unsign_bits
, /* adjust_reloc_bits */
560 NULL
), /* larch_reloc_type_name */
562 /* 8-bit in-place addition, for local label subtraction. */
563 LOONGARCH_HOWTO (R_LARCH_ADD8
, /* type (47). */
567 false, /* pc_relative. */
569 complain_overflow_dont
, /* complain_on_overflow. */
570 loongarch_elf_add_sub_reloc
, /* special_function. */
571 "R_LARCH_ADD8", /* name. */
572 false, /* partial_inplace. */
574 0xff, /* dst_mask. */
575 false, /* pcrel_offset. */
576 BFD_RELOC_LARCH_ADD8
, /* bfd_reloc_code_real_type. */
577 NULL
, /* adjust_reloc_bits. */
578 NULL
), /* larch_reloc_type_name. */
580 /* 16-bit in-place addition, for local label subtraction. */
581 LOONGARCH_HOWTO (R_LARCH_ADD16
, /* type (48). */
585 false, /* pc_relative. */
587 complain_overflow_dont
, /* complain_on_overflow. */
588 loongarch_elf_add_sub_reloc
, /* special_function. */
589 "R_LARCH_ADD16", /* name. */
590 false, /* partial_inplace. */
592 0xffff, /* dst_mask. */
593 false, /* pcrel_offset. */
594 BFD_RELOC_LARCH_ADD16
, /* bfd_reloc_code_real_type. */
595 NULL
, /* adjust_reloc_bits. */
596 NULL
), /* larch_reloc_type_name. */
598 /* 24-bit in-place addition, for local label subtraction. */
599 LOONGARCH_HOWTO (R_LARCH_ADD24
, /* type (49). */
603 false, /* pc_relative. */
605 complain_overflow_dont
, /* complain_on_overflow. */
606 loongarch_elf_add_sub_reloc
, /* special_function. */
607 "R_LARCH_ADD24", /* name. */
608 false, /* partial_inplace. */
610 0xffffff, /* dst_mask. */
611 false, /* pcrel_offset. */
612 BFD_RELOC_LARCH_ADD24
, /* bfd_reloc_code_real_type. */
613 NULL
, /* adjust_reloc_bits. */
614 NULL
), /* larch_reloc_type_name. */
616 /* 32-bit in-place addition, for local label subtraction. */
617 LOONGARCH_HOWTO (R_LARCH_ADD32
, /* type (50). */
621 false, /* pc_relative. */
623 complain_overflow_dont
, /* complain_on_overflow. */
624 loongarch_elf_add_sub_reloc
, /* special_function. */
625 "R_LARCH_ADD32", /* name. */
626 false, /* partial_inplace. */
628 0xffffffff, /* dst_mask. */
629 false, /* pcrel_offset. */
630 BFD_RELOC_LARCH_ADD32
, /* bfd_reloc_code_real_type. */
631 NULL
, /* adjust_reloc_bits. */
632 NULL
), /* larch_reloc_type_name. */
634 /* 64-bit in-place addition, for local label subtraction. */
635 LOONGARCH_HOWTO (R_LARCH_ADD64
, /* type (51). */
639 false, /* pc_relative. */
641 complain_overflow_dont
, /* complain_on_overflow. */
642 loongarch_elf_add_sub_reloc
, /* special_function. */
643 "R_LARCH_ADD64", /* name. */
644 false, /* partial_inplace. */
646 ALL_ONES
, /* dst_mask. */
647 false, /* pcrel_offset. */
648 BFD_RELOC_LARCH_ADD64
, /* bfd_reloc_code_real_type. */
649 NULL
, /* adjust_reloc_bits. */
650 NULL
), /* larch_reloc_type_name. */
652 /* 8-bit in-place subtraction, for local label subtraction. */
653 LOONGARCH_HOWTO (R_LARCH_SUB8
, /* type (52). */
657 false, /* pc_relative. */
659 complain_overflow_dont
, /* complain_on_overflow. */
660 loongarch_elf_add_sub_reloc
, /* special_function. */
661 "R_LARCH_SUB8", /* name. */
662 false, /* partial_inplace. */
664 0xff, /* dst_mask. */
665 false, /* pcrel_offset. */
666 BFD_RELOC_LARCH_SUB8
, /* bfd_reloc_code_real_type. */
667 NULL
, /* adjust_reloc_bits. */
668 NULL
), /* larch_reloc_type_name. */
670 /* 16-bit in-place subtraction, for local label subtraction. */
671 LOONGARCH_HOWTO (R_LARCH_SUB16
, /* type (53). */
675 false, /* pc_relative. */
677 complain_overflow_dont
, /* complain_on_overflow. */
678 loongarch_elf_add_sub_reloc
, /* special_function. */
679 "R_LARCH_SUB16", /* name. */
680 false, /* partial_inplace. */
682 0xffff, /* dst_mask. */
683 false, /* pcrel_offset. */
684 BFD_RELOC_LARCH_SUB16
, /* bfd_reloc_code_real_type. */
685 NULL
, /* adjust_reloc_bits. */
686 NULL
), /* larch_reloc_type_name. */
688 /* 24-bit in-place subtraction, for local label subtraction. */
689 LOONGARCH_HOWTO (R_LARCH_SUB24
, /* type (54). */
693 false, /* pc_relative. */
695 complain_overflow_dont
, /* complain_on_overflow. */
696 loongarch_elf_add_sub_reloc
, /* special_function. */
697 "R_LARCH_SUB24", /* name. */
698 false, /* partial_inplace. */
700 0xffffff, /* dst_mask. */
701 false, /* pcrel_offset. */
702 BFD_RELOC_LARCH_SUB24
, /* bfd_reloc_code_real_type. */
703 NULL
, /* adjust_reloc_bits. */
704 NULL
), /* larch_reloc_type_name. */
706 /* 32-bit in-place subtraction, for local label subtraction. */
707 LOONGARCH_HOWTO (R_LARCH_SUB32
, /* type (55). */
711 false, /* pc_relative. */
713 complain_overflow_dont
, /* complain_on_overflow. */
714 loongarch_elf_add_sub_reloc
, /* special_function. */
715 "R_LARCH_SUB32", /* name. */
716 false, /* partial_inplace. */
718 0xffffffff, /* dst_mask. */
719 false, /* pcrel_offset. */
720 BFD_RELOC_LARCH_SUB32
, /* bfd_reloc_code_real_type. */
721 NULL
, /* adjust_reloc_bits. */
722 NULL
), /* larch_reloc_type_name. */
724 /* 64-bit in-place subtraction, for local label subtraction. */
725 LOONGARCH_HOWTO (R_LARCH_SUB64
, /* type (56). */
729 false, /* pc_relative. */
731 complain_overflow_dont
, /* complain_on_overflow. */
732 loongarch_elf_add_sub_reloc
, /* special_function. */
733 "R_LARCH_SUB64", /* name. */
734 false, /* partial_inplace. */
736 ALL_ONES
, /* dst_mask. */
737 false, /* pcrel_offset. */
738 BFD_RELOC_LARCH_SUB64
, /* bfd_reloc_code_real_type. */
739 NULL
, /* adjust_reloc_bits. */
740 NULL
), /* larch_reloc_type_name. */
742 LOONGARCH_HOWTO (R_LARCH_GNU_VTINHERIT
, /* type (57). */
746 false, /* pc_relative. */
748 complain_overflow_signed
, /* complain_on_overflow. */
749 bfd_elf_generic_reloc
, /* special_function. */
750 "R_LARCH_GNU_VTINHERIT", /* name. */
751 false, /* partial_inplace. */
754 false, /* pcrel_offset */
755 BFD_RELOC_NONE
, /* bfd_reloc_code_real_type */
756 NULL
, /* adjust_reloc_bits */
757 NULL
), /* larch_reloc_type_name */
759 LOONGARCH_HOWTO (R_LARCH_GNU_VTENTRY
, /* type (58). */
763 false, /* pc_relative. */
765 complain_overflow_signed
, /* complain_on_overflow. */
766 NULL
, /* special_function. */
767 "R_LARCH_GNU_VTENTRY", /* name. */
768 false, /* partial_inplace. */
771 false, /* pcrel_offset */
772 BFD_RELOC_NONE
, /* bfd_reloc_code_real_type */
773 NULL
, /* adjust_reloc_bits */
774 NULL
), /* larch_reloc_type_name */
776 LOONGARCH_EMPTY_HOWTO (59),
777 LOONGARCH_EMPTY_HOWTO (60),
778 LOONGARCH_EMPTY_HOWTO (61),
779 LOONGARCH_EMPTY_HOWTO (62),
780 LOONGARCH_EMPTY_HOWTO (63),
782 /* New reloc types. */
783 LOONGARCH_HOWTO (R_LARCH_B16
, /* type (64). */
787 false, /* pc_relative. */
789 complain_overflow_signed
, /* complain_on_overflow. */
790 bfd_elf_generic_reloc
, /* special_function. */
791 "R_LARCH_B16", /* name. */
792 false, /* partial_inplace. */
794 0x3fffc00, /* dst_mask. */
795 false, /* pcrel_offset. */
796 BFD_RELOC_LARCH_B16
, /* bfd_reloc_code_real_type. */
797 reloc_sign_bits
, /* adjust_reloc_bits. */
798 "b16"), /* larch_reloc_type_name. */
800 LOONGARCH_HOWTO (R_LARCH_B21
, /* type (65). */
804 false, /* pc_relative. */
806 complain_overflow_signed
, /* complain_on_overflow. */
807 bfd_elf_generic_reloc
, /* special_function. */
808 "R_LARCH_B21", /* name. */
809 false, /* partial_inplace. */
811 0x3fffc1f, /* dst_mask. */
812 false, /* pcrel_offset. */
813 BFD_RELOC_LARCH_B21
, /* bfd_reloc_code_real_type. */
814 reloc_sign_bits
, /* adjust_reloc_bits. */
815 "b21"), /* larch_reloc_type_name. */
817 LOONGARCH_HOWTO (R_LARCH_B26
, /* type (66). */
821 false, /* pc_relative. */
823 complain_overflow_signed
, /* complain_on_overflow. */
824 bfd_elf_generic_reloc
, /* special_function. */
825 "R_LARCH_B26", /* name. */
826 false, /* partial_inplace. */
828 0x03ffffff, /* dst_mask. */
829 false, /* pcrel_offset. */
830 BFD_RELOC_LARCH_B26
, /* bfd_reloc_code_real_type. */
831 reloc_sign_bits
, /* adjust_reloc_bits. */
832 "b26"), /* larch_reloc_type_name. */
834 LOONGARCH_HOWTO (R_LARCH_ABS_HI20
, /* type (67). */
835 12, /* rightshift. */
838 false, /* pc_relative. */
840 complain_overflow_signed
, /* complain_on_overflow. */
841 bfd_elf_generic_reloc
, /* special_function. */
842 "R_LARCH_ABS_HI20", /* name. */
843 false, /* partial_inplace. */
845 0x1ffffe0, /* dst_mask */
846 false, /* pcrel_offset */
847 BFD_RELOC_LARCH_ABS_HI20
, /* bfd_reloc_code_real_type */
848 reloc_bits
, /* adjust_reloc_bits */
849 "abs_hi20"), /* larch_reloc_type_name */
851 LOONGARCH_HOWTO (R_LARCH_ABS_LO12
, /* type (68). */
855 false, /* pc_relative. */
857 complain_overflow_unsigned
, /* complain_on_overflow. */
858 bfd_elf_generic_reloc
, /* special_function. */
859 "R_LARCH_ABS_LO12", /* name. */
860 false, /* partial_inplace. */
862 0x3ffc00, /* dst_mask */
863 false, /* pcrel_offset */
864 BFD_RELOC_LARCH_ABS_LO12
, /* bfd_reloc_code_real_type */
865 reloc_bits
, /* adjust_reloc_bits */
866 "abs_lo12"), /* larch_reloc_type_name */
868 LOONGARCH_HOWTO (R_LARCH_ABS64_LO20
, /* type (69). */
869 32, /* rightshift. */
872 false, /* pc_relative. */
874 complain_overflow_signed
, /* complain_on_overflow. */
875 bfd_elf_generic_reloc
, /* special_function. */
876 "R_LARCH_ABS64_LO20", /* name. */
877 false, /* partial_inplace. */
879 0x1ffffe0, /* dst_mask */
880 false, /* pcrel_offset */
881 BFD_RELOC_LARCH_ABS64_LO20
, /* bfd_reloc_code_real_type */
882 reloc_bits
, /* adjust_reloc_bits */
883 "abs64_lo20"), /* larch_reloc_type_name */
885 LOONGARCH_HOWTO (R_LARCH_ABS64_HI12
, /* type (70). */
886 52, /* rightshift. */
889 false, /* pc_relative. */
891 complain_overflow_signed
, /* complain_on_overflow. */
892 bfd_elf_generic_reloc
, /* special_function. */
893 "R_LARCH_ABS64_HI12", /* name. */
894 false, /* partial_inplace. */
896 0x3ffc00, /* dst_mask */
897 false, /* pcrel_offset */
898 BFD_RELOC_LARCH_ABS64_HI12
, /* bfd_reloc_code_real_type */
899 reloc_bits
, /* adjust_reloc_bits */
900 "abs64_hi12"), /* larch_reloc_type_name */
902 LOONGARCH_HOWTO (R_LARCH_PCALA_HI20
, /* type (71). */
903 12, /* rightshift. */
906 false, /* pc_relative. */
908 complain_overflow_signed
, /* complain_on_overflow. */
909 bfd_elf_generic_reloc
, /* special_function. */
910 "R_LARCH_PCALA_HI20", /* name. */
911 false, /* partial_inplace. */
913 0x1ffffe0, /* dst_mask */
914 false, /* pcrel_offset */
915 BFD_RELOC_LARCH_PCALA_HI20
, /* bfd_reloc_code_real_type */
916 reloc_bits
, /* adjust_reloc_bits */
917 "pc_hi20"), /* larch_reloc_type_name */
919 LOONGARCH_HOWTO (R_LARCH_PCALA_LO12
, /* type (72). */
923 false, /* pc_relative. */
925 complain_overflow_signed
, /* complain_on_overflow. */
926 bfd_elf_generic_reloc
, /* special_function. */
927 "R_LARCH_PCALA_LO12", /* name. */
928 false, /* partial_inplace. */
930 0x3ffc00, /* dst_mask */
931 false, /* pcrel_offset */
932 BFD_RELOC_LARCH_PCALA_LO12
, /* bfd_reloc_code_real_type */
933 reloc_bits
, /* adjust_reloc_bits */
934 "pc_lo12"), /* larch_reloc_type_name */
936 LOONGARCH_HOWTO (R_LARCH_PCALA64_LO20
, /* type (73). */
937 32, /* rightshift. */
940 false, /* pc_relative. */
942 complain_overflow_signed
, /* complain_on_overflow. */
943 bfd_elf_generic_reloc
, /* special_function. */
944 "R_LARCH_PCALA64_LO20", /* name. */
945 false, /* partial_inplace. */
947 0x1ffffe0, /* dst_mask */
948 false, /* pcrel_offset */
949 BFD_RELOC_LARCH_PCALA64_LO20
, /* bfd_reloc_code_real_type */
950 reloc_bits
, /* adjust_reloc_bits */
951 "pc64_lo20"), /* larch_reloc_type_name */
953 LOONGARCH_HOWTO (R_LARCH_PCALA64_HI12
, /* type (74). */
954 52, /* rightshift. */
957 false, /* pc_relative. */
959 complain_overflow_signed
, /* complain_on_overflow. */
960 bfd_elf_generic_reloc
, /* special_function. */
961 "R_LARCH_PCALA64_HI12", /* name. */
962 false, /* partial_inplace. */
964 0x3ffc00, /* dst_mask */
965 false, /* pcrel_offset */
966 BFD_RELOC_LARCH_PCALA64_HI12
, /* bfd_reloc_code_real_type */
967 reloc_bits
, /* adjust_reloc_bits */
968 "pc64_hi12"), /* larch_reloc_type_name */
970 LOONGARCH_HOWTO (R_LARCH_GOT_PC_HI20
, /* type (75). */
971 12, /* rightshift. */
974 false, /* pc_relative. */
976 complain_overflow_signed
, /* complain_on_overflow. */
977 bfd_elf_generic_reloc
, /* special_function. */
978 "R_LARCH_GOT_PC_HI20", /* name. */
979 false, /* partial_inplace. */
981 0x1ffffe0, /* dst_mask */
982 false, /* pcrel_offset */
983 BFD_RELOC_LARCH_GOT_PC_HI20
, /* bfd_reloc_code_real_type */
984 reloc_bits
, /* adjust_reloc_bits */
985 "got_pc_hi20"), /* larch_reloc_type_name */
987 LOONGARCH_HOWTO (R_LARCH_GOT_PC_LO12
, /* type (76). */
991 false, /* pc_relative. */
993 complain_overflow_signed
, /* complain_on_overflow. */
994 bfd_elf_generic_reloc
, /* special_function. */
995 "R_LARCH_GOT_PC_LO12", /* name. */
996 false, /* partial_inplace. */
998 0x3ffc00, /* dst_mask */
999 false, /* pcrel_offset */
1000 BFD_RELOC_LARCH_GOT_PC_LO12
, /* bfd_reloc_code_real_type */
1001 reloc_bits
, /* adjust_reloc_bits */
1002 "got_pc_lo12"), /* larch_reloc_type_name */
1004 LOONGARCH_HOWTO (R_LARCH_GOT64_PC_LO20
, /* type (77). */
1005 32, /* rightshift. */
1008 false, /* pc_relative. */
1010 complain_overflow_signed
, /* complain_on_overflow. */
1011 bfd_elf_generic_reloc
, /* special_function. */
1012 "R_LARCH_GOT64_PC_LO20", /* name. */
1013 false, /* partial_inplace. */
1015 0x1ffffe0, /* dst_mask */
1016 false, /* pcrel_offset */
1017 BFD_RELOC_LARCH_GOT64_PC_LO20
, /* bfd_reloc_code_real_type */
1018 reloc_bits
, /* adjust_reloc_bits */
1019 "got64_pc_lo20"), /* larch_reloc_type_name */
1021 LOONGARCH_HOWTO (R_LARCH_GOT64_PC_HI12
, /* type (78). */
1022 52, /* rightshift. */
1025 false, /* pc_relative. */
1027 complain_overflow_signed
, /* complain_on_overflow. */
1028 bfd_elf_generic_reloc
, /* special_function. */
1029 "R_LARCH_GOT64_PC_HI12", /* name. */
1030 false, /* partial_inplace. */
1032 0x3ffc00, /* dst_mask */
1033 false, /* pcrel_offset */
1034 BFD_RELOC_LARCH_GOT64_PC_HI12
, /* bfd_reloc_code_real_type */
1035 reloc_bits
, /* adjust_reloc_bits */
1036 "got64_pc_hi12"), /* larch_reloc_type_name */
1038 LOONGARCH_HOWTO (R_LARCH_GOT_HI20
, /* type (79). */
1039 12, /* rightshift. */
1042 false, /* pc_relative. */
1044 complain_overflow_signed
, /* complain_on_overflow. */
1045 bfd_elf_generic_reloc
, /* special_function. */
1046 "R_LARCH_GOT_HI20", /* name. */
1047 false, /* partial_inplace. */
1049 0x1ffffe0, /* dst_mask */
1050 false, /* pcrel_offset */
1051 BFD_RELOC_LARCH_GOT_HI20
, /* bfd_reloc_code_real_type */
1052 reloc_bits
, /* adjust_reloc_bits */
1053 "got_hi20"), /* larch_reloc_type_name */
1055 LOONGARCH_HOWTO (R_LARCH_GOT_LO12
, /* type (80). */
1056 0, /* rightshift. */
1059 false, /* pc_relative. */
1061 complain_overflow_signed
, /* complain_on_overflow. */
1062 bfd_elf_generic_reloc
, /* special_function. */
1063 "R_LARCH_GOT_LO12", /* name. */
1064 false, /* partial_inplace. */
1066 0x3ffc00, /* dst_mask */
1067 false, /* pcrel_offset */
1068 BFD_RELOC_LARCH_GOT_LO12
, /* bfd_reloc_code_real_type */
1069 reloc_bits
, /* adjust_reloc_bits */
1070 "got_lo12"), /* larch_reloc_type_name */
1072 LOONGARCH_HOWTO (R_LARCH_GOT64_LO20
, /* type (81). */
1073 32, /* rightshift. */
1076 false, /* pc_relative. */
1078 complain_overflow_signed
, /* complain_on_overflow. */
1079 bfd_elf_generic_reloc
, /* special_function. */
1080 "R_LARCH_GOT64_LO20", /* name. */
1081 false, /* partial_inplace. */
1083 0x1ffffe0, /* dst_mask */
1084 false, /* pcrel_offset */
1085 BFD_RELOC_LARCH_GOT64_LO20
, /* bfd_reloc_code_real_type */
1086 reloc_bits
, /* adjust_reloc_bits */
1087 "got64_lo20"), /* larch_reloc_type_name */
1089 LOONGARCH_HOWTO (R_LARCH_GOT64_HI12
, /* type (82). */
1090 52, /* rightshift. */
1093 false, /* pc_relative. */
1095 complain_overflow_signed
, /* complain_on_overflow. */
1096 bfd_elf_generic_reloc
, /* special_function. */
1097 "R_LARCH_GOT64_HI12", /* name. */
1098 false, /* partial_inplace. */
1100 0x3ffc00, /* dst_mask */
1101 false, /* pcrel_offset */
1102 BFD_RELOC_LARCH_GOT64_HI12
, /* bfd_reloc_code_real_type */
1103 reloc_bits
, /* adjust_reloc_bits */
1104 "got64_hi12"), /* larch_reloc_type_name */
1106 LOONGARCH_HOWTO (R_LARCH_TLS_LE_HI20
, /* type (83). */
1107 12, /* rightshift. */
1110 false, /* pc_relative. */
1112 complain_overflow_signed
, /* complain_on_overflow. */
1113 bfd_elf_generic_reloc
, /* special_function. */
1114 "R_LARCH_TLS_LE_HI20", /* name. */
1115 false, /* partial_inplace. */
1117 0x1ffffe0, /* dst_mask */
1118 false, /* pcrel_offset */
1119 BFD_RELOC_LARCH_TLS_LE_HI20
, /* bfd_reloc_code_real_type */
1120 reloc_bits
, /* adjust_reloc_bits */
1121 "le_hi20"), /* larch_reloc_type_name */
1123 LOONGARCH_HOWTO (R_LARCH_TLS_LE_LO12
, /* type (84). */
1124 0, /* rightshift. */
1127 false, /* pc_relative. */
1129 complain_overflow_unsigned
, /* complain_on_overflow. */
1130 bfd_elf_generic_reloc
, /* special_function. */
1131 "R_LARCH_TLS_LE_LO12", /* name. */
1132 false, /* partial_inplace. */
1134 0x3ffc00, /* dst_mask */
1135 false, /* pcrel_offset */
1136 BFD_RELOC_LARCH_TLS_LE_LO12
, /* bfd_reloc_code_real_type */
1137 reloc_bits
, /* adjust_reloc_bits */
1138 "le_lo12"), /* larch_reloc_type_name */
1140 LOONGARCH_HOWTO (R_LARCH_TLS_LE64_LO20
, /* type (85). */
1141 32, /* rightshift. */
1144 false, /* pc_relative. */
1146 complain_overflow_signed
, /* complain_on_overflow. */
1147 bfd_elf_generic_reloc
, /* special_function. */
1148 "R_LARCH_TLS_LE64_LO20", /* name. */
1149 false, /* partial_inplace. */
1151 0x1ffffe0, /* dst_mask */
1152 false, /* pcrel_offset */
1153 BFD_RELOC_LARCH_TLS_LE64_LO20
, /* bfd_reloc_code_real_type */
1154 reloc_bits
, /* adjust_reloc_bits */
1155 "le64_lo20"), /* larch_reloc_type_name */
1157 LOONGARCH_HOWTO (R_LARCH_TLS_LE64_HI12
, /* type (86). */
1158 52, /* rightshift. */
1161 false, /* pc_relative. */
1163 complain_overflow_signed
, /* complain_on_overflow. */
1164 bfd_elf_generic_reloc
, /* special_function. */
1165 "R_LARCH_TLS_LE64_HI12", /* name. */
1166 false, /* partial_inplace. */
1168 0x3ffc00, /* dst_mask */
1169 false, /* pcrel_offset */
1170 BFD_RELOC_LARCH_TLS_LE64_HI12
, /* bfd_reloc_code_real_type */
1171 reloc_bits
, /* adjust_reloc_bits */
1172 "le64_hi12"), /* larch_reloc_type_name */
1174 LOONGARCH_HOWTO (R_LARCH_TLS_IE_PC_HI20
, /* type (87). */
1175 12, /* rightshift. */
1178 false, /* pc_relative. */
1180 complain_overflow_signed
, /* complain_on_overflow. */
1181 bfd_elf_generic_reloc
, /* special_function. */
1182 "R_LARCH_TLS_IE_PC_HI20", /* name. */
1183 false, /* partial_inplace. */
1185 0x1ffffe0, /* dst_mask */
1186 false, /* pcrel_offset */
1187 BFD_RELOC_LARCH_TLS_IE_PC_HI20
, /* bfd_reloc_code_real_type */
1188 reloc_bits
, /* adjust_reloc_bits */
1189 "ie_pc_hi20"), /* larch_reloc_type_name */
1191 LOONGARCH_HOWTO (R_LARCH_TLS_IE_PC_LO12
, /* type (88). */
1192 0, /* rightshift. */
1195 false, /* pc_relative. */
1197 complain_overflow_signed
, /* complain_on_overflow. */
1198 bfd_elf_generic_reloc
, /* special_function. */
1199 "R_LARCH_TLS_IE_PC_LO12", /* name. */
1200 false, /* partial_inplace. */
1202 0x3ffc00, /* dst_mask */
1203 false, /* pcrel_offset */
1204 BFD_RELOC_LARCH_TLS_IE_PC_LO12
, /* bfd_reloc_code_real_type */
1205 reloc_bits
, /* adjust_reloc_bits */
1206 "ie_pc_lo12"), /* larch_reloc_type_name */
1208 LOONGARCH_HOWTO (R_LARCH_TLS_IE64_PC_LO20
, /* type (89). */
1209 32, /* rightshift. */
1212 false, /* pc_relative. */
1214 complain_overflow_signed
, /* complain_on_overflow. */
1215 bfd_elf_generic_reloc
, /* special_function. */
1216 "R_LARCH_TLS_IE64_PC_LO20", /* name. */
1217 false, /* partial_inplace. */
1219 0x1ffffe0, /* dst_mask */
1220 false, /* pcrel_offset */
1221 BFD_RELOC_LARCH_TLS_IE64_PC_LO20
, /* bfd_reloc_code_real_type */
1222 reloc_bits
, /* adjust_reloc_bits */
1223 "ie64_pc_lo20"), /* larch_reloc_type_name */
1225 LOONGARCH_HOWTO (R_LARCH_TLS_IE64_PC_HI12
, /* type (90). */
1226 52, /* rightshift. */
1229 false, /* pc_relative. */
1231 complain_overflow_signed
, /* complain_on_overflow. */
1232 bfd_elf_generic_reloc
, /* special_function. */
1233 "R_LARCH_TLS_IE64_PC_HI12", /* name. */
1234 false, /* partial_inplace. */
1236 0x3ffc00, /* dst_mask */
1237 false, /* pcrel_offset */
1238 BFD_RELOC_LARCH_TLS_IE64_PC_HI12
, /* bfd_reloc_code_real_type */
1239 reloc_bits
, /* adjust_reloc_bits */
1240 "ie64_pc_hi12"), /* larch_reloc_type_name */
1242 LOONGARCH_HOWTO (R_LARCH_TLS_IE_HI20
, /* type (91). */
1243 12, /* rightshift. */
1246 false, /* pc_relative. */
1248 complain_overflow_signed
, /* complain_on_overflow. */
1249 bfd_elf_generic_reloc
, /* special_function. */
1250 "R_LARCH_TLS_IE_HI20", /* name. */
1251 false, /* partial_inplace. */
1253 0x1ffffe0, /* dst_mask */
1254 false, /* pcrel_offset */
1255 BFD_RELOC_LARCH_TLS_IE_HI20
, /* bfd_reloc_code_real_type */
1256 reloc_bits
, /* adjust_reloc_bits */
1257 "ie_hi20"), /* larch_reloc_type_name */
1259 LOONGARCH_HOWTO (R_LARCH_TLS_IE_LO12
, /* type (92). */
1260 0, /* rightshift. */
1263 false, /* pc_relative. */
1265 complain_overflow_signed
, /* complain_on_overflow. */
1266 bfd_elf_generic_reloc
, /* special_function. */
1267 "R_LARCH_TLS_IE_LO12", /* name. */
1268 false, /* partial_inplace. */
1270 0x3ffc00, /* dst_mask */
1271 false, /* pcrel_offset */
1272 BFD_RELOC_LARCH_TLS_IE_LO12
, /* bfd_reloc_code_real_type */
1273 reloc_bits
, /* adjust_reloc_bits */
1274 "ie_lo12"), /* larch_reloc_type_name */
1276 LOONGARCH_HOWTO (R_LARCH_TLS_IE64_LO20
, /* type (93). */
1277 32, /* rightshift. */
1280 false, /* pc_relative. */
1282 complain_overflow_signed
, /* complain_on_overflow. */
1283 bfd_elf_generic_reloc
, /* special_function. */
1284 "R_LARCH_TLS_IE64_LO20", /* name. */
1285 false, /* partial_inplace. */
1287 0x1ffffe0, /* dst_mask */
1288 false, /* pcrel_offset */
1289 BFD_RELOC_LARCH_TLS_IE64_LO20
, /* bfd_reloc_code_real_type */
1290 reloc_bits
, /* adjust_reloc_bits */
1291 "ie64_lo20"), /* larch_reloc_type_name */
1293 LOONGARCH_HOWTO (R_LARCH_TLS_IE64_HI12
, /* type (94). */
1294 52, /* rightshift. */
1297 false, /* pc_relative. */
1299 complain_overflow_signed
, /* complain_on_overflow. */
1300 bfd_elf_generic_reloc
, /* special_function. */
1301 "R_LARCH_TLS_IE64_HI12", /* name. */
1302 false, /* partial_inplace. */
1304 0x3ffc00, /* dst_mask */
1305 false, /* pcrel_offset */
1306 BFD_RELOC_LARCH_TLS_IE64_HI12
, /* bfd_reloc_code_real_type */
1307 reloc_bits
, /* adjust_reloc_bits */
1308 "ie64_hi12"), /* larch_reloc_type_name */
1310 LOONGARCH_HOWTO (R_LARCH_TLS_LD_PC_HI20
, /* type (95). */
1311 12, /* rightshift. */
1314 false, /* pc_relative. */
1316 complain_overflow_signed
, /* complain_on_overflow. */
1317 bfd_elf_generic_reloc
, /* special_function. */
1318 "R_LARCH_TLS_LD_PC_HI20", /* name. */
1319 false, /* partial_inplace. */
1321 0x1ffffe0, /* dst_mask */
1322 false, /* pcrel_offset */
1323 BFD_RELOC_LARCH_TLS_LD_PC_HI20
, /* bfd_reloc_code_real_type */
1324 reloc_bits
, /* adjust_reloc_bits */
1325 "ld_pc_hi20"), /* larch_reloc_type_name */
1327 LOONGARCH_HOWTO (R_LARCH_TLS_LD_HI20
, /* type (96). */
1328 12, /* rightshift. */
1331 false, /* pc_relative. */
1333 complain_overflow_signed
, /* complain_on_overflow. */
1334 bfd_elf_generic_reloc
, /* special_function. */
1335 "R_LARCH_TLS_LD_HI20", /* name. */
1336 false, /* partial_inplace. */
1338 0x1ffffe0, /* dst_mask */
1339 false, /* pcrel_offset */
1340 BFD_RELOC_LARCH_TLS_LD_HI20
, /* bfd_reloc_code_real_type */
1341 reloc_bits
, /* adjust_reloc_bits */
1342 "ld_hi20"), /* larch_reloc_type_name */
1344 LOONGARCH_HOWTO (R_LARCH_TLS_GD_PC_HI20
, /* type (97). */
1345 12, /* rightshift. */
1348 false, /* pc_relative. */
1350 complain_overflow_signed
, /* complain_on_overflow. */
1351 bfd_elf_generic_reloc
, /* special_function. */
1352 "R_LARCH_TLS_GD_PC_HI20", /* name. */
1353 false, /* partial_inplace. */
1355 0x1ffffe0, /* dst_mask */
1356 false, /* pcrel_offset */
1357 BFD_RELOC_LARCH_TLS_GD_PC_HI20
, /* bfd_reloc_code_real_type */
1358 reloc_bits
, /* adjust_reloc_bits */
1359 "gd_pc_hi20"), /* larch_reloc_type_name */
1361 LOONGARCH_HOWTO (R_LARCH_TLS_GD_HI20
, /* type (98). */
1362 12, /* rightshift. */
1365 false, /* pc_relative. */
1367 complain_overflow_signed
, /* complain_on_overflow. */
1368 bfd_elf_generic_reloc
, /* special_function. */
1369 "R_LARCH_TLS_GD_HI20", /* name. */
1370 false, /* partial_inplace. */
1372 0x1ffffe0, /* dst_mask */
1373 false, /* pcrel_offset */
1374 BFD_RELOC_LARCH_TLS_GD_HI20
, /* bfd_reloc_code_real_type */
1375 reloc_bits
, /* adjust_reloc_bits */
1376 "gd_hi20"), /* larch_reloc_type_name */
1378 /* 32-bit PC relative. */
1379 LOONGARCH_HOWTO (R_LARCH_32_PCREL
, /* type (99). */
1380 0, /* rightshift. */
1383 true, /* pc_relative. */
1385 complain_overflow_signed
, /* complain_on_overflow. */
1386 bfd_elf_generic_reloc
, /* special_function. */
1387 "R_LARCH_32_PCREL", /* name. */
1388 false, /* partial_inplace. */
1390 0xffffffff, /* dst_mask */
1391 false, /* pcrel_offset */
1392 BFD_RELOC_LARCH_32_PCREL
, /* bfd_reloc_code_real_type */
1393 NULL
, /* adjust_reloc_bits */
1394 NULL
), /* larch_reloc_type_name */
1396 /* The paired relocation may be relaxed. */
1397 LOONGARCH_HOWTO (R_LARCH_RELAX
, /* type (100). */
1401 false, /* pc_relative */
1403 complain_overflow_dont
, /* complain_on_overflow */
1404 bfd_elf_generic_reloc
, /* special_function */
1405 "R_LARCH_RELAX", /* name */
1406 false, /* partial_inplace */
1409 false, /* pcrel_offset */
1410 BFD_RELOC_LARCH_RELAX
, /* bfd_reloc_code_real_type */
1411 NULL
, /* adjust_reloc_bits */
1412 NULL
), /* larch_reloc_type_name */
1414 /* Delete relaxed instruction. */
1415 LOONGARCH_HOWTO (R_LARCH_DELETE
, /* type (101). */
1416 0, /* rightshift. */
1419 false, /* pc_relative. */
1421 complain_overflow_dont
, /* complain_on_overflow. */
1422 bfd_elf_generic_reloc
, /* special_function. */
1423 "R_LARCH_DELETE", /* name. */
1424 false, /* partial_inplace. */
1427 false, /* pcrel_offset. */
1428 BFD_RELOC_LARCH_DELETE
, /* bfd_reloc_code_real_type. */
1429 NULL
, /* adjust_reloc_bits. */
1430 NULL
), /* larch_reloc_type_name. */
1432 /* Indicates an alignment statement. f the symbol index is 0,
1433 the addend indicates the number of bytes occupied by nop instructions
1434 at the relocation offset. The alignment boundary is specified by the
1435 addend rounded up to the next power of two.
1436 If the symbol index is not 0, the addend indicates the first and third
1437 expressions of .align. The lowest 8 bits are used to represent the first
1438 expression, other bits are used to represent the third expression. */
1439 LOONGARCH_HOWTO (R_LARCH_ALIGN
, /* type (102). */
1440 0, /* rightshift. */
1443 false, /* pc_relative. */
1445 complain_overflow_dont
, /* complain_on_overflow. */
1446 bfd_elf_generic_reloc
, /* special_function. */
1447 "R_LARCH_ALIGN", /* name. */
1448 false, /* partial_inplace. */
1451 false, /* pcrel_offset. */
1452 BFD_RELOC_LARCH_ALIGN
, /* bfd_reloc_code_real_type. */
1453 NULL
, /* adjust_reloc_bits. */
1454 NULL
), /* larch_reloc_type_name. */
1456 /* For pcaddi and pcala_hi20 + pcala_lo12 can relax to pcrel_20. */
1457 LOONGARCH_HOWTO (R_LARCH_PCREL20_S2
, /* type (103). */
1458 2, /* rightshift. */
1461 false, /* pc_relative. */
1463 complain_overflow_signed
, /* complain_on_overflow. */
1464 bfd_elf_generic_reloc
, /* special_function. */
1465 "R_LARCH_PCREL20_S2", /* name. */
1466 false, /* partial_inplace. */
1468 0x1ffffe0, /* dst_mask. */
1469 false, /* pcrel_offset. */
1470 BFD_RELOC_LARCH_PCREL20_S2
, /* bfd_reloc_code_real_type. */
1471 reloc_sign_bits
, /* adjust_reloc_bits. */
1472 "pcrel_20"), /* larch_reloc_type_name. */
1474 /* Canonical Frame Address. */
1475 LOONGARCH_HOWTO (R_LARCH_CFA
, /* type (104). */
1476 0, /* rightshift. */
1479 false, /* pc_relative. */
1481 complain_overflow_dont
, /* complain_on_overflow. */
1482 bfd_elf_generic_reloc
, /* special_function. */
1483 "R_LARCH_CFA", /* name. */
1484 false, /* partial_inplace. */
1487 false, /* pcrel_offset. */
1488 BFD_RELOC_LARCH_CFA
, /* bfd_reloc_code_real_type. */
1489 NULL
, /* adjust_reloc_bits. */
1490 NULL
), /* larch_reloc_type_name. */
1492 /* 6-bit in-place addition, for local label subtraction
1493 to calculate DW_CFA_advance_loc. */
1494 LOONGARCH_HOWTO (R_LARCH_ADD6
, /* type (105). */
1495 0, /* rightshift. */
1498 false, /* pc_relative. */
1500 complain_overflow_dont
, /* complain_on_overflow. */
1501 loongarch_elf_add_sub_reloc
, /* special_function. */
1502 "R_LARCH_ADD6", /* name. */
1503 false, /* partial_inplace. */
1505 0x3f, /* dst_mask. */
1506 false, /* pcrel_offset. */
1507 BFD_RELOC_LARCH_ADD6
, /* bfd_reloc_code_real_type. */
1508 reloc_bits
, /* adjust_reloc_bits. */
1509 NULL
), /* larch_reloc_type_name. */
1511 /* 6-bit in-place subtraction, for local label subtraction
1512 to calculate DW_CFA_advance_loc. */
1513 LOONGARCH_HOWTO (R_LARCH_SUB6
, /* type (106). */
1514 0, /* rightshift. */
1517 false, /* pc_relative. */
1519 complain_overflow_dont
, /* complain_on_overflow. */
1520 loongarch_elf_add_sub_reloc
, /* special_function. */
1521 "R_LARCH_SUB6", /* name. */
1522 false, /* partial_inplace. */
1524 0x3f, /* dst_mask. */
1525 false, /* pcrel_offset. */
1526 BFD_RELOC_LARCH_SUB6
, /* bfd_reloc_code_real_type. */
1527 reloc_bits
, /* adjust_reloc_bits. */
1528 NULL
), /* larch_reloc_type_name. */
1530 /* The length of unsigned-leb128 is variable, just assume the
1531 size is one byte here.
1532 uleb128 in-place addition, for local label subtraction. */
1533 LOONGARCH_HOWTO (R_LARCH_ADD_ULEB128
, /* type (107). */
1534 0, /* rightshift. */
1537 false, /* pc_relative. */
1539 complain_overflow_dont
, /* complain_on_overflow. */
1540 loongarch_elf_add_sub_reloc_uleb128
, /* special_function. */
1541 "R_LARCH_ADD_ULEB128", /* name. */
1542 false, /* partial_inplace. */
1545 false, /* pcrel_offset. */
1546 BFD_RELOC_LARCH_ADD_ULEB128
, /* bfd_reloc_code_real_type. */
1547 NULL
, /* adjust_reloc_bits. */
1548 NULL
), /* larch_reloc_type_name. */
1550 /* The length of unsigned-leb128 is variable, just assume the
1551 size is one byte here.
1552 uleb128 in-place subtraction, for local label subtraction. */
1553 LOONGARCH_HOWTO (R_LARCH_SUB_ULEB128
, /* type (108). */
1554 0, /* rightshift. */
1557 false, /* pc_relative. */
1559 complain_overflow_dont
, /* complain_on_overflow. */
1560 loongarch_elf_add_sub_reloc_uleb128
, /* special_function. */
1561 "R_LARCH_SUB_ULEB128", /* name. */
1562 false, /* partial_inplace. */
1565 false, /* pcrel_offset. */
1566 BFD_RELOC_LARCH_SUB_ULEB128
, /* bfd_reloc_code_real_type. */
1567 NULL
, /* adjust_reloc_bits. */
1568 NULL
), /* larch_reloc_type_name. */
1570 /* 64-bit PC relative. */
1571 LOONGARCH_HOWTO (R_LARCH_64_PCREL
, /* type (109). */
1572 0, /* rightshift. */
1575 true, /* pc_relative. */
1577 complain_overflow_signed
, /* complain_on_overflow. */
1578 bfd_elf_generic_reloc
, /* special_function. */
1579 "R_LARCH_64_PCREL", /* name. */
1580 false, /* partial_inplace. */
1582 0xffffffffffffffff, /* dst_mask */
1583 false, /* pcrel_offset */
1584 BFD_RELOC_LARCH_64_PCREL
, /* bfd_reloc_code_real_type */
1585 NULL
, /* adjust_reloc_bits */
1586 NULL
), /* larch_reloc_type_name */
1588 /* Used for medium code model function call pcaddu18i+jirl,
1589 these two instructions must adjacent. */
1590 LOONGARCH_HOWTO (R_LARCH_CALL36
, /* type (110). */
1591 2, /* rightshift. */
1594 true, /* pc_relative. */
1596 complain_overflow_signed
, /* complain_on_overflow. */
1597 bfd_elf_generic_reloc
, /* special_function. */
1598 "R_LARCH_CALL36", /* name. */
1599 false, /* partial_inplace. */
1601 0x03fffc0001ffffe0, /* dst_mask. */
1602 false, /* pcrel_offset. */
1603 BFD_RELOC_LARCH_CALL36
, /* bfd_reloc_code_real_type. */
1604 reloc_sign_bits
, /* adjust_reloc_bits. */
1605 "call36"), /* larch_reloc_type_name. */
1607 /* TLS_DESC PCREL. */
1608 LOONGARCH_HOWTO (R_LARCH_TLS_DESC_PC_HI20
, /* type (111). */
1609 12, /* rightshift. */
1612 true, /* pc_relative. */
1614 complain_overflow_signed
, /* complain_on_overflow. */
1615 bfd_elf_generic_reloc
, /* special_function. */
1616 "R_LARCH_TLS_DESC_PC_HI20", /* name. */
1617 false, /* partial_inplace. */
1619 0x1ffffe0, /* dst_mask. */
1620 false, /* pcrel_offset. */
1621 BFD_RELOC_LARCH_TLS_DESC_PC_HI20
, /* bfd_reloc_code_real_type. */
1622 reloc_bits
, /* adjust_reloc_bits. */
1623 "desc_pc_hi20"), /* larch_reloc_type_name. */
1625 LOONGARCH_HOWTO (R_LARCH_TLS_DESC_PC_LO12
, /* type (112). */
1626 0, /* rightshift. */
1629 true, /* pc_relative. */
1631 complain_overflow_signed
, /* complain_on_overflow. */
1632 bfd_elf_generic_reloc
, /* special_function. */
1633 "R_LARCH_TLS_DESC_PC_LO12", /* name. */
1634 false, /* partial_inplace. */
1636 0x3ffc00, /* dst_mask. */
1637 false, /* pcrel_offset. */
1638 BFD_RELOC_LARCH_TLS_DESC_PC_LO12
, /* bfd_reloc_code_real_type. */
1639 reloc_bits
, /* adjust_reloc_bits. */
1640 "desc_pc_lo12"), /* larch_reloc_type_name. */
1642 /* TLS_DESC64 LARGE PCREL. */
1643 LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_PC_LO20
, /* type (113). */
1644 32, /* rightshift. */
1647 true, /* pc_relative. */
1649 complain_overflow_signed
, /* complain_on_overflow. */
1650 bfd_elf_generic_reloc
, /* special_function. */
1651 "R_LARCH_TLS_DESC64_PC_LO20", /* name. */
1652 false, /* partial_inplace. */
1654 0x1ffffe0, /* dst_mask. */
1655 false, /* pcrel_offset. */
1656 BFD_RELOC_LARCH_TLS_DESC64_PC_LO20
, /* bfd_reloc_code_real_type. */
1657 reloc_bits
, /* adjust_reloc_bits. */
1658 "desc64_pc_lo20"), /* larch_reloc_type_name. */
1660 LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_PC_HI12
, /* type (114). */
1661 52, /* rightshift. */
1664 true, /* pc_relative. */
1666 complain_overflow_signed
, /* complain_on_overflow. */
1667 bfd_elf_generic_reloc
, /* special_function. */
1668 "R_LARCH_TLS_DESC64_PC_HI12", /* name. */
1669 false, /* partial_inplace. */
1671 0x3ffc00, /* dst_mask. */
1672 false, /* pcrel_offset. */
1673 BFD_RELOC_LARCH_TLS_DESC64_PC_HI12
, /* bfd_reloc_code_real_type. */
1674 reloc_bits
, /* adjust_reloc_bits. */
1675 "desc64_pc_hi12"), /* larch_reloc_type_name. */
1678 LOONGARCH_HOWTO (R_LARCH_TLS_DESC_HI20
, /* type (115). */
1679 12, /* rightshift. */
1682 false, /* pc_relative. */
1684 complain_overflow_signed
, /* complain_on_overflow. */
1685 bfd_elf_generic_reloc
, /* special_function. */
1686 "R_LARCH_TLS_DESC_HI20", /* name. */
1687 false, /* partial_inplace. */
1689 0x1ffffe0, /* dst_mask. */
1690 false, /* pcrel_offset. */
1691 BFD_RELOC_LARCH_TLS_DESC_HI20
, /* bfd_reloc_code_real_type. */
1692 reloc_bits
, /* adjust_reloc_bits. */
1693 "desc_hi20"), /* larch_reloc_type_name. */
1695 LOONGARCH_HOWTO (R_LARCH_TLS_DESC_LO12
, /* type (116). */
1696 0, /* rightshift. */
1699 false, /* pc_relative. */
1701 complain_overflow_signed
, /* complain_on_overflow. */
1702 bfd_elf_generic_reloc
, /* special_function. */
1703 "R_LARCH_TLS_DESC_LO12", /* name. */
1704 false, /* partial_inplace. */
1706 0x3ffc00, /* dst_mask. */
1707 false, /* pcrel_offset. */
1708 BFD_RELOC_LARCH_TLS_DESC_LO12
, /* bfd_reloc_code_real_type. */
1709 reloc_bits
, /* adjust_reloc_bits. */
1710 "desc_lo12"), /* larch_reloc_type_name. */
1712 /* TLS_DESC64 LARGE ABS. */
1713 LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_LO20
, /* type (117). */
1714 32, /* rightshift. */
1717 false, /* pc_relative. */
1719 complain_overflow_signed
, /* complain_on_overflow. */
1720 bfd_elf_generic_reloc
, /* special_function. */
1721 "R_LARCH_TLS_DESC64_LO20", /* name. */
1722 false, /* partial_inplace. */
1724 0x1ffffe0, /* dst_mask. */
1725 false, /* pcrel_offset. */
1726 BFD_RELOC_LARCH_TLS_DESC64_LO20
, /* bfd_reloc_code_real_type. */
1727 reloc_bits
, /* adjust_reloc_bits. */
1728 "desc64_lo20"), /* larch_reloc_type_name. */
1730 LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_HI12
, /* type (118). */
1731 52, /* rightshift. */
1734 false, /* pc_relative. */
1736 complain_overflow_signed
, /* complain_on_overflow. */
1737 bfd_elf_generic_reloc
, /* special_function. */
1738 "R_LARCH_TLS_DESC64_HI12", /* name. */
1739 false, /* partial_inplace. */
1741 0x3ffc00, /* dst_mask. */
1742 false, /* pcrel_offset. */
1743 BFD_RELOC_LARCH_TLS_DESC64_HI12
, /* bfd_reloc_code_real_type. */
1744 reloc_bits
, /* adjust_reloc_bits. */
1745 "desc64_hi12"), /* larch_reloc_type_name. */
1747 LOONGARCH_HOWTO (R_LARCH_TLS_DESC_LD
, /* type (119). */
1748 0, /* rightshift. */
1751 true, /* pc_relative. */
1753 complain_overflow_signed
, /* complain_on_overflow. */
1754 bfd_elf_generic_reloc
, /* special_function. */
1755 "R_LARCH_TLS_DESC_LD", /* name. */
1756 false, /* partial_inplace. */
1759 false, /* pcrel_offset. */
1760 BFD_RELOC_LARCH_TLS_DESC_LD
, /* bfd_reloc_code_real_type. */
1761 NULL
, /* adjust_reloc_bits. */
1762 "desc_ld"), /* larch_reloc_type_name. */
1764 LOONGARCH_HOWTO (R_LARCH_TLS_DESC_CALL
, /* type (120). */
1765 0, /* rightshift. */
1768 false, /* pc_relative. */
1770 complain_overflow_dont
, /* complain_on_overflow. */
1771 bfd_elf_generic_reloc
, /* special_function. */
1772 "R_LARCH_TLS_DESC_CALL", /* name. */
1773 false, /* partial_inplace. */
1776 false, /* pcrel_offset. */
1777 BFD_RELOC_LARCH_TLS_DESC_CALL
, /* bfd_reloc_code_real_type. */
1778 NULL
, /* adjust_reloc_bits. */
1779 "desc_call"), /* larch_reloc_type_name. */
1781 LOONGARCH_HOWTO (R_LARCH_TLS_LE_HI20_R
, /* type (121). */
1782 12, /* rightshift. */
1785 false, /* pc_relative. */
1787 complain_overflow_signed
, /* complain_on_overflow. */
1788 bfd_elf_generic_reloc
, /* special_function. */
1789 "R_LARCH_TLS_LE_HI20_R", /* name. */
1790 false, /* partial_inplace. */
1792 0x1ffffe0, /* dst_mask. */
1793 false, /* pcrel_offset. */
1794 BFD_RELOC_LARCH_TLS_LE_HI20_R
, /* bfd_reloc_code_real_type. */
1795 reloc_bits
, /* adjust_reloc_bits. */
1796 "le_hi20_r"), /* larch_reloc_type_name. */
1798 LOONGARCH_HOWTO (R_LARCH_TLS_LE_ADD_R
, /* type (122). */
1799 0, /* rightshift. */
1802 false, /* pc_relative. */
1804 complain_overflow_dont
, /* complain_on_overflow. */
1805 bfd_elf_generic_reloc
, /* special_function. */
1806 "R_LARCH_TLS_LE_ADD_R", /* name. */
1807 false, /* partial_inplace. */
1810 false, /* pcrel_offset. */
1811 BFD_RELOC_LARCH_TLS_LE_ADD_R
, /* bfd_reloc_code_real_type. */
1812 NULL
, /* adjust_reloc_bits. */
1813 "le_add_r"), /* larch_reloc_type_name. */
1815 LOONGARCH_HOWTO (R_LARCH_TLS_LE_LO12_R
, /* type (123). */
1816 0, /* rightshift. */
1819 false, /* pc_relative. */
1821 complain_overflow_signed
, /* complain_on_overflow. */
1822 bfd_elf_generic_reloc
, /* special_function. */
1823 "R_LARCH_TLS_LE_LO12_R", /* name. */
1824 false, /* partial_inplace. */
1826 0x3ffc00, /* dst_mask. */
1827 false, /* pcrel_offset. */
1828 BFD_RELOC_LARCH_TLS_LE_LO12_R
, /* bfd_reloc_code_real_type. */
1829 reloc_bits
, /* adjust_reloc_bits. */
1830 "le_lo12_r"), /* larch_reloc_type_name. */
1832 /* For pcaddi, ld_pc_hi20 + ld_pc_lo12 can relax to ld_pcrel20_s2. */
1833 LOONGARCH_HOWTO (R_LARCH_TLS_LD_PCREL20_S2
, /* type (124). */
1834 2, /* rightshift. */
1837 false, /* pc_relative. */
1839 complain_overflow_signed
, /* complain_on_overflow. */
1840 bfd_elf_generic_reloc
, /* special_function. */
1841 "R_LARCH_TLS_LD_PCREL20_S2", /* name. */
1842 false, /* partial_inplace. */
1844 0x1ffffe0, /* dst_mask. */
1845 true, /* pcrel_offset. */
1846 BFD_RELOC_LARCH_TLS_LD_PCREL20_S2
, /* bfd_reloc_code_real_type. */
1847 reloc_sign_bits
, /* adjust_reloc_bits. */
1848 "ld_pcrel_20"), /* larch_reloc_type_name. */
1850 /* For pcaddi, gd_pc_hi20 + gd_pc_lo12 can relax to gd_pcrel20_s2. */
1851 LOONGARCH_HOWTO (R_LARCH_TLS_GD_PCREL20_S2
, /* type (125). */
1852 2, /* rightshift. */
1855 false, /* pc_relative. */
1857 complain_overflow_signed
, /* complain_on_overflow. */
1858 bfd_elf_generic_reloc
, /* special_function. */
1859 "R_LARCH_TLS_GD_PCREL20_S2", /* name. */
1860 false, /* partial_inplace. */
1862 0x1ffffe0, /* dst_mask. */
1863 true, /* pcrel_offset. */
1864 BFD_RELOC_LARCH_TLS_GD_PCREL20_S2
, /* bfd_reloc_code_real_type. */
1865 reloc_sign_bits
, /* adjust_reloc_bits. */
1866 "gd_pcrel_20"), /* larch_reloc_type_name. */
1868 /* For pcaddi, desc_pc_hi20 + desc_pc_lo12 can relax to desc_pcrel20_s2. */
1869 LOONGARCH_HOWTO (R_LARCH_TLS_DESC_PCREL20_S2
, /* type (126). */
1870 2, /* rightshift. */
1873 false, /* pc_relative. */
1875 complain_overflow_signed
, /* complain_on_overflow. */
1876 bfd_elf_generic_reloc
, /* special_function. */
1877 "R_LARCH_TLS_DESC_PCREL20_S2", /* name. */
1878 false, /* partial_inplace. */
1880 0x1ffffe0, /* dst_mask. */
1881 true, /* pcrel_offset. */
1882 BFD_RELOC_LARCH_TLS_DESC_PCREL20_S2
, /* bfd_reloc_code_real_type. */
1883 reloc_sign_bits
, /* adjust_reloc_bits. */
1884 "desc_pcrel_20"), /* larch_reloc_type_name. */
1888 loongarch_elf_rtype_to_howto (bfd
*abfd
, unsigned int r_type
)
1890 if (r_type
< R_LARCH_count
)
1892 BFD_ASSERT (ARRAY_SIZE (loongarch_howto_table
) == R_LARCH_count
);
1893 BFD_ASSERT (loongarch_howto_table
[r_type
].howto
.type
== r_type
);
1894 return &loongarch_howto_table
[r_type
].howto
;
1897 (*_bfd_error_handler
) (_("%pB: unsupported relocation type %#x"),
1899 bfd_set_error (bfd_error_bad_value
);
1904 loongarch_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
, const char *r_name
)
1906 for (size_t i
= 0; i
< ARRAY_SIZE (loongarch_howto_table
); i
++)
1907 if (loongarch_howto_table
[i
].howto
.name
1908 && strcasecmp (loongarch_howto_table
[i
].howto
.name
, r_name
) == 0)
1909 return &loongarch_howto_table
[i
].howto
;
1911 (*_bfd_error_handler
) (_("%pB: unsupported relocation type %s"),
1913 bfd_set_error (bfd_error_bad_value
);
1919 loongarch_reloc_type_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1920 bfd_reloc_code_real_type code
)
1922 BFD_ASSERT (ARRAY_SIZE (loongarch_howto_table
) == R_LARCH_count
);
1924 /* Fast search for new reloc types. */
1925 if (BFD_RELOC_LARCH_B16
<= code
&& code
< BFD_RELOC_LARCH_RELAX
)
1927 BFD_ASSERT (BFD_RELOC_LARCH_RELAX
- BFD_RELOC_LARCH_B16
1928 == R_LARCH_RELAX
- R_LARCH_B16
);
1929 loongarch_reloc_howto_type
*ht
;
1930 ht
= &loongarch_howto_table
[code
- BFD_RELOC_LARCH_B16
+ R_LARCH_B16
];
1931 BFD_ASSERT (ht
->bfd_type
== code
);
1935 for (size_t i
= 0; i
< ARRAY_SIZE (loongarch_howto_table
); i
++)
1936 if (loongarch_howto_table
[i
].bfd_type
== code
)
1937 return &loongarch_howto_table
[i
].howto
;
1939 (*_bfd_error_handler
) (_("%pB: unsupported bfd relocation type %#x"),
1941 bfd_set_error (bfd_error_bad_value
);
1945 bfd_reloc_code_real_type
1946 loongarch_larch_reloc_name_lookup (bfd
*abfd ATTRIBUTE_UNUSED
,
1947 const char *l_r_name
)
1949 for (size_t i
= 0; i
< ARRAY_SIZE (loongarch_howto_table
); i
++)
1951 loongarch_reloc_howto_type
*lht
= &loongarch_howto_table
[i
];
1952 if ((NULL
!= lht
->larch_reloc_type_name
)
1953 && (0 == strcmp (lht
->larch_reloc_type_name
, l_r_name
)))
1954 return lht
->bfd_type
;
1957 return BFD_RELOC_NONE
;
1961 /* Functions for reloc bits field.
1962 1. Signed extend *fix_val.
1963 2. Return false if overflow. */
1965 #define LARCH_RELOC_BFD_VMA_BIT_MASK(bitsize) \
1966 (~((((bfd_vma)0x1) << (bitsize)) - 1))
1968 /* Adjust val to perform insn
1969 BFD_RELOC_LARCH_SOP_POP_32_S_10_5
1970 BFD_RELOC_LARCH_SOP_POP_32_S_10_12
1971 BFD_RELOC_LARCH_SOP_POP_32_U_10_12
1972 BFD_RELOC_LARCH_SOP_POP_32_S_10_16
1973 BFD_RELOC_LARCH_SOP_POP_32_S_5_20
1974 BFD_RELOC_LARCH_SOP_POP_32_U. */
1977 reloc_bits (bfd
*abfd ATTRIBUTE_UNUSED
,
1978 reloc_howto_type
*howto
,
1981 bfd_signed_vma val
= (bfd_signed_vma
)(*fix_val
);
1982 bfd_signed_vma mask
= ((bfd_signed_vma
)0x1 << howto
->bitsize
) - 1;
1984 val
= val
>> howto
->rightshift
;
1986 /* Perform insn bits field. */
1988 val
<<= howto
->bitpos
;
1990 *fix_val
= (bfd_vma
)val
;
1996 reloc_bits_sanity (bfd
*abfd
, reloc_howto_type
*howto
, bfd_vma
*fix_val
,
1999 if ((sign
&& howto
->complain_on_overflow
!= complain_overflow_signed
)
2000 || (!sign
&& howto
->complain_on_overflow
!= complain_overflow_unsigned
))
2003 bfd_signed_vma val
= (bfd_signed_vma
)(*fix_val
);
2005 /* Check alignment. FIXME: if rightshift is not alingment. */
2006 if (howto
->rightshift
2007 && (val
& ((((bfd_signed_vma
) 1) << howto
->rightshift
) - 1)))
2009 /* The as passes NULL casued internal error, so it can not use _bfd_error_handler
2010 output details, ld is not affected. */
2013 (*_bfd_error_handler
) (_("%pB: relocation %s right shift %d error 0x%lx"),
2014 abfd
, howto
->name
, howto
->rightshift
, (long) val
);
2015 bfd_set_error (bfd_error_bad_value
);
2020 bfd_signed_vma mask
= ((bfd_signed_vma
)0x1 << (howto
->bitsize
2021 + howto
->rightshift
- sign
)) - 1;
2023 /* Positive number: high part is all 0;
2024 Negative number: if high part is not all 0, high part must be all 1.
2025 high part: from sign bit to highest bit. */
2026 if ((val
& ~mask
) && ((val
& ~mask
) != ~mask
))
2028 /* The as passes NULL casued internal error, so it can not use _bfd_error_handler
2029 output details, ld is not affected. */
2032 (*_bfd_error_handler
) (_("%pB: relocation %s overflow 0x%lx"),
2033 abfd
, howto
->name
, (long) val
);
2034 bfd_set_error (bfd_error_bad_value
);
2039 val
= val
>> howto
->rightshift
;
2041 mask
= ((bfd_signed_vma
)0x1 << howto
->bitsize
) - 1;
2044 switch (howto
->type
)
2046 case R_LARCH_SOP_POP_32_S_0_10_10_16_S2
:
2048 /* Perform insn bits field. 15:0<<10, 25:16>>16. */
2049 val
= ((val
& 0xffff) << 10) | ((val
>> 16) & 0x3ff);
2051 case R_LARCH_SOP_POP_32_S_0_5_10_16_S2
:
2053 /* Perform insn bits field. 15:0<<10, 20:16>>16. */
2054 val
= ((val
& 0xffff) << 10) | ((val
>> 16) & 0x1f);
2056 case R_LARCH_CALL36
:
2057 /* 0x8000: If low 16-bit immediate greater than 0x7fff,
2058 it become to a negative number due to sign-extended,
2059 so the high part need to add 0x8000. */
2060 val
= (((val
+ 0x8000) >> 16) << 5) | (((val
& 0xffff) << 10) << 32);
2063 val
<<= howto
->bitpos
;
2072 reloc_sign_bits (bfd
*abfd
, reloc_howto_type
*howto
, bfd_vma
*fix_val
)
2074 return reloc_bits_sanity (abfd
, howto
, fix_val
, 1);
2078 reloc_unsign_bits (bfd
*abfd
, reloc_howto_type
*howto
, bfd_vma
*fix_val
)
2080 return reloc_bits_sanity (abfd
, howto
, fix_val
, 0);
2084 loongarch_adjust_reloc_bitsfield (bfd
*abfd
, reloc_howto_type
*howto
,
2087 BFD_ASSERT (((loongarch_reloc_howto_type
*)howto
)->adjust_reloc_bits
);
2088 return ((loongarch_reloc_howto_type
*)
2089 howto
)->adjust_reloc_bits (abfd
, howto
, fix_val
);
2092 static bfd_reloc_status_type
2093 loongarch_elf_add_sub_reloc (bfd
*abfd
,
2094 arelent
*reloc_entry
,
2097 asection
*input_section
,
2099 char **error_message ATTRIBUTE_UNUSED
)
2101 reloc_howto_type
*howto
= reloc_entry
->howto
;
2104 if (output_bfd
!= NULL
2105 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
2106 && (!reloc_entry
->howto
->partial_inplace
|| reloc_entry
->addend
== 0))
2108 reloc_entry
->address
+= input_section
->output_offset
;
2109 return bfd_reloc_ok
;
2112 if (output_bfd
!= NULL
)
2113 return bfd_reloc_continue
;
2115 relocation
= symbol
->value
+ symbol
->section
->output_section
->vma
2116 + symbol
->section
->output_offset
+ reloc_entry
->addend
;
2118 bfd_size_type octets
= reloc_entry
->address
2119 * bfd_octets_per_byte (abfd
, input_section
);
2120 if (!bfd_reloc_offset_in_range (reloc_entry
->howto
, abfd
,
2121 input_section
, octets
))
2122 return bfd_reloc_outofrange
;
2124 bfd_vma old_value
= bfd_get (howto
->bitsize
, abfd
,
2125 data
+ reloc_entry
->address
);
2127 switch (howto
->type
)
2134 relocation
= old_value
+ relocation
;
2142 relocation
= old_value
- relocation
;
2146 bfd_put (howto
->bitsize
, abfd
, relocation
, data
+ reloc_entry
->address
);
2148 return bfd_reloc_ok
;
2151 static bfd_reloc_status_type
2152 loongarch_elf_add_sub_reloc_uleb128 (bfd
*abfd
,
2153 arelent
*reloc_entry
,
2156 asection
*input_section
,
2158 char **error_message ATTRIBUTE_UNUSED
)
2160 reloc_howto_type
*howto
= reloc_entry
->howto
;
2163 if (output_bfd
!= NULL
2164 && (symbol
->flags
& BSF_SECTION_SYM
) == 0
2165 && (!reloc_entry
->howto
->partial_inplace
|| reloc_entry
->addend
== 0))
2167 reloc_entry
->address
+= input_section
->output_offset
;
2168 return bfd_reloc_ok
;
2171 if (output_bfd
!= NULL
)
2172 return bfd_reloc_continue
;
2174 relocation
= symbol
->value
+ symbol
->section
->output_section
->vma
2175 + symbol
->section
->output_offset
+ reloc_entry
->addend
;
2177 bfd_size_type octets
= reloc_entry
->address
2178 * bfd_octets_per_byte (abfd
, input_section
);
2179 if (!bfd_reloc_offset_in_range (reloc_entry
->howto
, abfd
,
2180 input_section
, octets
))
2181 return bfd_reloc_outofrange
;
2183 unsigned int len
= 0;
2184 bfd_byte
*p
= data
+ reloc_entry
->address
;
2185 bfd_vma old_value
= _bfd_read_unsigned_leb128 (abfd
, p
, &len
);
2187 switch (howto
->type
)
2189 case R_LARCH_ADD_ULEB128
:
2190 relocation
= old_value
+ relocation
;
2193 case R_LARCH_SUB_ULEB128
:
2194 relocation
= old_value
- relocation
;
2198 bfd_vma mask
= (1 << (7 * len
)) - 1;
2199 relocation
= relocation
& mask
;
2200 loongarch_write_unsigned_leb128 (p
, len
, relocation
);
2201 return bfd_reloc_ok
;
2204 /* Write VALUE in uleb128 format to P.
2205 LEN is the uleb128 value length.
2206 Return a pointer to the byte following the last byte that was written. */
2208 loongarch_write_unsigned_leb128 (bfd_byte
*p
, unsigned int len
, bfd_vma value
)
2224 int loongarch_get_uleb128_length (bfd_byte
*buf
)
2226 unsigned int len
= 0;
2227 _bfd_read_unsigned_leb128 (NULL
, buf
, &len
);