Home | History | Annotate | Line # | Download | only in bfd
elfxx-loongarch.c revision 1.1.1.2
      1      1.1  christos /* LoongArch-specific support for ELF.
      2  1.1.1.2  christos    Copyright (C) 2021-2024 Free Software Foundation, Inc.
      3      1.1  christos    Contributed by Loongson Ltd.
      4      1.1  christos 
      5      1.1  christos    Based on RISC-V target.
      6      1.1  christos 
      7      1.1  christos    This file is part of BFD, the Binary File Descriptor library.
      8      1.1  christos 
      9      1.1  christos    This program is free software; you can redistribute it and/or modify
     10      1.1  christos    it under the terms of the GNU General Public License as published by
     11      1.1  christos    the Free Software Foundation; either version 3 of the License, or
     12      1.1  christos    (at your option) any later version.
     13      1.1  christos 
     14      1.1  christos    This program is distributed in the hope that it will be useful,
     15      1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     16      1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17      1.1  christos    GNU General Public License for more details.
     18      1.1  christos 
     19      1.1  christos    You should have received a copy of the GNU General Public License
     20      1.1  christos    along with this program; see the file COPYING3.  If not,
     21      1.1  christos    see <http://www.gnu.org/licenses/>.  */
     22      1.1  christos 
     23      1.1  christos #include "sysdep.h"
     24      1.1  christos #include "bfd.h"
     25      1.1  christos #include "libbfd.h"
     26      1.1  christos #include "elf-bfd.h"
     27      1.1  christos #include "elf/loongarch.h"
     28      1.1  christos #include "elfxx-loongarch.h"
     29      1.1  christos 
     30      1.1  christos #define ALL_ONES (~ (bfd_vma) 0)
     31      1.1  christos 
     32      1.1  christos typedef struct loongarch_reloc_howto_type_struct
     33      1.1  christos {
     34      1.1  christos   /* The first must be reloc_howto_type!  */
     35      1.1  christos   reloc_howto_type howto;
     36      1.1  christos   bfd_reloc_code_real_type bfd_type;
     37  1.1.1.2  christos   bool (*adjust_reloc_bits)(bfd *, reloc_howto_type *, bfd_vma *);
     38  1.1.1.2  christos   const char *larch_reloc_type_name;
     39  1.1.1.2  christos } loongarch_reloc_howto_type;
     40      1.1  christos 
     41      1.1  christos #define LOONGARCH_DEFAULT_HOWTO(r_name)					    \
     42      1.1  christos   { HOWTO (R_LARCH_##r_name, 0, 4, 32, false, 0, complain_overflow_signed,  \
     43      1.1  christos 	bfd_elf_generic_reloc, "R_LARCH_" #r_name, false, 0, ALL_ONES,	    \
     44  1.1.1.2  christos 	false), BFD_RELOC_LARCH_##r_name, NULL, NULL }
     45      1.1  christos 
     46      1.1  christos #define LOONGARCH_HOWTO(type, right, size, bits, pcrel, left, ovf, func,  \
     47  1.1.1.2  christos 	    name, inplace, src_mask, dst_mask, pcrel_off, btype, afunc,lname) \
     48      1.1  christos   { HOWTO(type, right, size, bits, pcrel, left, ovf, func, name,	  \
     49  1.1.1.2  christos 	  inplace, src_mask, dst_mask, pcrel_off), btype, afunc, lname }
     50      1.1  christos 
     51      1.1  christos #define LOONGARCH_EMPTY_HOWTO(C) \
     52  1.1.1.2  christos   { EMPTY_HOWTO (C), BFD_RELOC_NONE, NULL, NULL }
     53      1.1  christos 
     54  1.1.1.2  christos static bool
     55  1.1.1.2  christos reloc_bits (bfd *abfd, reloc_howto_type *howto, bfd_vma *val);
     56  1.1.1.2  christos static bool
     57  1.1.1.2  christos reloc_sign_bits (bfd *abfd, reloc_howto_type *howto, bfd_vma *fix_val);
     58  1.1.1.2  christos 
     59  1.1.1.2  christos static bfd_reloc_status_type
     60  1.1.1.2  christos loongarch_elf_add_sub_reloc (bfd *, arelent *, asymbol *, void *,
     61  1.1.1.2  christos 			      asection *, bfd *, char **);
     62  1.1.1.2  christos 
     63  1.1.1.2  christos static bfd_reloc_status_type
     64  1.1.1.2  christos loongarch_elf_add_sub_reloc_uleb128 (bfd *, arelent *, asymbol *, void *,
     65  1.1.1.2  christos 				      asection *, bfd *, char **);
     66      1.1  christos 
     67      1.1  christos /* This does not include any relocation information, but should be
     68      1.1  christos    good enough for GDB or objdump to read the file.  */
     69      1.1  christos static loongarch_reloc_howto_type loongarch_howto_table[] =
     70      1.1  christos {
     71      1.1  christos   /* No relocation.  */
     72      1.1  christos     LOONGARCH_HOWTO (R_LARCH_NONE,	  /* type (0).  */
     73      1.1  christos 	 0,				  /* rightshift */
     74      1.1  christos 	 0,				  /* size */
     75      1.1  christos 	 0,				  /* bitsize */
     76      1.1  christos 	 false,				  /* pc_relative */
     77      1.1  christos 	 0,				  /* bitpos */
     78      1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
     79      1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
     80      1.1  christos 	 "R_LARCH_NONE",		  /* name */
     81      1.1  christos 	 false,				  /* partial_inplace */
     82      1.1  christos 	 0,				  /* src_mask */
     83      1.1  christos 	 0,				  /* dst_mask */
     84      1.1  christos 	 false,				  /* pcrel_offset */
     85      1.1  christos 	 BFD_RELOC_NONE,		  /* bfd_reloc_code_real_type */
     86  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits */
     87  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name */
     88      1.1  christos 
     89      1.1  christos   /* 32 bit relocation.  */
     90      1.1  christos   LOONGARCH_HOWTO (R_LARCH_32,		  /* type (1).  */
     91      1.1  christos 	 0,				  /* rightshift */
     92      1.1  christos 	 4,				  /* size */
     93      1.1  christos 	 32,				  /* bitsize */
     94      1.1  christos 	 false,				  /* pc_relative */
     95      1.1  christos 	 0,				  /* bitpos */
     96      1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
     97      1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
     98      1.1  christos 	 "R_LARCH_32",			  /* name */
     99      1.1  christos 	 false,				  /* partial_inplace */
    100      1.1  christos 	 0,				  /* src_mask */
    101      1.1  christos 	 ALL_ONES,			  /* dst_mask */
    102      1.1  christos 	 false,				  /* pcrel_offset */
    103      1.1  christos 	 BFD_RELOC_32,			  /* bfd_reloc_code_real_type */
    104  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits */
    105  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name */
    106      1.1  christos 
    107      1.1  christos   /* 64 bit relocation.  */
    108      1.1  christos   LOONGARCH_HOWTO (R_LARCH_64,		  /* type (2).  */
    109      1.1  christos 	 0,				  /* rightshift */
    110      1.1  christos 	 8,				  /* size */
    111      1.1  christos 	 64,				  /* bitsize */
    112      1.1  christos 	 false,				  /* pc_relative */
    113      1.1  christos 	 0,				  /* bitpos */
    114      1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    115      1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    116      1.1  christos 	 "R_LARCH_64",			  /* name */
    117      1.1  christos 	 false,				  /* partial_inplace */
    118      1.1  christos 	 0,				  /* src_mask */
    119      1.1  christos 	 ALL_ONES,			  /* dst_mask */
    120      1.1  christos 	 false,				  /* pcrel_offset */
    121      1.1  christos 	 BFD_RELOC_64,			  /* bfd_reloc_code_real_type */
    122  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits */
    123  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name */
    124      1.1  christos 
    125      1.1  christos   LOONGARCH_HOWTO (R_LARCH_RELATIVE,	  /* type (3).  */
    126      1.1  christos 	 0,				  /* rightshift */
    127      1.1  christos 	 4,				  /* size */
    128      1.1  christos 	 32,				  /* bitsize */
    129      1.1  christos 	 false,				  /* pc_relative */
    130      1.1  christos 	 0,				  /* bitpos */
    131      1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    132      1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    133      1.1  christos 	 "R_LARCH_RELATIVE",		  /* name */
    134      1.1  christos 	 false,				  /* partial_inplace */
    135      1.1  christos 	 0,				  /* src_mask */
    136      1.1  christos 	 ALL_ONES,			  /* dst_mask */
    137      1.1  christos 	 false,				  /* pcrel_offset */
    138      1.1  christos 	 BFD_RELOC_NONE,		  /* undefined?  */
    139  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits */
    140  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name */
    141      1.1  christos 
    142      1.1  christos   LOONGARCH_HOWTO (R_LARCH_COPY,	  /* type (4).  */
    143      1.1  christos 	 0,				  /* rightshift */
    144      1.1  christos 	 0,				  /* this one is variable size */
    145      1.1  christos 	 0,				  /* bitsize */
    146      1.1  christos 	 false,				  /* pc_relative */
    147      1.1  christos 	 0,				  /* bitpos */
    148      1.1  christos 	 complain_overflow_bitfield,	  /* complain_on_overflow */
    149      1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    150      1.1  christos 	 "R_LARCH_COPY",		  /* name */
    151      1.1  christos 	 false,				  /* partial_inplace */
    152      1.1  christos 	 0,				  /* src_mask */
    153      1.1  christos 	 0,				  /* dst_mask */
    154      1.1  christos 	 false,				  /* pcrel_offset */
    155  1.1.1.2  christos 	 BFD_RELOC_NONE,		  /* undefined?  */
    156  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits */
    157  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name */
    158      1.1  christos 
    159      1.1  christos   LOONGARCH_HOWTO (R_LARCH_JUMP_SLOT,	  /* type (5).  */
    160      1.1  christos 	 0,				  /* rightshift */
    161      1.1  christos 	 8,				  /* size */
    162      1.1  christos 	 64,				  /* bitsize */
    163      1.1  christos 	 false,				  /* pc_relative */
    164      1.1  christos 	 0,				  /* bitpos */
    165      1.1  christos 	 complain_overflow_bitfield,	  /* complain_on_overflow */
    166      1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    167      1.1  christos 	 "R_LARCH_JUMP_SLOT",		  /* name */
    168      1.1  christos 	 false,				  /* partial_inplace */
    169      1.1  christos 	 0,				  /* src_mask */
    170      1.1  christos 	 0,				  /* dst_mask */
    171      1.1  christos 	 false,				  /* pcrel_offset */
    172  1.1.1.2  christos 	 BFD_RELOC_NONE,		  /* undefined?  */
    173  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits */
    174  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name */
    175      1.1  christos 
    176      1.1  christos   /* Dynamic TLS relocations.  */
    177      1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DTPMOD32,  /* type (6).  */
    178      1.1  christos 	 0,				  /* rightshift */
    179      1.1  christos 	 4,				  /* size */
    180      1.1  christos 	 32,				  /* bitsize */
    181      1.1  christos 	 false,				  /* pc_relative */
    182      1.1  christos 	 0,				  /* bitpos */
    183      1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    184      1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    185      1.1  christos 	 "R_LARCH_TLS_DTPMOD32",	  /* name */
    186      1.1  christos 	 false,				  /* partial_inplace */
    187      1.1  christos 	 0,				  /* src_mask */
    188      1.1  christos 	 ALL_ONES,			  /* dst_mask */
    189      1.1  christos 	 false,				  /* pcrel_offset */
    190      1.1  christos 	 BFD_RELOC_LARCH_TLS_DTPMOD32,	  /* bfd_reloc_code_real_type */
    191  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits */
    192  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name */
    193      1.1  christos 
    194      1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DTPMOD64,  /* type (7).  */
    195      1.1  christos 	 0,				  /* rightshift */
    196      1.1  christos 	 8,				  /* size */
    197      1.1  christos 	 64,				  /* bitsize */
    198      1.1  christos 	 false,				  /* pc_relative */
    199      1.1  christos 	 0,				  /* bitpos */
    200      1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    201      1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    202      1.1  christos 	 "R_LARCH_TLS_DTPMOD64",	  /* name */
    203      1.1  christos 	 false,				  /* partial_inplace */
    204      1.1  christos 	 0,				  /* src_mask */
    205      1.1  christos 	 ALL_ONES,			  /* dst_mask */
    206      1.1  christos 	 false,				  /* pcrel_offset */
    207      1.1  christos 	 BFD_RELOC_LARCH_TLS_DTPMOD64,	  /* bfd_reloc_code_real_type */
    208  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits */
    209  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name */
    210      1.1  christos 
    211      1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DTPREL32,  /* type (8). */
    212      1.1  christos 	 0,				  /* rightshift */
    213      1.1  christos 	 4,				  /* size */
    214      1.1  christos 	 32,				  /* bitsize */
    215      1.1  christos 	 false,				  /* pc_relative */
    216      1.1  christos 	 0,				  /* bitpos */
    217      1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    218      1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    219      1.1  christos 	 "R_LARCH_TLS_DTPREL32",	  /* name */
    220      1.1  christos 	 true,				  /* partial_inplace */
    221      1.1  christos 	 0,				  /* src_mask */
    222      1.1  christos 	 ALL_ONES,			  /* dst_mask */
    223      1.1  christos 	 false,				  /* pcrel_offset */
    224      1.1  christos 	 BFD_RELOC_LARCH_TLS_DTPREL32,	  /* bfd_reloc_code_real_type */
    225  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits */
    226  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name */
    227      1.1  christos 
    228      1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DTPREL64,  /* type (9).  */
    229      1.1  christos 	 0,				  /* rightshift */
    230      1.1  christos 	 8,				  /* size */
    231      1.1  christos 	 64,				  /* bitsize */
    232      1.1  christos 	 false,				  /* pc_relative */
    233      1.1  christos 	 0,				  /* bitpos */
    234      1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    235      1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    236      1.1  christos 	 "R_LARCH_TLS_DTPREL64",	  /* name */
    237      1.1  christos 	 true,				  /* partial_inplace */
    238      1.1  christos 	 0,				  /* src_mask */
    239      1.1  christos 	 ALL_ONES,			  /* dst_mask */
    240      1.1  christos 	 false,				  /* pcrel_offset */
    241      1.1  christos 	 BFD_RELOC_LARCH_TLS_DTPREL64,	  /* bfd_reloc_code_real_type */
    242  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits */
    243  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name */
    244      1.1  christos 
    245      1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_TPREL32,	  /* type (10).  */
    246      1.1  christos 	 0,				  /* rightshift */
    247      1.1  christos 	 4,				  /* size */
    248      1.1  christos 	 32,				  /* bitsize */
    249      1.1  christos 	 false,				  /* pc_relative */
    250      1.1  christos 	 0,				  /* bitpos */
    251      1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    252      1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    253      1.1  christos 	 "R_LARCH_TLS_TPREL32",		  /* name */
    254      1.1  christos 	 false,				  /* partial_inplace */
    255      1.1  christos 	 0,				  /* src_mask */
    256      1.1  christos 	 ALL_ONES,			  /* dst_mask */
    257      1.1  christos 	 false,				  /* pcrel_offset */
    258      1.1  christos 	 BFD_RELOC_LARCH_TLS_TPREL32,	  /* bfd_reloc_code_real_type */
    259  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits */
    260  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name */
    261      1.1  christos 
    262      1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_TPREL64,	  /* type (11).  */
    263      1.1  christos 	 0,				  /* rightshift */
    264      1.1  christos 	 8,				  /* size */
    265      1.1  christos 	 64,				  /* bitsize */
    266      1.1  christos 	 false,				  /* pc_relative */
    267      1.1  christos 	 0,				  /* bitpos */
    268      1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    269      1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    270      1.1  christos 	 "R_LARCH_TLS_TPREL64",		  /* name */
    271      1.1  christos 	 false,				  /* partial_inplace */
    272      1.1  christos 	 0,				  /* src_mask */
    273      1.1  christos 	 ALL_ONES,			  /* dst_mask */
    274      1.1  christos 	 false,				  /* pcrel_offset */
    275      1.1  christos 	 BFD_RELOC_LARCH_TLS_TPREL64,	  /* bfd_reloc_code_real_type */
    276  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits */
    277  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name */
    278      1.1  christos 
    279      1.1  christos   LOONGARCH_HOWTO (R_LARCH_IRELATIVE,	  /* type (12).  */
    280      1.1  christos 	 0,				  /* rightshift */
    281      1.1  christos 	 4,				  /* size */
    282      1.1  christos 	 32,				  /* bitsize */
    283      1.1  christos 	 false,				  /* pc_relative */
    284      1.1  christos 	 0,				  /* bitpos */
    285      1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    286      1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    287      1.1  christos 	 "R_LARCH_IRELATIVE",		  /* name */
    288      1.1  christos 	 false,				  /* partial_inplace */
    289      1.1  christos 	 0,				  /* src_mask */
    290      1.1  christos 	 ALL_ONES,			  /* dst_mask */
    291      1.1  christos 	 false,				  /* pcrel_offset */
    292      1.1  christos 	 BFD_RELOC_NONE,		  /* undefined?  */
    293  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits */
    294  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name */
    295      1.1  christos 
    296  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DESC32,	  /* type (13).  */
    297  1.1.1.2  christos 	 0,				  /* rightshift.  */
    298  1.1.1.2  christos 	 4,				  /* size.  */
    299  1.1.1.2  christos 	 32,				  /* bitsize.  */
    300  1.1.1.2  christos 	 false,				  /* pc_relative.  */
    301  1.1.1.2  christos 	 0,				  /* bitpos.  */
    302  1.1.1.2  christos 	 complain_overflow_dont,	  /* complain_on_overflow.  */
    303  1.1.1.2  christos 	 bfd_elf_generic_reloc,		  /* special_function.  */
    304  1.1.1.2  christos 	 "R_LARCH_TLS_DESC32",		  /* name.  */
    305  1.1.1.2  christos 	 false,				  /* partial_inplace.  */
    306  1.1.1.2  christos 	 0,				  /* src_mask.  */
    307  1.1.1.2  christos 	 ALL_ONES,		  	  /* dst_mask.  */
    308  1.1.1.2  christos 	 false,				  /* pcrel_offset.  */
    309  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_DESC32,	  /* bfd_reloc_code_real_type.  */
    310  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits.  */
    311  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name.  */
    312  1.1.1.2  christos 
    313  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DESC64,	  /* type (14).  */
    314  1.1.1.2  christos 	 0,				  /* rightshift.  */
    315  1.1.1.2  christos 	 4,				  /* size.  */
    316  1.1.1.2  christos 	 64,				  /* bitsize.  */
    317  1.1.1.2  christos 	 false,				  /* pc_relative.  */
    318  1.1.1.2  christos 	 0,				  /* bitpos.  */
    319  1.1.1.2  christos 	 complain_overflow_dont,	  /* complain_on_overflow.  */
    320  1.1.1.2  christos 	 bfd_elf_generic_reloc,		  /* special_function.  */
    321  1.1.1.2  christos 	 "R_LARCH_TLS_DESC64",		  /* name.  */
    322  1.1.1.2  christos 	 false,				  /* partial_inplace.  */
    323  1.1.1.2  christos 	 0,				  /* src_mask.  */
    324  1.1.1.2  christos 	 ALL_ONES,			  /* dst_mask.  */
    325  1.1.1.2  christos 	 false,				  /* pcrel_offset.  */
    326  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_DESC64,	  /* bfd_reloc_code_real_type.  */
    327  1.1.1.2  christos 	 NULL,				  /* adjust_reloc_bits.  */
    328  1.1.1.2  christos 	 NULL),				  /* larch_reloc_type_name.  */
    329  1.1.1.2  christos 
    330  1.1.1.2  christos   LOONGARCH_EMPTY_HOWTO (15),
    331  1.1.1.2  christos   LOONGARCH_EMPTY_HOWTO (16),
    332  1.1.1.2  christos   LOONGARCH_EMPTY_HOWTO (17),
    333  1.1.1.2  christos   LOONGARCH_EMPTY_HOWTO (18),
    334  1.1.1.2  christos   LOONGARCH_EMPTY_HOWTO (19),
    335      1.1  christos 
    336      1.1  christos   LOONGARCH_HOWTO (R_LARCH_MARK_LA,		/* type (20).  */
    337  1.1.1.2  christos 	 0,					/* rightshift.  */
    338  1.1.1.2  christos 	 0,					/* size.  */
    339  1.1.1.2  christos 	 0,					/* bitsize.  */
    340  1.1.1.2  christos 	 false,					/* pc_relative.  */
    341  1.1.1.2  christos 	 0,					/* bitpos.  */
    342  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    343  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    344      1.1  christos 	 "R_LARCH_MARK_LA",			/* name.  */
    345  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    346      1.1  christos 	 0,					/* src_mask.  */
    347      1.1  christos 	 0,					/* dst_mask.  */
    348      1.1  christos 	 false,					/* pcrel_offset */
    349      1.1  christos 	 BFD_RELOC_LARCH_MARK_LA,		/* bfd_reloc_code_real_type */
    350  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits */
    351  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name */
    352      1.1  christos 
    353      1.1  christos   LOONGARCH_HOWTO (R_LARCH_MARK_PCREL,		/* type (21).  */
    354  1.1.1.2  christos 	 0,					/* rightshift.  */
    355  1.1.1.2  christos 	 0,					/* size.  */
    356  1.1.1.2  christos 	 0,					/* bitsize.  */
    357  1.1.1.2  christos 	 false,					/* pc_relative.  */
    358  1.1.1.2  christos 	 0,					/* bitpos.  */
    359  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    360  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    361      1.1  christos 	 "R_LARCH_MARK_PCREL",			/* name.  */
    362  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    363      1.1  christos 	 0,					/* src_mask.  */
    364      1.1  christos 	 0,					/* dst_mask.  */
    365      1.1  christos 	 false,					/* pcrel_offset */
    366      1.1  christos 	 BFD_RELOC_LARCH_MARK_PCREL,		/* bfd_reloc_code_real_type */
    367  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits */
    368  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name */
    369      1.1  christos 
    370      1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_PUSH_PCREL,	/* type (22).  */
    371  1.1.1.2  christos 	 2,					/* rightshift.  */
    372  1.1.1.2  christos 	 4,					/* size.  */
    373  1.1.1.2  christos 	 32,					/* bitsize.  */
    374      1.1  christos 	 true /* FIXME: somewhat use this.  */,	/* pc_relative.  */
    375  1.1.1.2  christos 	 0,					/* bitpos.  */
    376  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    377  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    378  1.1.1.2  christos 	 "R_LARCH_SOP_PUSH_PCREL",		/* name.  */
    379  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    380      1.1  christos 	 0x03ffffff,				/* src_mask.  */
    381      1.1  christos 	 0x03ffffff,				/* dst_mask.  */
    382      1.1  christos 	 false,					/* pcrel_offset */
    383      1.1  christos 	 BFD_RELOC_LARCH_SOP_PUSH_PCREL,	/* bfd_reloc_code_real_type */
    384  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits */
    385  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name */
    386      1.1  christos 
    387      1.1  christos   /* type 23-37.  */
    388      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_ABSOLUTE),
    389      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_DUP),
    390      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_GPREL),
    391      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_TLS_TPREL),
    392      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_TLS_GOT),
    393      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_TLS_GD),
    394      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_PLT_PCREL),
    395      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_ASSERT),
    396      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_NOT),
    397      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_SUB),
    398      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_SL),
    399      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_SR),
    400      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_ADD),
    401      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_AND),
    402      1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_IF_ELSE),
    403      1.1  christos 
    404      1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_10_5,	  /* type (38).  */
    405  1.1.1.2  christos 	 0,					  /* rightshift.  */
    406  1.1.1.2  christos 	 4,					  /* size.  */
    407  1.1.1.2  christos 	 5,					  /* bitsize.  */
    408      1.1  christos 	 false,					  /* pc_relative.  */
    409  1.1.1.2  christos 	 10,					  /* bitpos.  */
    410  1.1.1.2  christos 	 complain_overflow_signed,		  /* complain_on_overflow.  */
    411  1.1.1.2  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    412  1.1.1.2  christos 	 "R_LARCH_SOP_POP_32_S_10_5",		  /* name.  */
    413  1.1.1.2  christos 	 false,					  /* partial_inplace.  */
    414      1.1  christos 	 0,					  /* src_mask */
    415      1.1  christos 	 0x7c00,				  /* dst_mask */
    416      1.1  christos 	 false,					  /* pcrel_offset */
    417      1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_10_5,	  /* bfd_reloc_code_real_type */
    418  1.1.1.2  christos 	 reloc_bits,				  /* adjust_reloc_bits */
    419  1.1.1.2  christos 	 NULL),					  /* larch_reloc_type_name */
    420      1.1  christos 
    421      1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_U_10_12,	  /* type (39).  */
    422  1.1.1.2  christos 	 0,					  /* rightshift.  */
    423  1.1.1.2  christos 	 4,					  /* size.  */
    424  1.1.1.2  christos 	 12,					  /* bitsize.  */
    425      1.1  christos 	 false,					  /* pc_relative.  */
    426  1.1.1.2  christos 	 10,					  /* bitpos.  */
    427  1.1.1.2  christos 	 complain_overflow_unsigned,		  /* complain_on_overflow.  */
    428  1.1.1.2  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    429  1.1.1.2  christos 	 "R_LARCH_SOP_POP_32_U_10_12",		  /* name.  */
    430  1.1.1.2  christos 	 false,					  /* partial_inplace.  */
    431      1.1  christos 	 0,					  /* src_mask */
    432      1.1  christos 	 0x3ffc00,				  /* dst_mask */
    433      1.1  christos 	 false,					  /* pcrel_offset */
    434      1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_U_10_12,	  /* bfd_reloc_code_real_type */
    435  1.1.1.2  christos 	 reloc_bits,				  /* adjust_reloc_bits */
    436  1.1.1.2  christos 	 NULL),					  /* larch_reloc_type_name */
    437      1.1  christos 
    438      1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_10_12,	  /* type (40).  */
    439  1.1.1.2  christos 	 0,					  /* rightshift.  */
    440  1.1.1.2  christos 	 4,					  /* size.  */
    441  1.1.1.2  christos 	 12,					  /* bitsize.  */
    442      1.1  christos 	 false,					  /* pc_relative.  */
    443  1.1.1.2  christos 	 10,					  /* bitpos.  */
    444  1.1.1.2  christos 	 complain_overflow_signed,		  /* complain_on_overflow.  */
    445  1.1.1.2  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    446  1.1.1.2  christos 	 "R_LARCH_SOP_POP_32_S_10_12",		  /* name.  */
    447  1.1.1.2  christos 	 false,					  /* partial_inplace.  */
    448      1.1  christos 	 0,					  /* src_mask */
    449      1.1  christos 	 0x3ffc00,				  /* dst_mask */
    450      1.1  christos 	 false,					  /* pcrel_offset */
    451      1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_10_12,	  /* bfd_reloc_code_real_type */
    452  1.1.1.2  christos 	 reloc_bits,				  /* adjust_reloc_bits */
    453  1.1.1.2  christos 	 NULL),					  /* larch_reloc_type_name */
    454      1.1  christos 
    455      1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_10_16,	  /* type (41).  */
    456  1.1.1.2  christos 	 0,					  /* rightshift.  */
    457  1.1.1.2  christos 	 4,					  /* size.  */
    458  1.1.1.2  christos 	 16,					  /* bitsize.  */
    459      1.1  christos 	 false,					  /* pc_relative.  */
    460  1.1.1.2  christos 	 10,					  /* bitpos.  */
    461  1.1.1.2  christos 	 complain_overflow_signed,		  /* complain_on_overflow.  */
    462  1.1.1.2  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    463  1.1.1.2  christos 	 "R_LARCH_SOP_POP_32_S_10_16",		  /* name.  */
    464  1.1.1.2  christos 	 false,					  /* partial_inplace.  */
    465      1.1  christos 	 0,					  /* src_mask */
    466      1.1  christos 	 0x3fffc00,				  /* dst_mask */
    467      1.1  christos 	 false,					  /* pcrel_offset */
    468      1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_10_16,	  /* bfd_reloc_code_real_type */
    469  1.1.1.2  christos 	 reloc_bits,				  /* adjust_reloc_bits */
    470  1.1.1.2  christos 	 NULL),					  /* larch_reloc_type_name */
    471      1.1  christos 
    472      1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_10_16_S2, /* type (42).  */
    473      1.1  christos 	 2,					  /* rightshift.  */
    474  1.1.1.2  christos 	 4,					  /* size.  */
    475  1.1.1.2  christos 	 16,					  /* bitsize.  */
    476      1.1  christos 	 false,					  /* pc_relative.  */
    477  1.1.1.2  christos 	 10,					  /* bitpos.  */
    478  1.1.1.2  christos 	 complain_overflow_signed,		  /* complain_on_overflow.  */
    479  1.1.1.2  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    480  1.1.1.2  christos 	 "R_LARCH_SOP_POP_32_S_10_16_S2",	  /* name.  */
    481  1.1.1.2  christos 	 false,					  /* partial_inplace.  */
    482      1.1  christos 	 0,					  /* src_mask */
    483      1.1  christos 	 0x3fffc00,				  /* dst_mask */
    484      1.1  christos 	 false,					  /* pcrel_offset */
    485      1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_10_16_S2,	  /* bfd_reloc_code_real_type */
    486  1.1.1.2  christos 	 reloc_sign_bits,			  /* adjust_reloc_bits */
    487  1.1.1.2  christos 	 NULL),					  /* larch_reloc_type_name */
    488      1.1  christos 
    489      1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_5_20,	  /* type (43).  */
    490  1.1.1.2  christos 	 0,					  /* rightshift.  */
    491  1.1.1.2  christos 	 4,					  /* size.  */
    492  1.1.1.2  christos 	 20,					  /* bitsize.  */
    493      1.1  christos 	 false,					  /* pc_relative.  */
    494  1.1.1.2  christos 	 5,					  /* bitpos.  */
    495  1.1.1.2  christos 	 complain_overflow_signed,		  /* complain_on_overflow.  */
    496  1.1.1.2  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    497  1.1.1.2  christos 	 "R_LARCH_SOP_POP_32_S_5_20",		  /* name.  */
    498  1.1.1.2  christos 	 false,					  /* partial_inplace.  */
    499      1.1  christos 	 0,					  /* src_mask */
    500      1.1  christos 	 0x1ffffe0,				  /* dst_mask */
    501      1.1  christos 	 false,					  /* pcrel_offset */
    502      1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_5_20,	  /* bfd_reloc_code_real_type */
    503  1.1.1.2  christos 	 reloc_bits,				  /* adjust_reloc_bits */
    504  1.1.1.2  christos 	 NULL),					  /* larch_reloc_type_name */
    505      1.1  christos 
    506      1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_0_5_10_16_S2,
    507      1.1  christos 						  /* type (44).  */
    508      1.1  christos 	 2,					  /* rightshift.  */
    509      1.1  christos 	 4,					  /* size.  */
    510  1.1.1.2  christos 	 21,					  /* bitsize.  */
    511      1.1  christos 	 false,					  /* pc_relative.  */
    512  1.1.1.2  christos 	 0,					  /* bitpos.  */
    513  1.1.1.2  christos 	 complain_overflow_signed,		  /* complain_on_overflow.  */
    514  1.1.1.2  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    515  1.1.1.2  christos 	 "R_LARCH_SOP_POP_32_S_0_5_10_16_S2",	  /* name.  */
    516  1.1.1.2  christos 	 false,					  /* partial_inplace.  */
    517      1.1  christos 	 0xfc0003e0,				  /* src_mask */
    518      1.1  christos 	 0xfc0003e0,				  /* dst_mask */
    519      1.1  christos 	 false,					  /* pcrel_offset */
    520      1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_0_5_10_16_S2,
    521      1.1  christos 						  /* bfd_reloc_code_real_type */
    522  1.1.1.2  christos 	 reloc_sign_bits,			  /* adjust_reloc_bits */
    523  1.1.1.2  christos 	 NULL),					  /* larch_reloc_type_name */
    524      1.1  christos 
    525      1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_0_10_10_16_S2,	/* type (45).  */
    526  1.1.1.2  christos 	 2,					/* rightshift.  */
    527  1.1.1.2  christos 	 4,					/* size.  */
    528  1.1.1.2  christos 	 26,					/* bitsize.  */
    529  1.1.1.2  christos 	 false,					/* pc_relative.  */
    530  1.1.1.2  christos 	 0,					/* bitpos.  */
    531  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    532  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    533  1.1.1.2  christos 	 "R_LARCH_SOP_POP_32_S_0_10_10_16_S2",	/* name.  */
    534  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    535  1.1.1.2  christos 	 0,					/* src_mask */
    536  1.1.1.2  christos 	 0x03ffffff,				/* dst_mask */
    537      1.1  christos 	 false,					/* pcrel_offset */
    538      1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_0_10_10_16_S2,
    539      1.1  christos 						/* bfd_reloc_code_real_type */
    540  1.1.1.2  christos 	 reloc_sign_bits,			/* adjust_reloc_bits */
    541  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name */
    542      1.1  christos 
    543      1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_U,	/* type (46).  */
    544  1.1.1.2  christos 	 0,					/* rightshift.  */
    545  1.1.1.2  christos 	 4,					/* size.  */
    546  1.1.1.2  christos 	 32,					/* bitsize.  */
    547  1.1.1.2  christos 	 false,					/* pc_relative.  */
    548  1.1.1.2  christos 	 0,					/* bitpos.  */
    549  1.1.1.2  christos 	 complain_overflow_unsigned,		/* complain_on_overflow.  */
    550  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    551  1.1.1.2  christos 	 "R_LARCH_SOP_POP_32_S_U",		/* name.  */
    552  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    553      1.1  christos 	 0xffffffff00000000,			/* src_mask */
    554      1.1  christos 	 0x00000000ffffffff,			/* dst_mask */
    555      1.1  christos 	 false,					/* pcrel_offset */
    556      1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_U,		/* bfd_reloc_code_real_type */
    557  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
    558  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name */
    559      1.1  christos 
    560  1.1.1.2  christos   /* 8-bit in-place addition, for local label subtraction.  */
    561  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_ADD8,		/* type (47).  */
    562  1.1.1.2  christos 	 0,					/* rightshift.  */
    563  1.1.1.2  christos 	 1,					/* size.  */
    564  1.1.1.2  christos 	 8,					/* bitsize.  */
    565  1.1.1.2  christos 	 false,					/* pc_relative.  */
    566  1.1.1.2  christos 	 0,					/* bitpos.  */
    567  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
    568  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc,		/* special_function.  */
    569  1.1.1.2  christos 	 "R_LARCH_ADD8",			/* name.  */
    570  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    571  1.1.1.2  christos 	 0,					/* src_mask.  */
    572  1.1.1.2  christos 	 0xff,					/* dst_mask.  */
    573  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
    574  1.1.1.2  christos 	 BFD_RELOC_LARCH_ADD8,			/* bfd_reloc_code_real_type.  */
    575  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
    576  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
    577  1.1.1.2  christos 
    578  1.1.1.2  christos   /* 16-bit in-place addition, for local label subtraction.  */
    579  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_ADD16,		/* type (48).  */
    580  1.1.1.2  christos 	 0,					/* rightshift.  */
    581  1.1.1.2  christos 	 2,					/* size.  */
    582  1.1.1.2  christos 	 16,					/* bitsize.  */
    583  1.1.1.2  christos 	 false,					/* pc_relative.  */
    584  1.1.1.2  christos 	 0,					/* bitpos.  */
    585  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
    586  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc,		/* special_function.  */
    587  1.1.1.2  christos 	 "R_LARCH_ADD16",			/* name.  */
    588  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    589  1.1.1.2  christos 	 0,					/* src_mask.  */
    590  1.1.1.2  christos 	 0xffff,				/* dst_mask.  */
    591  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
    592  1.1.1.2  christos 	 BFD_RELOC_LARCH_ADD16,			/* bfd_reloc_code_real_type.  */
    593  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
    594  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
    595  1.1.1.2  christos 
    596  1.1.1.2  christos   /* 24-bit in-place addition, for local label subtraction.  */
    597  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_ADD24,		/* type (49).  */
    598  1.1.1.2  christos 	 0,					/* rightshift.  */
    599  1.1.1.2  christos 	 3,					/* size.  */
    600  1.1.1.2  christos 	 24,					/* bitsize.  */
    601  1.1.1.2  christos 	 false,					/* pc_relative.  */
    602  1.1.1.2  christos 	 0,					/* bitpos.  */
    603  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
    604  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc,		/* special_function.  */
    605  1.1.1.2  christos 	 "R_LARCH_ADD24",			/* name.  */
    606  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    607  1.1.1.2  christos 	 0,					/* src_mask.  */
    608  1.1.1.2  christos 	 0xffffff,				/* dst_mask.  */
    609  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
    610  1.1.1.2  christos 	 BFD_RELOC_LARCH_ADD24,			/* bfd_reloc_code_real_type.  */
    611  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
    612  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
    613  1.1.1.2  christos 
    614  1.1.1.2  christos   /* 32-bit in-place addition, for local label subtraction.  */
    615  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_ADD32,		/* type (50).  */
    616  1.1.1.2  christos 	 0,					/* rightshift.  */
    617  1.1.1.2  christos 	 4,					/* size.  */
    618  1.1.1.2  christos 	 32,					/* bitsize.  */
    619  1.1.1.2  christos 	 false,					/* pc_relative.  */
    620  1.1.1.2  christos 	 0,					/* bitpos.  */
    621  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
    622  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc,		/* special_function.  */
    623  1.1.1.2  christos 	 "R_LARCH_ADD32",			/* name.  */
    624  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    625  1.1.1.2  christos 	 0,					/* src_mask.  */
    626  1.1.1.2  christos 	 0xffffffff,				/* dst_mask.  */
    627  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
    628  1.1.1.2  christos 	 BFD_RELOC_LARCH_ADD32,			/* bfd_reloc_code_real_type.  */
    629  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
    630  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
    631  1.1.1.2  christos 
    632  1.1.1.2  christos   /* 64-bit in-place addition, for local label subtraction.  */
    633  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_ADD64,		/* type (51).  */
    634  1.1.1.2  christos 	 0,					/* rightshift.  */
    635  1.1.1.2  christos 	 8,					/* size.  */
    636  1.1.1.2  christos 	 64,					/* bitsize.  */
    637  1.1.1.2  christos 	 false,					/* pc_relative.  */
    638  1.1.1.2  christos 	 0,					/* bitpos.  */
    639  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
    640  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc,		/* special_function.  */
    641  1.1.1.2  christos 	 "R_LARCH_ADD64",			/* name.  */
    642  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    643  1.1.1.2  christos 	 0,					/* src_mask.  */
    644  1.1.1.2  christos 	 ALL_ONES,				/* dst_mask.  */
    645  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
    646  1.1.1.2  christos 	 BFD_RELOC_LARCH_ADD64,			/* bfd_reloc_code_real_type.  */
    647  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
    648  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
    649  1.1.1.2  christos 
    650  1.1.1.2  christos   /* 8-bit in-place subtraction, for local label subtraction.  */
    651  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_SUB8,		/* type (52).  */
    652  1.1.1.2  christos 	 0,					/* rightshift.  */
    653  1.1.1.2  christos 	 1,					/* size.  */
    654  1.1.1.2  christos 	 8,					/* bitsize.  */
    655  1.1.1.2  christos 	 false,					/* pc_relative.  */
    656  1.1.1.2  christos 	 0,					/* bitpos.  */
    657  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
    658  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc,		/* special_function.  */
    659  1.1.1.2  christos 	 "R_LARCH_SUB8",			/* name.  */
    660  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    661  1.1.1.2  christos 	 0,					/* src_mask.  */
    662  1.1.1.2  christos 	 0xff,					/* dst_mask.  */
    663  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
    664  1.1.1.2  christos 	 BFD_RELOC_LARCH_SUB8,			/* bfd_reloc_code_real_type.  */
    665  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
    666  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
    667  1.1.1.2  christos 
    668  1.1.1.2  christos   /* 16-bit in-place subtraction, for local label subtraction.  */
    669  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_SUB16,		/* type (53).  */
    670  1.1.1.2  christos 	 0,					/* rightshift.  */
    671  1.1.1.2  christos 	 2,					/* size.  */
    672  1.1.1.2  christos 	 16,					/* bitsize.  */
    673  1.1.1.2  christos 	 false,					/* pc_relative.  */
    674  1.1.1.2  christos 	 0,					/* bitpos.  */
    675  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
    676  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc,		/* special_function.  */
    677  1.1.1.2  christos 	 "R_LARCH_SUB16",			/* name.  */
    678  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    679  1.1.1.2  christos 	 0,					/* src_mask.  */
    680  1.1.1.2  christos 	 0xffff,				/* dst_mask.  */
    681  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
    682  1.1.1.2  christos 	 BFD_RELOC_LARCH_SUB16,			/* bfd_reloc_code_real_type.  */
    683  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
    684  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
    685  1.1.1.2  christos 
    686  1.1.1.2  christos   /* 24-bit in-place subtraction, for local label subtraction.  */
    687  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_SUB24,		/* type (54).  */
    688  1.1.1.2  christos 	 0,					/* rightshift.  */
    689  1.1.1.2  christos 	 3,					/* size.  */
    690  1.1.1.2  christos 	 24,					/* bitsize.  */
    691  1.1.1.2  christos 	 false,					/* pc_relative.  */
    692  1.1.1.2  christos 	 0,					/* bitpos.  */
    693  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
    694  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc,		/* special_function.  */
    695  1.1.1.2  christos 	 "R_LARCH_SUB24",			/* name.  */
    696  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    697  1.1.1.2  christos 	 0,					/* src_mask.  */
    698  1.1.1.2  christos 	 0xffffff,				/* dst_mask.  */
    699  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
    700  1.1.1.2  christos 	 BFD_RELOC_LARCH_SUB24,			/* bfd_reloc_code_real_type.  */
    701  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
    702  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
    703  1.1.1.2  christos 
    704  1.1.1.2  christos   /* 32-bit in-place subtraction, for local label subtraction.  */
    705  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_SUB32,		/* type (55).  */
    706  1.1.1.2  christos 	 0,					/* rightshift.  */
    707  1.1.1.2  christos 	 4,					/* size.  */
    708  1.1.1.2  christos 	 32,					/* bitsize.  */
    709  1.1.1.2  christos 	 false,					/* pc_relative.  */
    710  1.1.1.2  christos 	 0,					/* bitpos.  */
    711  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
    712  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc,		/* special_function.  */
    713  1.1.1.2  christos 	 "R_LARCH_SUB32",			/* name.  */
    714  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    715  1.1.1.2  christos 	 0,					/* src_mask.  */
    716  1.1.1.2  christos 	 0xffffffff,				/* dst_mask.  */
    717  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
    718  1.1.1.2  christos 	 BFD_RELOC_LARCH_SUB32,			/* bfd_reloc_code_real_type.  */
    719  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
    720  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
    721  1.1.1.2  christos 
    722  1.1.1.2  christos   /* 64-bit in-place subtraction, for local label subtraction.  */
    723  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_SUB64,		/* type (56).  */
    724  1.1.1.2  christos 	 0,					/* rightshift.  */
    725  1.1.1.2  christos 	 8,					/* size.  */
    726  1.1.1.2  christos 	 64,					/* bitsize.  */
    727  1.1.1.2  christos 	 false,					/* pc_relative.  */
    728  1.1.1.2  christos 	 0,					/* bitpos.  */
    729  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
    730  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc,		/* special_function.  */
    731  1.1.1.2  christos 	 "R_LARCH_SUB64",			/* name.  */
    732  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    733  1.1.1.2  christos 	 0,					/* src_mask.  */
    734  1.1.1.2  christos 	 ALL_ONES,				/* dst_mask.  */
    735  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
    736  1.1.1.2  christos 	 BFD_RELOC_LARCH_SUB64,			/* bfd_reloc_code_real_type.  */
    737  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
    738  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
    739  1.1.1.2  christos 
    740  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_GNU_VTINHERIT,	/* type (57).  */
    741  1.1.1.2  christos 	 0,					/* rightshift.  */
    742  1.1.1.2  christos 	 0,					/* size.  */
    743  1.1.1.2  christos 	 0,					/* bitsize.  */
    744  1.1.1.2  christos 	 false,					/* pc_relative.  */
    745  1.1.1.2  christos 	 0,					/* bitpos.  */
    746  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    747  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    748  1.1.1.2  christos 	 "R_LARCH_GNU_VTINHERIT",		/* name.  */
    749  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    750      1.1  christos 	 0,					/* src_mask */
    751      1.1  christos 	 0,					/* dst_mask */
    752      1.1  christos 	 false,					/* pcrel_offset */
    753      1.1  christos 	 BFD_RELOC_NONE,			/* bfd_reloc_code_real_type */
    754  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits */
    755  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name */
    756      1.1  christos 
    757  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_GNU_VTENTRY,		/* type (58).  */
    758  1.1.1.2  christos 	 0,					/* rightshift.  */
    759  1.1.1.2  christos 	 0,					/* size.  */
    760  1.1.1.2  christos 	 0,					/* bitsize.  */
    761      1.1  christos 	 false,					/* pc_relative.  */
    762  1.1.1.2  christos 	 0,					/* bitpos.  */
    763  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    764      1.1  christos 	 NULL,					/* special_function.  */
    765  1.1.1.2  christos 	 "R_LARCH_GNU_VTENTRY",			/* name.  */
    766  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    767      1.1  christos 	 0,					/* src_mask */
    768      1.1  christos 	 0,					/* dst_mask */
    769      1.1  christos 	 false,					/* pcrel_offset */
    770      1.1  christos 	 BFD_RELOC_NONE,			/* bfd_reloc_code_real_type */
    771  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits */
    772  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name */
    773  1.1.1.2  christos 
    774  1.1.1.2  christos   LOONGARCH_EMPTY_HOWTO (59),
    775  1.1.1.2  christos   LOONGARCH_EMPTY_HOWTO (60),
    776  1.1.1.2  christos   LOONGARCH_EMPTY_HOWTO (61),
    777  1.1.1.2  christos   LOONGARCH_EMPTY_HOWTO (62),
    778  1.1.1.2  christos   LOONGARCH_EMPTY_HOWTO (63),
    779  1.1.1.2  christos 
    780  1.1.1.2  christos   /* New reloc types.  */
    781  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_B16,			/* type (64).  */
    782  1.1.1.2  christos 	 2,					/* rightshift.  */
    783  1.1.1.2  christos 	 4,					/* size.  */
    784  1.1.1.2  christos 	 16,					/* bitsize.  */
    785  1.1.1.2  christos 	 false,					/* pc_relative.  */
    786  1.1.1.2  christos 	 10,					/* bitpos.  */
    787  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    788  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    789  1.1.1.2  christos 	 "R_LARCH_B16",				/* name.  */
    790  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    791  1.1.1.2  christos 	 0,					/* src_mask.  */
    792  1.1.1.2  christos 	 0x3fffc00,				/* dst_mask.  */
    793  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
    794  1.1.1.2  christos 	 BFD_RELOC_LARCH_B16,			/* bfd_reloc_code_real_type.  */
    795  1.1.1.2  christos 	 reloc_sign_bits,			/* adjust_reloc_bits.  */
    796  1.1.1.2  christos 	 "b16"),				/* larch_reloc_type_name.  */
    797  1.1.1.2  christos 
    798  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_B21,			/* type (65).  */
    799  1.1.1.2  christos 	 2,					/* rightshift.  */
    800  1.1.1.2  christos 	 4,					/* size.  */
    801  1.1.1.2  christos 	 21,					/* bitsize.  */
    802  1.1.1.2  christos 	 false,					/* pc_relative.  */
    803  1.1.1.2  christos 	 0,					/* bitpos.  */
    804  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    805  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    806  1.1.1.2  christos 	 "R_LARCH_B21",				/* name.  */
    807  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    808  1.1.1.2  christos 	 0,					/* src_mask.  */
    809  1.1.1.2  christos 	 0x3fffc1f,				/* dst_mask.  */
    810  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
    811  1.1.1.2  christos 	 BFD_RELOC_LARCH_B21,			/* bfd_reloc_code_real_type.  */
    812  1.1.1.2  christos 	 reloc_sign_bits,			/* adjust_reloc_bits.  */
    813  1.1.1.2  christos 	 "b21"),				/* larch_reloc_type_name.  */
    814  1.1.1.2  christos 
    815  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_B26,			/* type (66).  */
    816  1.1.1.2  christos 	 2,					/* rightshift.  */
    817  1.1.1.2  christos 	 4,					/* size.  */
    818  1.1.1.2  christos 	 26,					/* bitsize.  */
    819  1.1.1.2  christos 	 false,					/* pc_relative.  */
    820  1.1.1.2  christos 	 0,					/* bitpos.  */
    821  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    822  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    823  1.1.1.2  christos 	 "R_LARCH_B26",				/* name.  */
    824  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    825  1.1.1.2  christos 	 0,					/* src_mask.  */
    826  1.1.1.2  christos 	 0x03ffffff,				/* dst_mask.  */
    827  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
    828  1.1.1.2  christos 	 BFD_RELOC_LARCH_B26,			/* bfd_reloc_code_real_type.  */
    829  1.1.1.2  christos 	 reloc_sign_bits,			/* adjust_reloc_bits.  */
    830  1.1.1.2  christos 	 "b26"),				/* larch_reloc_type_name.  */
    831  1.1.1.2  christos 
    832  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_ABS_HI20,		/* type (67).  */
    833  1.1.1.2  christos 	 12,					/* rightshift.  */
    834  1.1.1.2  christos 	 4,					/* size.  */
    835  1.1.1.2  christos 	 20,					/* bitsize.  */
    836  1.1.1.2  christos 	 false,					/* pc_relative.  */
    837  1.1.1.2  christos 	 5,					/* bitpos.  */
    838  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    839  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    840  1.1.1.2  christos 	 "R_LARCH_ABS_HI20",			/* name.  */
    841  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    842  1.1.1.2  christos 	 0,					/* src_mask */
    843  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
    844  1.1.1.2  christos 	 false,					/* pcrel_offset */
    845  1.1.1.2  christos 	 BFD_RELOC_LARCH_ABS_HI20,		/* bfd_reloc_code_real_type */
    846  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
    847  1.1.1.2  christos 	 "abs_hi20"),				/* larch_reloc_type_name */
    848  1.1.1.2  christos 
    849  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_ABS_LO12,		/* type (68).  */
    850  1.1.1.2  christos 	 0,					/* rightshift.  */
    851  1.1.1.2  christos 	 4,					/* size.  */
    852  1.1.1.2  christos 	 12,					/* bitsize.  */
    853  1.1.1.2  christos 	 false,					/* pc_relative.  */
    854  1.1.1.2  christos 	 10,					/* bitpos.  */
    855  1.1.1.2  christos 	 complain_overflow_unsigned,		/* complain_on_overflow.  */
    856  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    857  1.1.1.2  christos 	 "R_LARCH_ABS_LO12",			/* name.  */
    858  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    859  1.1.1.2  christos 	 0,					/* src_mask */
    860  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
    861  1.1.1.2  christos 	 false,					/* pcrel_offset */
    862  1.1.1.2  christos 	 BFD_RELOC_LARCH_ABS_LO12,		/* bfd_reloc_code_real_type */
    863  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
    864  1.1.1.2  christos 	 "abs_lo12"),				/* larch_reloc_type_name */
    865  1.1.1.2  christos 
    866  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_ABS64_LO20,		/* type (69).  */
    867  1.1.1.2  christos 	 32,					/* rightshift.  */
    868  1.1.1.2  christos 	 4,					/* size.  */
    869  1.1.1.2  christos 	 20,					/* bitsize.  */
    870  1.1.1.2  christos 	 false,					/* pc_relative.  */
    871  1.1.1.2  christos 	 5,					/* bitpos.  */
    872  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    873  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    874  1.1.1.2  christos 	 "R_LARCH_ABS64_LO20",			/* name.  */
    875  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    876  1.1.1.2  christos 	 0,					/* src_mask */
    877  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
    878  1.1.1.2  christos 	 false,					/* pcrel_offset */
    879  1.1.1.2  christos 	 BFD_RELOC_LARCH_ABS64_LO20,		/* bfd_reloc_code_real_type */
    880  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
    881  1.1.1.2  christos 	 "abs64_lo20"),				/* larch_reloc_type_name */
    882  1.1.1.2  christos 
    883  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_ABS64_HI12,		/* type (70).  */
    884  1.1.1.2  christos 	 52,					/* rightshift.  */
    885  1.1.1.2  christos 	 4,					/* size.  */
    886  1.1.1.2  christos 	 12,					/* bitsize.  */
    887  1.1.1.2  christos 	 false,					/* pc_relative.  */
    888  1.1.1.2  christos 	 10,					/* bitpos.  */
    889  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    890  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    891  1.1.1.2  christos 	 "R_LARCH_ABS64_HI12",			/* name.  */
    892  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    893  1.1.1.2  christos 	 0,					/* src_mask */
    894  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
    895  1.1.1.2  christos 	 false,					/* pcrel_offset */
    896  1.1.1.2  christos 	 BFD_RELOC_LARCH_ABS64_HI12,		/* bfd_reloc_code_real_type */
    897  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
    898  1.1.1.2  christos 	 "abs64_hi12"),				/* larch_reloc_type_name */
    899  1.1.1.2  christos 
    900  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_PCALA_HI20,		/* type (71).  */
    901  1.1.1.2  christos 	 12,					/* rightshift.  */
    902  1.1.1.2  christos 	 4,					/* size.  */
    903  1.1.1.2  christos 	 20,					/* bitsize.  */
    904  1.1.1.2  christos 	 false,					/* pc_relative.  */
    905  1.1.1.2  christos 	 5,					/* bitpos.  */
    906  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    907  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    908  1.1.1.2  christos 	 "R_LARCH_PCALA_HI20",			/* name.  */
    909  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    910  1.1.1.2  christos 	 0,					/* src_mask */
    911  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
    912  1.1.1.2  christos 	 false,					/* pcrel_offset */
    913  1.1.1.2  christos 	 BFD_RELOC_LARCH_PCALA_HI20,		/* bfd_reloc_code_real_type */
    914  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
    915  1.1.1.2  christos 	 "pc_hi20"),				/* larch_reloc_type_name */
    916  1.1.1.2  christos 
    917  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_PCALA_LO12,		/* type (72).  */
    918  1.1.1.2  christos 	 0,					/* rightshift.  */
    919  1.1.1.2  christos 	 4,					/* size.  */
    920  1.1.1.2  christos 	 12,					/* bitsize.  */
    921  1.1.1.2  christos 	 false,					/* pc_relative.  */
    922  1.1.1.2  christos 	 10,					/* bitpos.  */
    923  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    924  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    925  1.1.1.2  christos 	 "R_LARCH_PCALA_LO12",			/* name.  */
    926  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    927  1.1.1.2  christos 	 0,					/* src_mask */
    928  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
    929  1.1.1.2  christos 	 false,					/* pcrel_offset */
    930  1.1.1.2  christos 	 BFD_RELOC_LARCH_PCALA_LO12,		/* bfd_reloc_code_real_type */
    931  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
    932  1.1.1.2  christos 	 "pc_lo12"),				/* larch_reloc_type_name */
    933  1.1.1.2  christos 
    934  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_PCALA64_LO20,	/* type (73).  */
    935  1.1.1.2  christos 	 32,					/* rightshift.  */
    936  1.1.1.2  christos 	 4,					/* size.  */
    937  1.1.1.2  christos 	 20,					/* bitsize.  */
    938  1.1.1.2  christos 	 false,					/* pc_relative.  */
    939  1.1.1.2  christos 	 5,					/* bitpos.  */
    940  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    941  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    942  1.1.1.2  christos 	 "R_LARCH_PCALA64_LO20",		/* name.  */
    943  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    944  1.1.1.2  christos 	 0,					/* src_mask */
    945  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
    946  1.1.1.2  christos 	 false,					/* pcrel_offset */
    947  1.1.1.2  christos 	 BFD_RELOC_LARCH_PCALA64_LO20,		/* bfd_reloc_code_real_type */
    948  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
    949  1.1.1.2  christos 	 "pc64_lo20"),				/* larch_reloc_type_name */
    950  1.1.1.2  christos 
    951  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_PCALA64_HI12,	/* type (74).  */
    952  1.1.1.2  christos 	 52,					/* rightshift.  */
    953  1.1.1.2  christos 	 4,					/* size.  */
    954  1.1.1.2  christos 	 12,					/* bitsize.  */
    955  1.1.1.2  christos 	 false,					/* pc_relative.  */
    956  1.1.1.2  christos 	 10,					/* bitpos.  */
    957  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    958  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    959  1.1.1.2  christos 	 "R_LARCH_PCALA64_HI12",		/* name.  */
    960  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    961  1.1.1.2  christos 	 0,					/* src_mask */
    962  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
    963  1.1.1.2  christos 	 false,					/* pcrel_offset */
    964  1.1.1.2  christos 	 BFD_RELOC_LARCH_PCALA64_HI12,		/* bfd_reloc_code_real_type */
    965  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
    966  1.1.1.2  christos 	 "pc64_hi12"),				/* larch_reloc_type_name */
    967  1.1.1.2  christos 
    968  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_GOT_PC_HI20,		/* type (75).  */
    969  1.1.1.2  christos 	 12,					/* rightshift.  */
    970  1.1.1.2  christos 	 4,					/* size.  */
    971  1.1.1.2  christos 	 20,					/* bitsize.  */
    972  1.1.1.2  christos 	 false,					/* pc_relative.  */
    973  1.1.1.2  christos 	 5,					/* bitpos.  */
    974  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    975  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    976  1.1.1.2  christos 	 "R_LARCH_GOT_PC_HI20",			/* name.  */
    977  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    978  1.1.1.2  christos 	 0,					/* src_mask */
    979  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
    980  1.1.1.2  christos 	 false,					/* pcrel_offset */
    981  1.1.1.2  christos 	 BFD_RELOC_LARCH_GOT_PC_HI20,		/* bfd_reloc_code_real_type */
    982  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
    983  1.1.1.2  christos 	 "got_pc_hi20"),			/* larch_reloc_type_name */
    984  1.1.1.2  christos 
    985  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_GOT_PC_LO12,		/* type (76).  */
    986  1.1.1.2  christos 	 0,					/* rightshift.  */
    987  1.1.1.2  christos 	 4,					/* size.  */
    988  1.1.1.2  christos 	 12,					/* bitsize.  */
    989  1.1.1.2  christos 	 false,					/* pc_relative.  */
    990  1.1.1.2  christos 	 10,					/* bitpos.  */
    991  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    992  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    993  1.1.1.2  christos 	 "R_LARCH_GOT_PC_LO12",			/* name.  */
    994  1.1.1.2  christos 	 false,					/* partial_inplace.  */
    995  1.1.1.2  christos 	 0,					/* src_mask */
    996  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
    997  1.1.1.2  christos 	 false,					/* pcrel_offset */
    998  1.1.1.2  christos 	 BFD_RELOC_LARCH_GOT_PC_LO12,		/* bfd_reloc_code_real_type */
    999  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1000  1.1.1.2  christos 	 "got_pc_lo12"),			/* larch_reloc_type_name */
   1001  1.1.1.2  christos 
   1002  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_GOT64_PC_LO20,	/* type (77).  */
   1003  1.1.1.2  christos 	 32,					/* rightshift.  */
   1004  1.1.1.2  christos 	 4,					/* size.  */
   1005  1.1.1.2  christos 	 20,					/* bitsize.  */
   1006  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1007  1.1.1.2  christos 	 5,					/* bitpos.  */
   1008  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1009  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1010  1.1.1.2  christos 	 "R_LARCH_GOT64_PC_LO20",		/* name.  */
   1011  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1012  1.1.1.2  christos 	 0,					/* src_mask */
   1013  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
   1014  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1015  1.1.1.2  christos 	 BFD_RELOC_LARCH_GOT64_PC_LO20,		/* bfd_reloc_code_real_type */
   1016  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1017  1.1.1.2  christos 	 "got64_pc_lo20"),			/* larch_reloc_type_name */
   1018  1.1.1.2  christos 
   1019  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_GOT64_PC_HI12,	/* type (78).  */
   1020  1.1.1.2  christos 	 52,					/* rightshift.  */
   1021  1.1.1.2  christos 	 4,					/* size.  */
   1022  1.1.1.2  christos 	 12,					/* bitsize.  */
   1023  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1024  1.1.1.2  christos 	 10,					/* bitpos.  */
   1025  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1026  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1027  1.1.1.2  christos 	 "R_LARCH_GOT64_PC_HI12",		/* name.  */
   1028  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1029  1.1.1.2  christos 	 0,					/* src_mask */
   1030  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
   1031  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1032  1.1.1.2  christos 	 BFD_RELOC_LARCH_GOT64_PC_HI12,		/* bfd_reloc_code_real_type */
   1033  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1034  1.1.1.2  christos 	 "got64_pc_hi12"),			/* larch_reloc_type_name */
   1035  1.1.1.2  christos 
   1036  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_GOT_HI20,		/* type (79).  */
   1037  1.1.1.2  christos 	 12,					/* rightshift.  */
   1038  1.1.1.2  christos 	 4,					/* size.  */
   1039  1.1.1.2  christos 	 20,					/* bitsize.  */
   1040  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1041  1.1.1.2  christos 	 5,					/* bitpos.  */
   1042  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1043  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1044  1.1.1.2  christos 	 "R_LARCH_GOT_HI20",			/* name.  */
   1045  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1046  1.1.1.2  christos 	 0,					/* src_mask */
   1047  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
   1048  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1049  1.1.1.2  christos 	 BFD_RELOC_LARCH_GOT_HI20,		/* bfd_reloc_code_real_type */
   1050  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1051  1.1.1.2  christos 	 "got_hi20"),				/* larch_reloc_type_name */
   1052  1.1.1.2  christos 
   1053  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_GOT_LO12,		/* type (80).  */
   1054  1.1.1.2  christos 	 0,					/* rightshift.  */
   1055  1.1.1.2  christos 	 4,					/* size.  */
   1056  1.1.1.2  christos 	 12,					/* bitsize.  */
   1057  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1058  1.1.1.2  christos 	 10,					/* bitpos.  */
   1059  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1060  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1061  1.1.1.2  christos 	 "R_LARCH_GOT_LO12",			/* name.  */
   1062  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1063  1.1.1.2  christos 	 0,					/* src_mask */
   1064  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
   1065  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1066  1.1.1.2  christos 	 BFD_RELOC_LARCH_GOT_LO12,		/* bfd_reloc_code_real_type */
   1067  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1068  1.1.1.2  christos 	 "got_lo12"),				/* larch_reloc_type_name */
   1069  1.1.1.2  christos 
   1070  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_GOT64_LO20,		/* type (81).  */
   1071  1.1.1.2  christos 	 32,					/* rightshift.  */
   1072  1.1.1.2  christos 	 4,					/* size.  */
   1073  1.1.1.2  christos 	 20,					/* bitsize.  */
   1074  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1075  1.1.1.2  christos 	 5,					/* bitpos.  */
   1076  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1077  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1078  1.1.1.2  christos 	 "R_LARCH_GOT64_LO20",			/* name.  */
   1079  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1080  1.1.1.2  christos 	 0,					/* src_mask */
   1081  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
   1082  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1083  1.1.1.2  christos 	 BFD_RELOC_LARCH_GOT64_LO20,		/* bfd_reloc_code_real_type */
   1084  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1085  1.1.1.2  christos 	 "got64_lo20"),				/* larch_reloc_type_name */
   1086  1.1.1.2  christos 
   1087  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_GOT64_HI12,		/* type (82).  */
   1088  1.1.1.2  christos 	 52,					/* rightshift.  */
   1089  1.1.1.2  christos 	 4,					/* size.  */
   1090  1.1.1.2  christos 	 12,					/* bitsize.  */
   1091  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1092  1.1.1.2  christos 	 10,					/* bitpos.  */
   1093  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1094  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1095  1.1.1.2  christos 	 "R_LARCH_GOT64_HI12",			/* name.  */
   1096  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1097  1.1.1.2  christos 	 0,					/* src_mask */
   1098  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
   1099  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1100  1.1.1.2  christos 	 BFD_RELOC_LARCH_GOT64_HI12,		/* bfd_reloc_code_real_type */
   1101  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1102  1.1.1.2  christos 	 "got64_hi12"),				/* larch_reloc_type_name */
   1103  1.1.1.2  christos 
   1104  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LE_HI20,		/* type (83).  */
   1105  1.1.1.2  christos 	 12,					/* rightshift.  */
   1106  1.1.1.2  christos 	 4,					/* size.  */
   1107  1.1.1.2  christos 	 20,					/* bitsize.  */
   1108  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1109  1.1.1.2  christos 	 5,					/* bitpos.  */
   1110  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1111  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1112  1.1.1.2  christos 	 "R_LARCH_TLS_LE_HI20",			/* name.  */
   1113  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1114  1.1.1.2  christos 	 0,					/* src_mask */
   1115  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
   1116  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1117  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_LE_HI20,		/* bfd_reloc_code_real_type */
   1118  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1119  1.1.1.2  christos 	 "le_hi20"),				/* larch_reloc_type_name */
   1120  1.1.1.2  christos 
   1121  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LE_LO12,		/* type (84).  */
   1122  1.1.1.2  christos 	 0,					/* rightshift.  */
   1123  1.1.1.2  christos 	 4,					/* size.  */
   1124  1.1.1.2  christos 	 12,					/* bitsize.  */
   1125  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1126  1.1.1.2  christos 	 10,					/* bitpos.  */
   1127  1.1.1.2  christos 	 complain_overflow_unsigned,		/* complain_on_overflow.  */
   1128  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1129  1.1.1.2  christos 	 "R_LARCH_TLS_LE_LO12",			/* name.  */
   1130  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1131  1.1.1.2  christos 	 0,					/* src_mask */
   1132  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
   1133  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1134  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_LE_LO12,		/* bfd_reloc_code_real_type */
   1135  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1136  1.1.1.2  christos 	 "le_lo12"),				/* larch_reloc_type_name */
   1137  1.1.1.2  christos 
   1138  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LE64_LO20,	/* type (85).  */
   1139  1.1.1.2  christos 	 32,					/* rightshift.  */
   1140  1.1.1.2  christos 	 4,					/* size.  */
   1141  1.1.1.2  christos 	 20,					/* bitsize.  */
   1142  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1143  1.1.1.2  christos 	 5,					/* bitpos.  */
   1144  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1145  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1146  1.1.1.2  christos 	 "R_LARCH_TLS_LE64_LO20",		/* name.  */
   1147  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1148  1.1.1.2  christos 	 0,					/* src_mask */
   1149  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
   1150  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1151  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_LE64_LO20,		/* bfd_reloc_code_real_type */
   1152  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1153  1.1.1.2  christos 	 "le64_lo20"),				/* larch_reloc_type_name */
   1154  1.1.1.2  christos 
   1155  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LE64_HI12,	/* type (86).  */
   1156  1.1.1.2  christos 	 52,					/* rightshift.  */
   1157  1.1.1.2  christos 	 4,					/* size.  */
   1158  1.1.1.2  christos 	 12,					/* bitsize.  */
   1159  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1160  1.1.1.2  christos 	 10,					/* bitpos.  */
   1161  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1162  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1163  1.1.1.2  christos 	 "R_LARCH_TLS_LE64_HI12",		/* name.  */
   1164  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1165  1.1.1.2  christos 	 0,					/* src_mask */
   1166  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
   1167  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1168  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_LE64_HI12,		/* bfd_reloc_code_real_type */
   1169  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1170  1.1.1.2  christos 	 "le64_hi12"),				/* larch_reloc_type_name */
   1171  1.1.1.2  christos 
   1172  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE_PC_HI20,	/* type (87).  */
   1173  1.1.1.2  christos 	 12,					/* rightshift.  */
   1174  1.1.1.2  christos 	 4,					/* size.  */
   1175  1.1.1.2  christos 	 20,					/* bitsize.  */
   1176  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1177  1.1.1.2  christos 	 5,					/* bitpos.  */
   1178  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1179  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1180  1.1.1.2  christos 	 "R_LARCH_TLS_IE_PC_HI20",		/* name.  */
   1181  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1182  1.1.1.2  christos 	 0,					/* src_mask */
   1183  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
   1184  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1185  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_IE_PC_HI20,	/* bfd_reloc_code_real_type */
   1186  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1187  1.1.1.2  christos 	 "ie_pc_hi20"),				/* larch_reloc_type_name */
   1188  1.1.1.2  christos 
   1189  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE_PC_LO12,	/* type (88).  */
   1190  1.1.1.2  christos 	 0,					/* rightshift.  */
   1191  1.1.1.2  christos 	 4,					/* size.  */
   1192  1.1.1.2  christos 	 12,					/* bitsize.  */
   1193  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1194  1.1.1.2  christos 	 10,					/* bitpos.  */
   1195  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1196  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1197  1.1.1.2  christos 	 "R_LARCH_TLS_IE_PC_LO12",		/* name.  */
   1198  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1199  1.1.1.2  christos 	 0,					/* src_mask */
   1200  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
   1201  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1202  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_IE_PC_LO12,	/* bfd_reloc_code_real_type */
   1203  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1204  1.1.1.2  christos 	 "ie_pc_lo12"),				/* larch_reloc_type_name */
   1205  1.1.1.2  christos 
   1206  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE64_PC_LO20,	/* type (89).  */
   1207  1.1.1.2  christos 	 32,					/* rightshift.  */
   1208  1.1.1.2  christos 	 4,					/* size.  */
   1209  1.1.1.2  christos 	 20,					/* bitsize.  */
   1210  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1211  1.1.1.2  christos 	 5,					/* bitpos.  */
   1212  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1213  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1214  1.1.1.2  christos 	 "R_LARCH_TLS_IE64_PC_LO20",		/* name.  */
   1215  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1216  1.1.1.2  christos 	 0,					/* src_mask */
   1217  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
   1218  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1219  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_IE64_PC_LO20,	/* bfd_reloc_code_real_type */
   1220  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1221  1.1.1.2  christos 	 "ie64_pc_lo20"),			/* larch_reloc_type_name */
   1222  1.1.1.2  christos 
   1223  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE64_PC_HI12,	/* type (90).  */
   1224  1.1.1.2  christos 	 52,					/* rightshift.  */
   1225  1.1.1.2  christos 	 4,					/* size.  */
   1226  1.1.1.2  christos 	 12,					/* bitsize.  */
   1227  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1228  1.1.1.2  christos 	 10,					/* bitpos.  */
   1229  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1230  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1231  1.1.1.2  christos 	 "R_LARCH_TLS_IE64_PC_HI12",		/* name.  */
   1232  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1233  1.1.1.2  christos 	 0,					/* src_mask */
   1234  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
   1235  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1236  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_IE64_PC_HI12,	/* bfd_reloc_code_real_type */
   1237  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1238  1.1.1.2  christos 	 "ie64_pc_hi12"),			/* larch_reloc_type_name */
   1239  1.1.1.2  christos 
   1240  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE_HI20,		/* type (91).  */
   1241  1.1.1.2  christos 	 12,					/* rightshift.  */
   1242  1.1.1.2  christos 	 4,					/* size.  */
   1243  1.1.1.2  christos 	 20,					/* bitsize.  */
   1244  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1245  1.1.1.2  christos 	 5,					/* bitpos.  */
   1246  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1247  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1248  1.1.1.2  christos 	 "R_LARCH_TLS_IE_HI20",			/* name.  */
   1249  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1250  1.1.1.2  christos 	 0,					/* src_mask */
   1251  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
   1252  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1253  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_IE_HI20,		/* bfd_reloc_code_real_type */
   1254  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1255  1.1.1.2  christos 	 "ie_hi20"),				/* larch_reloc_type_name */
   1256  1.1.1.2  christos 
   1257  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE_LO12,		/* type (92).  */
   1258  1.1.1.2  christos 	 0,					/* rightshift.  */
   1259  1.1.1.2  christos 	 4,					/* size.  */
   1260  1.1.1.2  christos 	 12,					/* bitsize.  */
   1261  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1262  1.1.1.2  christos 	 10,					/* bitpos.  */
   1263  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1264  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1265  1.1.1.2  christos 	 "R_LARCH_TLS_IE_LO12",			/* name.  */
   1266  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1267  1.1.1.2  christos 	 0,					/* src_mask */
   1268  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
   1269  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1270  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_IE_LO12,		/* bfd_reloc_code_real_type */
   1271  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1272  1.1.1.2  christos 	 "ie_lo12"),				/* larch_reloc_type_name */
   1273  1.1.1.2  christos 
   1274  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE64_LO20,	/* type (93).  */
   1275  1.1.1.2  christos 	 32,					/* rightshift.  */
   1276  1.1.1.2  christos 	 4,					/* size.  */
   1277  1.1.1.2  christos 	 20,					/* bitsize.  */
   1278  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1279  1.1.1.2  christos 	 5,					/* bitpos.  */
   1280  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1281  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1282  1.1.1.2  christos 	 "R_LARCH_TLS_IE64_LO20",		/* name.  */
   1283  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1284  1.1.1.2  christos 	 0,					/* src_mask */
   1285  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
   1286  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1287  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_IE64_LO20,		/* bfd_reloc_code_real_type */
   1288  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1289  1.1.1.2  christos 	 "ie64_lo20"),				/* larch_reloc_type_name */
   1290  1.1.1.2  christos 
   1291  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE64_HI12,	/* type (94).  */
   1292  1.1.1.2  christos 	 52,					/* rightshift.  */
   1293  1.1.1.2  christos 	 4,					/* size.  */
   1294  1.1.1.2  christos 	 12,					/* bitsize.  */
   1295  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1296  1.1.1.2  christos 	 10,					/* bitpos.  */
   1297  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1298  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1299  1.1.1.2  christos 	 "R_LARCH_TLS_IE64_HI12",		/* name.  */
   1300  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1301  1.1.1.2  christos 	 0,					/* src_mask */
   1302  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask */
   1303  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1304  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_IE64_HI12,		/* bfd_reloc_code_real_type */
   1305  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1306  1.1.1.2  christos 	 "ie64_hi12"),				/* larch_reloc_type_name */
   1307  1.1.1.2  christos 
   1308  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LD_PC_HI20,	/* type (95).  */
   1309  1.1.1.2  christos 	 12,					/* rightshift.  */
   1310  1.1.1.2  christos 	 4,					/* size.  */
   1311  1.1.1.2  christos 	 20,					/* bitsize.  */
   1312  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1313  1.1.1.2  christos 	 5,					/* bitpos.  */
   1314  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1315  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1316  1.1.1.2  christos 	 "R_LARCH_TLS_LD_PC_HI20",		/* name.  */
   1317  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1318  1.1.1.2  christos 	 0,					/* src_mask */
   1319  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
   1320  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1321  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_LD_PC_HI20,	/* bfd_reloc_code_real_type */
   1322  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1323  1.1.1.2  christos 	 "ld_pc_hi20"),				/* larch_reloc_type_name */
   1324  1.1.1.2  christos 
   1325  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LD_HI20,		/* type (96).  */
   1326  1.1.1.2  christos 	 12,					/* rightshift.  */
   1327  1.1.1.2  christos 	 4,					/* size.  */
   1328  1.1.1.2  christos 	 20,					/* bitsize.  */
   1329  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1330  1.1.1.2  christos 	 5,					/* bitpos.  */
   1331  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1332  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1333  1.1.1.2  christos 	 "R_LARCH_TLS_LD_HI20",			/* name.  */
   1334  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1335  1.1.1.2  christos 	 0,					/* src_mask */
   1336  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
   1337  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1338  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_LD_HI20,		/* bfd_reloc_code_real_type */
   1339  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1340  1.1.1.2  christos 	 "ld_hi20"),				/* larch_reloc_type_name */
   1341  1.1.1.2  christos 
   1342  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_GD_PC_HI20,	/* type (97).  */
   1343  1.1.1.2  christos 	 12,					/* rightshift.  */
   1344  1.1.1.2  christos 	 4,					/* size.  */
   1345  1.1.1.2  christos 	 20,					/* bitsize.  */
   1346  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1347  1.1.1.2  christos 	 5,					/* bitpos.  */
   1348  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1349  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1350  1.1.1.2  christos 	 "R_LARCH_TLS_GD_PC_HI20",		/* name.  */
   1351  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1352  1.1.1.2  christos 	 0,					/* src_mask */
   1353  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
   1354  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1355  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_GD_PC_HI20,	/* bfd_reloc_code_real_type */
   1356  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1357  1.1.1.2  christos 	 "gd_pc_hi20"),				/* larch_reloc_type_name */
   1358  1.1.1.2  christos 
   1359  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_GD_HI20,		/* type (98).  */
   1360  1.1.1.2  christos 	 12,					/* rightshift.  */
   1361  1.1.1.2  christos 	 4,					/* size.  */
   1362  1.1.1.2  christos 	 20,					/* bitsize.  */
   1363  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1364  1.1.1.2  christos 	 5,					/* bitpos.  */
   1365  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1366  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1367  1.1.1.2  christos 	 "R_LARCH_TLS_GD_HI20",			/* name.  */
   1368  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1369  1.1.1.2  christos 	 0,					/* src_mask */
   1370  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask */
   1371  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1372  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_GD_HI20,		/* bfd_reloc_code_real_type */
   1373  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1374  1.1.1.2  christos 	 "gd_hi20"),				/* larch_reloc_type_name */
   1375  1.1.1.2  christos 
   1376  1.1.1.2  christos   /* 32-bit PC relative.  */
   1377  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_32_PCREL,		/* type (99).  */
   1378  1.1.1.2  christos 	 0,					/* rightshift.  */
   1379  1.1.1.2  christos 	 4,					/* size.  */
   1380  1.1.1.2  christos 	 32,					/* bitsize.  */
   1381  1.1.1.2  christos 	 true,					/* pc_relative.  */
   1382  1.1.1.2  christos 	 0,					/* bitpos.  */
   1383  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1384  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1385  1.1.1.2  christos 	 "R_LARCH_32_PCREL",			/* name.  */
   1386  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1387  1.1.1.2  christos 	 0,					/* src_mask */
   1388  1.1.1.2  christos 	 0xffffffff,				/* dst_mask */
   1389  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1390  1.1.1.2  christos 	 BFD_RELOC_LARCH_32_PCREL,		/* bfd_reloc_code_real_type */
   1391  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits */
   1392  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name */
   1393  1.1.1.2  christos 
   1394  1.1.1.2  christos   /* The paired relocation may be relaxed.  */
   1395  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_RELAX,		/* type (100).  */
   1396  1.1.1.2  christos 	 0,					/* rightshift */
   1397  1.1.1.2  christos 	 1,					/* size */
   1398  1.1.1.2  christos 	 0,					/* bitsize */
   1399  1.1.1.2  christos 	 false,					/* pc_relative */
   1400  1.1.1.2  christos 	 0,					/* bitpos */
   1401  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow */
   1402  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function */
   1403  1.1.1.2  christos 	 "R_LARCH_RELAX",			/* name */
   1404  1.1.1.2  christos 	 false,					/* partial_inplace */
   1405  1.1.1.2  christos 	 0,					/* src_mask */
   1406  1.1.1.2  christos 	 0,					/* dst_mask */
   1407  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1408  1.1.1.2  christos 	 BFD_RELOC_LARCH_RELAX,			/* bfd_reloc_code_real_type */
   1409  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits */
   1410  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name */
   1411  1.1.1.2  christos 
   1412  1.1.1.2  christos   /* Delete relaxed instruction.  */
   1413  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_DELETE,		/* type (101).  */
   1414  1.1.1.2  christos 	 0,					/* rightshift.  */
   1415  1.1.1.2  christos 	 0,					/* size.  */
   1416  1.1.1.2  christos 	 0,					/* bitsize.  */
   1417  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1418  1.1.1.2  christos 	 0,					/* bitpos.  */
   1419  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
   1420  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1421  1.1.1.2  christos 	 "R_LARCH_DELETE",			/* name.  */
   1422  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1423  1.1.1.2  christos 	 0,					/* src_mask.  */
   1424  1.1.1.2  christos 	 0,					/* dst_mask.  */
   1425  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1426  1.1.1.2  christos 	 BFD_RELOC_LARCH_DELETE,		/* bfd_reloc_code_real_type.  */
   1427  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
   1428  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
   1429  1.1.1.2  christos 
   1430  1.1.1.2  christos   /* Indicates an alignment statement. f the symbol index is 0,
   1431  1.1.1.2  christos      the addend indicates the number of bytes occupied by nop instructions
   1432  1.1.1.2  christos      at the relocation offset. The alignment boundary is specified by the
   1433  1.1.1.2  christos      addend rounded up to the next power of two.
   1434  1.1.1.2  christos      If the symbol index is not 0, the addend indicates the first and third
   1435  1.1.1.2  christos      expressions of .align. The lowest 8 bits are used to represent the first
   1436  1.1.1.2  christos      expression, other bits are used to represent the third expression.  */
   1437  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_ALIGN,		/* type (102).  */
   1438  1.1.1.2  christos 	 0,					/* rightshift.  */
   1439  1.1.1.2  christos 	 0,					/* size.  */
   1440  1.1.1.2  christos 	 0,					/* bitsize.  */
   1441  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1442  1.1.1.2  christos 	 0,					/* bitpos.  */
   1443  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
   1444  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1445  1.1.1.2  christos 	 "R_LARCH_ALIGN",			/* name.  */
   1446  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1447  1.1.1.2  christos 	 0,					/* src_mask.  */
   1448  1.1.1.2  christos 	 0,					/* dst_mask.  */
   1449  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1450  1.1.1.2  christos 	 BFD_RELOC_LARCH_ALIGN,			/* bfd_reloc_code_real_type.  */
   1451  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
   1452  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
   1453  1.1.1.2  christos 
   1454  1.1.1.2  christos   /* For pcaddi and pcala_hi20 + pcala_lo12 can relax to pcrel_20.  */
   1455  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_PCREL20_S2,		/* type (103).  */
   1456  1.1.1.2  christos 	 2,					/* rightshift.  */
   1457  1.1.1.2  christos 	 4,					/* size.  */
   1458  1.1.1.2  christos 	 20,					/* bitsize.  */
   1459  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1460  1.1.1.2  christos 	 5,					/* bitpos.  */
   1461  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1462  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1463  1.1.1.2  christos 	 "R_LARCH_PCREL20_S2",			/* name.  */
   1464  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1465  1.1.1.2  christos 	 0,					/* src_mask.  */
   1466  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask.  */
   1467  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1468  1.1.1.2  christos 	 BFD_RELOC_LARCH_PCREL20_S2,		/* bfd_reloc_code_real_type.  */
   1469  1.1.1.2  christos 	 reloc_sign_bits,			/* adjust_reloc_bits.  */
   1470  1.1.1.2  christos 	 "pcrel_20"),				/* larch_reloc_type_name.  */
   1471  1.1.1.2  christos 
   1472  1.1.1.2  christos   /* Canonical Frame Address.  */
   1473  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_CFA,			/* type (104).  */
   1474  1.1.1.2  christos 	 0,					/* rightshift.  */
   1475  1.1.1.2  christos 	 0,					/* size.  */
   1476  1.1.1.2  christos 	 0,					/* bitsize.  */
   1477  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1478  1.1.1.2  christos 	 0,					/* bitpos.  */
   1479  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
   1480  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1481  1.1.1.2  christos 	 "R_LARCH_CFA",				/* name.  */
   1482  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1483  1.1.1.2  christos 	 0,					/* src_mask.  */
   1484  1.1.1.2  christos 	 0,					/* dst_mask.  */
   1485  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1486  1.1.1.2  christos 	 BFD_RELOC_LARCH_CFA,			/* bfd_reloc_code_real_type.  */
   1487  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
   1488  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
   1489  1.1.1.2  christos 
   1490  1.1.1.2  christos   /* 6-bit in-place addition, for local label subtraction
   1491  1.1.1.2  christos      to calculate DW_CFA_advance_loc.  */
   1492  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_ADD6,		/* type (105).  */
   1493  1.1.1.2  christos 	 0,					/* rightshift.  */
   1494  1.1.1.2  christos 	 1,					/* size.  */
   1495  1.1.1.2  christos 	 8,					/* bitsize.  */
   1496  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1497  1.1.1.2  christos 	 0,					/* bitpos.  */
   1498  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
   1499  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc,		/* special_function.  */
   1500  1.1.1.2  christos 	 "R_LARCH_ADD6",			/* name.  */
   1501  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1502  1.1.1.2  christos 	 0,					/* src_mask.  */
   1503  1.1.1.2  christos 	 0x3f,					/* dst_mask.  */
   1504  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1505  1.1.1.2  christos 	 BFD_RELOC_LARCH_ADD6,			/* bfd_reloc_code_real_type.  */
   1506  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits.  */
   1507  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
   1508  1.1.1.2  christos 
   1509  1.1.1.2  christos   /* 6-bit in-place subtraction, for local label subtraction
   1510  1.1.1.2  christos      to calculate DW_CFA_advance_loc.  */
   1511  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_SUB6,		/* type (106).  */
   1512  1.1.1.2  christos 	 0,					/* rightshift.  */
   1513  1.1.1.2  christos 	 1,					/* size.  */
   1514  1.1.1.2  christos 	 8,					/* bitsize.  */
   1515  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1516  1.1.1.2  christos 	 0,					/* bitpos.  */
   1517  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
   1518  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc,		/* special_function.  */
   1519  1.1.1.2  christos 	 "R_LARCH_SUB6",			/* name.  */
   1520  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1521  1.1.1.2  christos 	 0,					/* src_mask.  */
   1522  1.1.1.2  christos 	 0x3f,					/* dst_mask.  */
   1523  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1524  1.1.1.2  christos 	 BFD_RELOC_LARCH_SUB6,			/* bfd_reloc_code_real_type.  */
   1525  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits.  */
   1526  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
   1527  1.1.1.2  christos 
   1528  1.1.1.2  christos   /* The length of unsigned-leb128 is variable, just assume the
   1529  1.1.1.2  christos      size is one byte here.
   1530  1.1.1.2  christos      uleb128 in-place addition, for local label subtraction.  */
   1531  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_ADD_ULEB128,		/* type (107).  */
   1532  1.1.1.2  christos 	 0,					/* rightshift.  */
   1533  1.1.1.2  christos 	 1,					/* size.  */
   1534  1.1.1.2  christos 	 0,					/* bitsize.  */
   1535  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1536  1.1.1.2  christos 	 0,					/* bitpos.  */
   1537  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
   1538  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc_uleb128,	/* special_function.  */
   1539  1.1.1.2  christos 	 "R_LARCH_ADD_ULEB128",			/* name.  */
   1540  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1541  1.1.1.2  christos 	 0,					/* src_mask.  */
   1542  1.1.1.2  christos 	 0,					/* dst_mask.  */
   1543  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1544  1.1.1.2  christos 	 BFD_RELOC_LARCH_ADD_ULEB128,		/* bfd_reloc_code_real_type.  */
   1545  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
   1546  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
   1547  1.1.1.2  christos 
   1548  1.1.1.2  christos   /* The length of unsigned-leb128 is variable, just assume the
   1549  1.1.1.2  christos      size is one byte here.
   1550  1.1.1.2  christos      uleb128 in-place subtraction, for local label subtraction.  */
   1551  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_SUB_ULEB128,		/* type (108).  */
   1552  1.1.1.2  christos 	 0,					/* rightshift.  */
   1553  1.1.1.2  christos 	 1,					/* size.  */
   1554  1.1.1.2  christos 	 0,					/* bitsize.  */
   1555  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1556  1.1.1.2  christos 	 0,					/* bitpos.  */
   1557  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
   1558  1.1.1.2  christos 	 loongarch_elf_add_sub_reloc_uleb128,	/* special_function.  */
   1559  1.1.1.2  christos 	 "R_LARCH_SUB_ULEB128",			/* name.  */
   1560  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1561  1.1.1.2  christos 	 0,					/* src_mask.  */
   1562  1.1.1.2  christos 	 0,					/* dst_mask.  */
   1563  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1564  1.1.1.2  christos 	 BFD_RELOC_LARCH_SUB_ULEB128,		/* bfd_reloc_code_real_type.  */
   1565  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
   1566  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name.  */
   1567  1.1.1.2  christos 
   1568  1.1.1.2  christos   /* 64-bit PC relative.  */
   1569  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_64_PCREL,		/* type (109).  */
   1570  1.1.1.2  christos 	 0,					/* rightshift.  */
   1571  1.1.1.2  christos 	 8,					/* size.  */
   1572  1.1.1.2  christos 	 64,					/* bitsize.  */
   1573  1.1.1.2  christos 	 true,					/* pc_relative.  */
   1574  1.1.1.2  christos 	 0,					/* bitpos.  */
   1575  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1576  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1577  1.1.1.2  christos 	 "R_LARCH_64_PCREL",			/* name.  */
   1578  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1579  1.1.1.2  christos 	 0,					/* src_mask */
   1580  1.1.1.2  christos 	 0xffffffffffffffff,			/* dst_mask */
   1581  1.1.1.2  christos 	 false,					/* pcrel_offset */
   1582  1.1.1.2  christos 	 BFD_RELOC_LARCH_64_PCREL,		/* bfd_reloc_code_real_type */
   1583  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits */
   1584  1.1.1.2  christos 	 NULL),					/* larch_reloc_type_name */
   1585  1.1.1.2  christos 
   1586  1.1.1.2  christos   /* Used for medium code model function call pcaddu18i+jirl,
   1587  1.1.1.2  christos      these two instructions must adjacent.  */
   1588  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_CALL36,		/* type (110).  */
   1589  1.1.1.2  christos 	 2,					/* rightshift.  */
   1590  1.1.1.2  christos 	 8,					/* size.  */
   1591  1.1.1.2  christos 	 36,					/* bitsize.  */
   1592  1.1.1.2  christos 	 true,					/* pc_relative.  */
   1593  1.1.1.2  christos 	 0,					/* bitpos.  */
   1594  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1595  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1596  1.1.1.2  christos 	 "R_LARCH_CALL36",			/* name.  */
   1597  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1598  1.1.1.2  christos 	 0,					/* src_mask.  */
   1599  1.1.1.2  christos 	 0x03fffc0001ffffe0,			/* dst_mask.  */
   1600  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1601  1.1.1.2  christos 	 BFD_RELOC_LARCH_CALL36,		/* bfd_reloc_code_real_type.  */
   1602  1.1.1.2  christos 	 reloc_sign_bits,			/* adjust_reloc_bits.  */
   1603  1.1.1.2  christos 	 "call36"),				/* larch_reloc_type_name.  */
   1604  1.1.1.2  christos 
   1605  1.1.1.2  christos   /* TLS_DESC PCREL.  */
   1606  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DESC_PC_HI20,	/* type (111).  */
   1607  1.1.1.2  christos 	 12,					/* rightshift.  */
   1608  1.1.1.2  christos 	 4,					/* size.  */
   1609  1.1.1.2  christos 	 20,					/* bitsize.  */
   1610  1.1.1.2  christos 	 true,					/* pc_relative.  */
   1611  1.1.1.2  christos 	 5,					/* bitpos.  */
   1612  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1613  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1614  1.1.1.2  christos 	 "R_LARCH_TLS_DESC_PC_HI20",		/* name.  */
   1615  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1616  1.1.1.2  christos 	 0,					/* src_mask.  */
   1617  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask.  */
   1618  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1619  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_DESC_PC_HI20,	/* bfd_reloc_code_real_type.  */
   1620  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits.  */
   1621  1.1.1.2  christos 	 "desc_pc_hi20"),			/* larch_reloc_type_name.  */
   1622  1.1.1.2  christos 
   1623  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DESC_PC_LO12,	/* type (112).  */
   1624  1.1.1.2  christos 	 0,					/* rightshift.  */
   1625  1.1.1.2  christos 	 4,					/* size.  */
   1626  1.1.1.2  christos 	 12,					/* bitsize.  */
   1627  1.1.1.2  christos 	 true,					/* pc_relative.  */
   1628  1.1.1.2  christos 	 10,					/* bitpos.  */
   1629  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1630  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1631  1.1.1.2  christos 	 "R_LARCH_TLS_DESC_PC_LO12",		/* name.  */
   1632  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1633  1.1.1.2  christos 	 0,					/* src_mask.  */
   1634  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask.  */
   1635  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1636  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_DESC_PC_LO12,	/* bfd_reloc_code_real_type.  */
   1637  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits.  */
   1638  1.1.1.2  christos 	 "desc_pc_lo12"),			/* larch_reloc_type_name.  */
   1639  1.1.1.2  christos 
   1640  1.1.1.2  christos   /* TLS_DESC64 LARGE PCREL.  */
   1641  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_PC_LO20, /* type (113).  */
   1642  1.1.1.2  christos 	32,				       /* rightshift.  */
   1643  1.1.1.2  christos 	8,				       /* size.  */
   1644  1.1.1.2  christos 	20,				       /* bitsize.  */
   1645  1.1.1.2  christos 	true,				       /* pc_relative.  */
   1646  1.1.1.2  christos 	5,				       /* bitpos.  */
   1647  1.1.1.2  christos 	complain_overflow_signed,	       /* complain_on_overflow.  */
   1648  1.1.1.2  christos 	bfd_elf_generic_reloc,		       /* special_function.  */
   1649  1.1.1.2  christos 	"R_LARCH_TLS_DESC64_PC_LO20",	       /* name.  */
   1650  1.1.1.2  christos 	false,				       /* partial_inplace.  */
   1651  1.1.1.2  christos 	0,				       /* src_mask.  */
   1652  1.1.1.2  christos 	0x1ffffe0,			       /* dst_mask.  */
   1653  1.1.1.2  christos 	false,				       /* pcrel_offset.  */
   1654  1.1.1.2  christos 	BFD_RELOC_LARCH_TLS_DESC64_PC_LO20,    /* bfd_reloc_code_real_type.  */
   1655  1.1.1.2  christos 	reloc_bits,			       /* adjust_reloc_bits.  */
   1656  1.1.1.2  christos 	"desc64_pc_lo20"),		       /* larch_reloc_type_name.  */
   1657  1.1.1.2  christos 
   1658  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_PC_HI12, /* type (114).  */
   1659  1.1.1.2  christos 	52,				       /* rightshift.  */
   1660  1.1.1.2  christos 	8,				       /* size.  */
   1661  1.1.1.2  christos 	12,				       /* bitsize.  */
   1662  1.1.1.2  christos 	true,				       /* pc_relative.  */
   1663  1.1.1.2  christos 	10,				       /* bitpos.  */
   1664  1.1.1.2  christos 	complain_overflow_signed,	       /* complain_on_overflow.  */
   1665  1.1.1.2  christos 	bfd_elf_generic_reloc,		       /* special_function.  */
   1666  1.1.1.2  christos 	"R_LARCH_TLS_DESC64_PC_HI12",	       /* name.  */
   1667  1.1.1.2  christos 	false,				       /* partial_inplace.  */
   1668  1.1.1.2  christos 	0,				       /* src_mask.  */
   1669  1.1.1.2  christos 	0x3ffc00,			       /* dst_mask.  */
   1670  1.1.1.2  christos 	false,				       /* pcrel_offset.  */
   1671  1.1.1.2  christos 	BFD_RELOC_LARCH_TLS_DESC64_PC_HI12,    /* bfd_reloc_code_real_type.  */
   1672  1.1.1.2  christos 	reloc_bits,			       /* adjust_reloc_bits.  */
   1673  1.1.1.2  christos 	"desc64_pc_hi12"),		       /* larch_reloc_type_name.  */
   1674  1.1.1.2  christos 
   1675  1.1.1.2  christos   /* TLS_DESC ABS.  */
   1676  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DESC_HI20,	/* type (115).  */
   1677  1.1.1.2  christos 	 12,					/* rightshift.  */
   1678  1.1.1.2  christos 	 4,					/* size.  */
   1679  1.1.1.2  christos 	 20,					/* bitsize.  */
   1680  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1681  1.1.1.2  christos 	 5,					/* bitpos.  */
   1682  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1683  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1684  1.1.1.2  christos 	 "R_LARCH_TLS_DESC_HI20",		/* name.  */
   1685  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1686  1.1.1.2  christos 	 0,					/* src_mask.  */
   1687  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask.  */
   1688  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1689  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_DESC_HI20,		/* bfd_reloc_code_real_type.  */
   1690  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits.  */
   1691  1.1.1.2  christos 	 "desc_hi20"),				/* larch_reloc_type_name.  */
   1692  1.1.1.2  christos 
   1693  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DESC_LO12,	/* type (116).  */
   1694  1.1.1.2  christos 	 0,					/* rightshift.  */
   1695  1.1.1.2  christos 	 4,					/* size.  */
   1696  1.1.1.2  christos 	 12,					/* bitsize.  */
   1697  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1698  1.1.1.2  christos 	 10,					/* bitpos.  */
   1699  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1700  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1701  1.1.1.2  christos 	 "R_LARCH_TLS_DESC_LO12",		/* name.  */
   1702  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1703  1.1.1.2  christos 	 0,					/* src_mask.  */
   1704  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask.  */
   1705  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1706  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_DESC_LO12,		/* bfd_reloc_code_real_type.  */
   1707  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits.  */
   1708  1.1.1.2  christos 	 "desc_lo12"),				/* larch_reloc_type_name.  */
   1709  1.1.1.2  christos 
   1710  1.1.1.2  christos   /* TLS_DESC64 LARGE ABS.  */
   1711  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_LO20,    /* type (117).  */
   1712  1.1.1.2  christos 	32,				       /* rightshift.  */
   1713  1.1.1.2  christos 	8,				       /* size.  */
   1714  1.1.1.2  christos 	20,				       /* bitsize.  */
   1715  1.1.1.2  christos 	false,				       /* pc_relative.  */
   1716  1.1.1.2  christos 	5,				       /* bitpos.  */
   1717  1.1.1.2  christos 	complain_overflow_signed,	       /* complain_on_overflow.  */
   1718  1.1.1.2  christos 	bfd_elf_generic_reloc,		       /* special_function.  */
   1719  1.1.1.2  christos 	"R_LARCH_TLS_DESC64_LO20",	       /* name.  */
   1720  1.1.1.2  christos 	false,				       /* partial_inplace.  */
   1721  1.1.1.2  christos 	0,				       /* src_mask.  */
   1722  1.1.1.2  christos 	0x1ffffe0,			       /* dst_mask.  */
   1723  1.1.1.2  christos 	false,				       /* pcrel_offset.  */
   1724  1.1.1.2  christos 	BFD_RELOC_LARCH_TLS_DESC64_LO20,       /* bfd_reloc_code_real_type.  */
   1725  1.1.1.2  christos 	reloc_bits,			       /* adjust_reloc_bits.  */
   1726  1.1.1.2  christos 	"desc64_lo20"),			       /* larch_reloc_type_name.  */
   1727  1.1.1.2  christos 
   1728  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_HI12,    /* type (118).  */
   1729  1.1.1.2  christos 	52,				       /* rightshift.  */
   1730  1.1.1.2  christos 	8,				       /* size.  */
   1731  1.1.1.2  christos 	12,				       /* bitsize.  */
   1732  1.1.1.2  christos 	false,				       /* pc_relative.  */
   1733  1.1.1.2  christos 	10,				       /* bitpos.  */
   1734  1.1.1.2  christos 	complain_overflow_signed,	       /* complain_on_overflow.  */
   1735  1.1.1.2  christos 	bfd_elf_generic_reloc,		       /* special_function.  */
   1736  1.1.1.2  christos 	"R_LARCH_TLS_DESC64_HI12",	       /* name.  */
   1737  1.1.1.2  christos 	false,				       /* partial_inplace.  */
   1738  1.1.1.2  christos 	0,				       /* src_mask.  */
   1739  1.1.1.2  christos 	0x3ffc00,			       /* dst_mask.  */
   1740  1.1.1.2  christos 	false,				       /* pcrel_offset.  */
   1741  1.1.1.2  christos 	BFD_RELOC_LARCH_TLS_DESC64_HI12,       /* bfd_reloc_code_real_type.  */
   1742  1.1.1.2  christos 	reloc_bits,			       /* adjust_reloc_bits.  */
   1743  1.1.1.2  christos 	"desc64_hi12"),			       /* larch_reloc_type_name.  */
   1744  1.1.1.2  christos 
   1745  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DESC_LD,		/* type (119).  */
   1746  1.1.1.2  christos 	 0,					/* rightshift.  */
   1747  1.1.1.2  christos 	 4,					/* size.  */
   1748  1.1.1.2  christos 	 0,					/* bitsize.  */
   1749  1.1.1.2  christos 	 true,					/* pc_relative.  */
   1750  1.1.1.2  christos 	 0,					/* bitpos.  */
   1751  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1752  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1753  1.1.1.2  christos 	 "R_LARCH_TLS_DESC_LD",			/* name.  */
   1754  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1755  1.1.1.2  christos 	 0,					/* src_mask.  */
   1756  1.1.1.2  christos 	 0,					/* dst_mask.  */
   1757  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1758  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_DESC_LD,		/* bfd_reloc_code_real_type.  */
   1759  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
   1760  1.1.1.2  christos 	 "desc_ld"),				/* larch_reloc_type_name.  */
   1761  1.1.1.2  christos 
   1762  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DESC_CALL,	/* type (120).  */
   1763  1.1.1.2  christos 	 0,					/* rightshift.  */
   1764  1.1.1.2  christos 	 4,					/* size.  */
   1765  1.1.1.2  christos 	 0,					/* bitsize.  */
   1766  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1767  1.1.1.2  christos 	 0,					/* bitpos.  */
   1768  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
   1769  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1770  1.1.1.2  christos 	 "R_LARCH_TLS_DESC_CALL",		/* name.  */
   1771  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1772  1.1.1.2  christos 	 0,					/* src_mask.  */
   1773  1.1.1.2  christos 	 0,					/* dst_mask.  */
   1774  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1775  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_DESC_CALL,		/* bfd_reloc_code_real_type.  */
   1776  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
   1777  1.1.1.2  christos 	 "desc_call"),				/* larch_reloc_type_name.  */
   1778  1.1.1.2  christos 
   1779  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LE_HI20_R,	/* type (121).  */
   1780  1.1.1.2  christos 	 12,					/* rightshift.  */
   1781  1.1.1.2  christos 	 4,					/* size.  */
   1782  1.1.1.2  christos 	 20,					/* bitsize.  */
   1783  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1784  1.1.1.2  christos 	 5,					/* bitpos.  */
   1785  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1786  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1787  1.1.1.2  christos 	 "R_LARCH_TLS_LE_HI20_R",		/* name.  */
   1788  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1789  1.1.1.2  christos 	 0,					/* src_mask.  */
   1790  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask.  */
   1791  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1792  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_LE_HI20_R,		/* bfd_reloc_code_real_type.  */
   1793  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits.  */
   1794  1.1.1.2  christos 	 "le_hi20_r"),				/* larch_reloc_type_name.  */
   1795  1.1.1.2  christos 
   1796  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LE_ADD_R,	/* type (122).  */
   1797  1.1.1.2  christos 	 0,					/* rightshift.  */
   1798  1.1.1.2  christos 	 0,					/* size.  */
   1799  1.1.1.2  christos 	 0,					/* bitsize.  */
   1800  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1801  1.1.1.2  christos 	 0,					/* bitpos.  */
   1802  1.1.1.2  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
   1803  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1804  1.1.1.2  christos 	 "R_LARCH_TLS_LE_ADD_R",		/* name.  */
   1805  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1806  1.1.1.2  christos 	 0,					/* src_mask.  */
   1807  1.1.1.2  christos 	 0,					/* dst_mask.  */
   1808  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1809  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_LE_ADD_R,		/* bfd_reloc_code_real_type.  */
   1810  1.1.1.2  christos 	 NULL,					/* adjust_reloc_bits.  */
   1811  1.1.1.2  christos 	 "le_add_r"),				/* larch_reloc_type_name.  */
   1812  1.1.1.2  christos 
   1813  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LE_LO12_R,	/* type (123).  */
   1814  1.1.1.2  christos 	 0,					/* rightshift.  */
   1815  1.1.1.2  christos 	 4,					/* size.  */
   1816  1.1.1.2  christos 	 12,					/* bitsize.  */
   1817  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1818  1.1.1.2  christos 	 10,					/* bitpos.  */
   1819  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1820  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1821  1.1.1.2  christos 	 "R_LARCH_TLS_LE_LO12_R",		/* name.  */
   1822  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1823  1.1.1.2  christos 	 0,					/* src_mask.  */
   1824  1.1.1.2  christos 	 0x3ffc00,				/* dst_mask.  */
   1825  1.1.1.2  christos 	 false,					/* pcrel_offset.  */
   1826  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_LE_LO12_R,		/* bfd_reloc_code_real_type.  */
   1827  1.1.1.2  christos 	 reloc_bits,				/* adjust_reloc_bits.  */
   1828  1.1.1.2  christos 	 "le_lo12_r"),				/* larch_reloc_type_name.  */
   1829  1.1.1.2  christos 
   1830  1.1.1.2  christos   /* For pcaddi, ld_pc_hi20 + ld_pc_lo12 can relax to ld_pcrel20_s2.  */
   1831  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LD_PCREL20_S2,	/* type (124).  */
   1832  1.1.1.2  christos 	 2,					/* rightshift.  */
   1833  1.1.1.2  christos 	 4,					/* size.  */
   1834  1.1.1.2  christos 	 20,					/* bitsize.  */
   1835  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1836  1.1.1.2  christos 	 5,					/* bitpos.  */
   1837  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1838  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1839  1.1.1.2  christos 	 "R_LARCH_TLS_LD_PCREL20_S2",		/* name.  */
   1840  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1841  1.1.1.2  christos 	 0,					/* src_mask.  */
   1842  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask.  */
   1843  1.1.1.2  christos 	 true,					/* pcrel_offset.  */
   1844  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_LD_PCREL20_S2,	/* bfd_reloc_code_real_type.  */
   1845  1.1.1.2  christos 	 reloc_sign_bits,			/* adjust_reloc_bits.  */
   1846  1.1.1.2  christos 	 "ld_pcrel_20"),			/* larch_reloc_type_name.  */
   1847  1.1.1.2  christos 
   1848  1.1.1.2  christos   /* For pcaddi, gd_pc_hi20 + gd_pc_lo12 can relax to gd_pcrel20_s2.  */
   1849  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_GD_PCREL20_S2,	/* type (125).  */
   1850  1.1.1.2  christos 	 2,					/* rightshift.  */
   1851  1.1.1.2  christos 	 4,					/* size.  */
   1852  1.1.1.2  christos 	 20,					/* bitsize.  */
   1853  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1854  1.1.1.2  christos 	 5,					/* bitpos.  */
   1855  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1856  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1857  1.1.1.2  christos 	 "R_LARCH_TLS_GD_PCREL20_S2",		/* name.  */
   1858  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1859  1.1.1.2  christos 	 0,					/* src_mask.  */
   1860  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask.  */
   1861  1.1.1.2  christos 	 true,					/* pcrel_offset.  */
   1862  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_GD_PCREL20_S2,	/* bfd_reloc_code_real_type.  */
   1863  1.1.1.2  christos 	 reloc_sign_bits,			/* adjust_reloc_bits.  */
   1864  1.1.1.2  christos 	 "gd_pcrel_20"),			/* larch_reloc_type_name.  */
   1865  1.1.1.2  christos 
   1866  1.1.1.2  christos   /* For pcaddi, desc_pc_hi20 + desc_pc_lo12 can relax to desc_pcrel20_s2.  */
   1867  1.1.1.2  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DESC_PCREL20_S2,	/* type (126).  */
   1868  1.1.1.2  christos 	 2,					/* rightshift.  */
   1869  1.1.1.2  christos 	 4,					/* size.  */
   1870  1.1.1.2  christos 	 20,					/* bitsize.  */
   1871  1.1.1.2  christos 	 false,					/* pc_relative.  */
   1872  1.1.1.2  christos 	 5,					/* bitpos.  */
   1873  1.1.1.2  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1874  1.1.1.2  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1875  1.1.1.2  christos 	 "R_LARCH_TLS_DESC_PCREL20_S2",		/* name.  */
   1876  1.1.1.2  christos 	 false,					/* partial_inplace.  */
   1877  1.1.1.2  christos 	 0,					/* src_mask.  */
   1878  1.1.1.2  christos 	 0x1ffffe0,				/* dst_mask.  */
   1879  1.1.1.2  christos 	 true,					/* pcrel_offset.  */
   1880  1.1.1.2  christos 	 BFD_RELOC_LARCH_TLS_DESC_PCREL20_S2,	/* bfd_reloc_code_real_type.  */
   1881  1.1.1.2  christos 	 reloc_sign_bits,			/* adjust_reloc_bits.  */
   1882  1.1.1.2  christos 	 "desc_pcrel_20"),			/* larch_reloc_type_name.  */
   1883      1.1  christos };
   1884      1.1  christos 
   1885      1.1  christos reloc_howto_type *
   1886      1.1  christos loongarch_elf_rtype_to_howto (bfd *abfd, unsigned int r_type)
   1887      1.1  christos {
   1888  1.1.1.2  christos   if (r_type < R_LARCH_count)
   1889      1.1  christos     {
   1890      1.1  christos       BFD_ASSERT (ARRAY_SIZE (loongarch_howto_table) == R_LARCH_count);
   1891      1.1  christos       BFD_ASSERT (loongarch_howto_table[r_type].howto.type == r_type);
   1892  1.1.1.2  christos       return &loongarch_howto_table[r_type].howto;
   1893      1.1  christos     }
   1894      1.1  christos 
   1895      1.1  christos   (*_bfd_error_handler) (_("%pB: unsupported relocation type %#x"),
   1896      1.1  christos 			 abfd, r_type);
   1897      1.1  christos   bfd_set_error (bfd_error_bad_value);
   1898      1.1  christos   return NULL;
   1899      1.1  christos }
   1900      1.1  christos 
   1901      1.1  christos reloc_howto_type *
   1902      1.1  christos loongarch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
   1903      1.1  christos {
   1904      1.1  christos   for (size_t i = 0; i < ARRAY_SIZE (loongarch_howto_table); i++)
   1905      1.1  christos     if (loongarch_howto_table[i].howto.name
   1906      1.1  christos 	&& strcasecmp (loongarch_howto_table[i].howto.name, r_name) == 0)
   1907  1.1.1.2  christos       return &loongarch_howto_table[i].howto;
   1908      1.1  christos 
   1909      1.1  christos   (*_bfd_error_handler) (_("%pB: unsupported relocation type %s"),
   1910      1.1  christos 			 abfd, r_name);
   1911      1.1  christos   bfd_set_error (bfd_error_bad_value);
   1912      1.1  christos   return NULL;
   1913      1.1  christos }
   1914      1.1  christos 
   1915      1.1  christos /* Cost so much.  */
   1916      1.1  christos reloc_howto_type *
   1917      1.1  christos loongarch_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   1918      1.1  christos 			     bfd_reloc_code_real_type code)
   1919      1.1  christos {
   1920      1.1  christos   BFD_ASSERT (ARRAY_SIZE (loongarch_howto_table) == R_LARCH_count);
   1921      1.1  christos 
   1922  1.1.1.2  christos   /* Fast search for new reloc types.  */
   1923  1.1.1.2  christos   if (BFD_RELOC_LARCH_B16 <= code && code < BFD_RELOC_LARCH_RELAX)
   1924  1.1.1.2  christos     {
   1925  1.1.1.2  christos       BFD_ASSERT (BFD_RELOC_LARCH_RELAX - BFD_RELOC_LARCH_B16
   1926  1.1.1.2  christos 		  == R_LARCH_RELAX - R_LARCH_B16);
   1927  1.1.1.2  christos       loongarch_reloc_howto_type *ht;
   1928  1.1.1.2  christos       ht = &loongarch_howto_table[code - BFD_RELOC_LARCH_B16 + R_LARCH_B16];
   1929  1.1.1.2  christos       BFD_ASSERT (ht->bfd_type == code);
   1930  1.1.1.2  christos       return &ht->howto;
   1931  1.1.1.2  christos     }
   1932  1.1.1.2  christos 
   1933      1.1  christos   for (size_t i = 0; i < ARRAY_SIZE (loongarch_howto_table); i++)
   1934      1.1  christos     if (loongarch_howto_table[i].bfd_type == code)
   1935  1.1.1.2  christos       return &loongarch_howto_table[i].howto;
   1936      1.1  christos 
   1937      1.1  christos   (*_bfd_error_handler) (_("%pB: unsupported bfd relocation type %#x"),
   1938      1.1  christos 			 abfd, code);
   1939      1.1  christos   bfd_set_error (bfd_error_bad_value);
   1940      1.1  christos   return NULL;
   1941      1.1  christos }
   1942      1.1  christos 
   1943  1.1.1.2  christos bfd_reloc_code_real_type
   1944  1.1.1.2  christos loongarch_larch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   1945  1.1.1.2  christos 				   const char *l_r_name)
   1946  1.1.1.2  christos {
   1947  1.1.1.2  christos   for (size_t i = 0; i < ARRAY_SIZE (loongarch_howto_table); i++)
   1948  1.1.1.2  christos     {
   1949  1.1.1.2  christos       loongarch_reloc_howto_type *lht = &loongarch_howto_table[i];
   1950  1.1.1.2  christos       if ((NULL != lht->larch_reloc_type_name)
   1951  1.1.1.2  christos 	  && (0 == strcmp (lht->larch_reloc_type_name, l_r_name)))
   1952  1.1.1.2  christos 	return lht->bfd_type;
   1953  1.1.1.2  christos     }
   1954  1.1.1.2  christos 
   1955  1.1.1.2  christos   return BFD_RELOC_NONE;
   1956  1.1.1.2  christos }
   1957  1.1.1.2  christos 
   1958  1.1.1.2  christos 
   1959  1.1.1.2  christos /* Functions for reloc bits field.
   1960  1.1.1.2  christos    1.  Signed extend *fix_val.
   1961  1.1.1.2  christos    2.  Return false if overflow.  */
   1962  1.1.1.2  christos 
   1963      1.1  christos #define LARCH_RELOC_BFD_VMA_BIT_MASK(bitsize) \
   1964      1.1  christos   (~((((bfd_vma)0x1) << (bitsize)) - 1))
   1965      1.1  christos 
   1966      1.1  christos /* Adjust val to perform insn
   1967  1.1.1.2  christos    BFD_RELOC_LARCH_SOP_POP_32_S_10_5
   1968  1.1.1.2  christos    BFD_RELOC_LARCH_SOP_POP_32_S_10_12
   1969  1.1.1.2  christos    BFD_RELOC_LARCH_SOP_POP_32_U_10_12
   1970  1.1.1.2  christos    BFD_RELOC_LARCH_SOP_POP_32_S_10_16
   1971  1.1.1.2  christos    BFD_RELOC_LARCH_SOP_POP_32_S_5_20
   1972  1.1.1.2  christos    BFD_RELOC_LARCH_SOP_POP_32_U.  */
   1973  1.1.1.2  christos 
   1974  1.1.1.2  christos static bool
   1975  1.1.1.2  christos reloc_bits (bfd *abfd ATTRIBUTE_UNUSED,
   1976  1.1.1.2  christos 	    reloc_howto_type *howto,
   1977  1.1.1.2  christos 	    bfd_vma *fix_val)
   1978      1.1  christos {
   1979  1.1.1.2  christos   bfd_signed_vma val = (bfd_signed_vma)(*fix_val);
   1980  1.1.1.2  christos   bfd_signed_vma mask = ((bfd_signed_vma)0x1 << howto->bitsize) - 1;
   1981      1.1  christos 
   1982  1.1.1.2  christos   val = val >> howto->rightshift;
   1983      1.1  christos 
   1984      1.1  christos   /* Perform insn bits field.  */
   1985  1.1.1.2  christos   val = val & mask;
   1986      1.1  christos   val <<= howto->bitpos;
   1987      1.1  christos 
   1988  1.1.1.2  christos   *fix_val = (bfd_vma)val;
   1989      1.1  christos 
   1990      1.1  christos   return true;
   1991      1.1  christos }
   1992      1.1  christos 
   1993  1.1.1.2  christos static bool
   1994  1.1.1.2  christos reloc_sign_bits (bfd *abfd, reloc_howto_type *howto, bfd_vma *fix_val)
   1995      1.1  christos {
   1996      1.1  christos   if (howto->complain_on_overflow != complain_overflow_signed)
   1997      1.1  christos     return false;
   1998      1.1  christos 
   1999  1.1.1.2  christos   bfd_signed_vma val = (bfd_signed_vma)(*fix_val);
   2000  1.1.1.2  christos 
   2001  1.1.1.2  christos   /* Check alignment. FIXME: if rightshift is not alingment.  */
   2002  1.1.1.2  christos   if (howto->rightshift
   2003  1.1.1.2  christos       && (val & ((((bfd_signed_vma) 1) << howto->rightshift) - 1)))
   2004      1.1  christos     {
   2005  1.1.1.2  christos       /* The as passes NULL casued internal error, so it can not use _bfd_error_handler
   2006  1.1.1.2  christos 	 output details, ld is not affected.  */
   2007  1.1.1.2  christos       if (abfd != NULL)
   2008  1.1.1.2  christos 	{
   2009  1.1.1.2  christos 	  (*_bfd_error_handler) (_("%pB: relocation %s right shift %d error 0x%lx"),
   2010  1.1.1.2  christos 				 abfd, howto->name, howto->rightshift, (long) val);
   2011  1.1.1.2  christos 	  bfd_set_error (bfd_error_bad_value);
   2012  1.1.1.2  christos 	}
   2013  1.1.1.2  christos       return false;
   2014      1.1  christos     }
   2015  1.1.1.2  christos 
   2016  1.1.1.2  christos   bfd_signed_vma mask = ((bfd_signed_vma)0x1 << (howto->bitsize
   2017  1.1.1.2  christos 			  + howto->rightshift - 1)) - 1;
   2018  1.1.1.2  christos 
   2019  1.1.1.2  christos   /* Positive number: high part is all 0;
   2020  1.1.1.2  christos      Negative number: if high part is not all 0, high part must be all 1.
   2021  1.1.1.2  christos      high part: from sign bit to highest bit.  */
   2022  1.1.1.2  christos   if ((val & ~mask) && ((val & ~mask) != ~mask))
   2023      1.1  christos     {
   2024  1.1.1.2  christos       /* The as passes NULL casued internal error, so it can not use _bfd_error_handler
   2025  1.1.1.2  christos 	 output details, ld is not affected.  */
   2026  1.1.1.2  christos       if (abfd != NULL)
   2027  1.1.1.2  christos 	{
   2028  1.1.1.2  christos 	  (*_bfd_error_handler) (_("%pB: relocation %s overflow 0x%lx"),
   2029  1.1.1.2  christos 				 abfd, howto->name, (long) val);
   2030  1.1.1.2  christos 	  bfd_set_error (bfd_error_bad_value);
   2031  1.1.1.2  christos 	}
   2032  1.1.1.2  christos       return false;
   2033      1.1  christos     }
   2034      1.1  christos 
   2035  1.1.1.2  christos   val = val >> howto->rightshift;
   2036  1.1.1.2  christos   /* can delete? */
   2037  1.1.1.2  christos   mask = ((bfd_signed_vma)0x1 << howto->bitsize) - 1;
   2038  1.1.1.2  christos   val = val & mask;
   2039      1.1  christos 
   2040  1.1.1.2  christos   switch (howto->type)
   2041  1.1.1.2  christos     {
   2042  1.1.1.2  christos     case R_LARCH_SOP_POP_32_S_0_10_10_16_S2:
   2043  1.1.1.2  christos     case R_LARCH_B26:
   2044  1.1.1.2  christos       /* Perform insn bits field. 15:0<<10, 25:16>>16.  */
   2045  1.1.1.2  christos       val = ((val & 0xffff) << 10) | ((val >> 16) & 0x3ff);
   2046  1.1.1.2  christos       break;
   2047  1.1.1.2  christos     case R_LARCH_SOP_POP_32_S_0_5_10_16_S2:
   2048  1.1.1.2  christos     case R_LARCH_B21:
   2049  1.1.1.2  christos       /* Perform insn bits field. 15:0<<10, 20:16>>16.  */
   2050  1.1.1.2  christos       val = ((val & 0xffff) << 10) | ((val >> 16) & 0x1f);
   2051  1.1.1.2  christos       break;
   2052  1.1.1.2  christos     case R_LARCH_CALL36:
   2053  1.1.1.2  christos       /* 0x8000: If low 16-bit immediate greater than 0x7fff,
   2054  1.1.1.2  christos 	 it become to a negative number due to sign-extended,
   2055  1.1.1.2  christos 	 so the high part need to add 0x8000.  */
   2056  1.1.1.2  christos       val = (((val + 0x8000) >> 16) << 5) | (((val & 0xffff) << 10) << 32);
   2057  1.1.1.2  christos       break;
   2058  1.1.1.2  christos     default:
   2059  1.1.1.2  christos       val <<= howto->bitpos;
   2060  1.1.1.2  christos       break;
   2061  1.1.1.2  christos     }
   2062      1.1  christos 
   2063      1.1  christos   *fix_val = val;
   2064      1.1  christos   return true;
   2065      1.1  christos }
   2066      1.1  christos 
   2067  1.1.1.2  christos bool
   2068  1.1.1.2  christos loongarch_adjust_reloc_bitsfield (bfd *abfd, reloc_howto_type *howto,
   2069  1.1.1.2  christos 				  bfd_vma *fix_val)
   2070      1.1  christos {
   2071  1.1.1.2  christos   BFD_ASSERT (((loongarch_reloc_howto_type *)howto)->adjust_reloc_bits);
   2072  1.1.1.2  christos   return ((loongarch_reloc_howto_type *)
   2073  1.1.1.2  christos 	  howto)->adjust_reloc_bits (abfd, howto, fix_val);
   2074  1.1.1.2  christos }
   2075      1.1  christos 
   2076  1.1.1.2  christos static bfd_reloc_status_type
   2077  1.1.1.2  christos loongarch_elf_add_sub_reloc (bfd *abfd,
   2078  1.1.1.2  christos 	       arelent *reloc_entry,
   2079  1.1.1.2  christos 	       asymbol *symbol,
   2080  1.1.1.2  christos 	       void *data,
   2081  1.1.1.2  christos 	       asection *input_section,
   2082  1.1.1.2  christos 	       bfd *output_bfd,
   2083  1.1.1.2  christos 	       char **error_message ATTRIBUTE_UNUSED)
   2084  1.1.1.2  christos {
   2085  1.1.1.2  christos   reloc_howto_type *howto = reloc_entry->howto;
   2086  1.1.1.2  christos   bfd_vma relocation;
   2087      1.1  christos 
   2088  1.1.1.2  christos   if (output_bfd != NULL
   2089  1.1.1.2  christos       && (symbol->flags & BSF_SECTION_SYM) == 0
   2090  1.1.1.2  christos       && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
   2091      1.1  christos     {
   2092  1.1.1.2  christos       reloc_entry->address += input_section->output_offset;
   2093  1.1.1.2  christos       return bfd_reloc_ok;
   2094      1.1  christos     }
   2095  1.1.1.2  christos 
   2096  1.1.1.2  christos   if (output_bfd != NULL)
   2097  1.1.1.2  christos     return bfd_reloc_continue;
   2098  1.1.1.2  christos 
   2099  1.1.1.2  christos   relocation = symbol->value + symbol->section->output_section->vma
   2100  1.1.1.2  christos     + symbol->section->output_offset + reloc_entry->addend;
   2101  1.1.1.2  christos 
   2102  1.1.1.2  christos   bfd_size_type octets = reloc_entry->address
   2103  1.1.1.2  christos     * bfd_octets_per_byte (abfd, input_section);
   2104  1.1.1.2  christos   if (!bfd_reloc_offset_in_range (reloc_entry->howto, abfd,
   2105  1.1.1.2  christos 				  input_section, octets))
   2106  1.1.1.2  christos     return bfd_reloc_outofrange;
   2107  1.1.1.2  christos 
   2108  1.1.1.2  christos   bfd_vma old_value = bfd_get (howto->bitsize, abfd,
   2109  1.1.1.2  christos 			       data + reloc_entry->address);
   2110  1.1.1.2  christos 
   2111  1.1.1.2  christos   switch (howto->type)
   2112      1.1  christos     {
   2113  1.1.1.2  christos     case R_LARCH_ADD6:
   2114  1.1.1.2  christos     case R_LARCH_ADD8:
   2115  1.1.1.2  christos     case R_LARCH_ADD16:
   2116  1.1.1.2  christos     case R_LARCH_ADD32:
   2117  1.1.1.2  christos     case R_LARCH_ADD64:
   2118  1.1.1.2  christos       relocation = old_value + relocation;
   2119  1.1.1.2  christos       break;
   2120  1.1.1.2  christos 
   2121  1.1.1.2  christos     case R_LARCH_SUB6:
   2122  1.1.1.2  christos     case R_LARCH_SUB8:
   2123  1.1.1.2  christos     case R_LARCH_SUB16:
   2124  1.1.1.2  christos     case R_LARCH_SUB32:
   2125  1.1.1.2  christos     case R_LARCH_SUB64:
   2126  1.1.1.2  christos       relocation = old_value - relocation;
   2127  1.1.1.2  christos       break;
   2128      1.1  christos     }
   2129      1.1  christos 
   2130  1.1.1.2  christos   bfd_put (howto->bitsize, abfd, relocation, data + reloc_entry->address);
   2131      1.1  christos 
   2132  1.1.1.2  christos   return bfd_reloc_ok;
   2133  1.1.1.2  christos }
   2134      1.1  christos 
   2135  1.1.1.2  christos static bfd_reloc_status_type
   2136  1.1.1.2  christos loongarch_elf_add_sub_reloc_uleb128 (bfd *abfd,
   2137  1.1.1.2  christos 	       arelent *reloc_entry,
   2138  1.1.1.2  christos 	       asymbol *symbol,
   2139  1.1.1.2  christos 	       void *data,
   2140  1.1.1.2  christos 	       asection *input_section,
   2141  1.1.1.2  christos 	       bfd *output_bfd,
   2142  1.1.1.2  christos 	       char **error_message ATTRIBUTE_UNUSED)
   2143  1.1.1.2  christos {
   2144  1.1.1.2  christos   reloc_howto_type *howto = reloc_entry->howto;
   2145  1.1.1.2  christos   bfd_vma relocation;
   2146      1.1  christos 
   2147  1.1.1.2  christos  if (output_bfd != NULL
   2148  1.1.1.2  christos      && (symbol->flags & BSF_SECTION_SYM) == 0
   2149  1.1.1.2  christos      && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
   2150  1.1.1.2  christos    {
   2151  1.1.1.2  christos      reloc_entry->address += input_section->output_offset;
   2152  1.1.1.2  christos      return bfd_reloc_ok;
   2153  1.1.1.2  christos    }
   2154  1.1.1.2  christos 
   2155  1.1.1.2  christos   if (output_bfd != NULL)
   2156  1.1.1.2  christos     return bfd_reloc_continue;
   2157  1.1.1.2  christos 
   2158  1.1.1.2  christos   relocation = symbol->value + symbol->section->output_section->vma
   2159  1.1.1.2  christos     + symbol->section->output_offset + reloc_entry->addend;
   2160  1.1.1.2  christos 
   2161  1.1.1.2  christos   bfd_size_type octets = reloc_entry->address
   2162  1.1.1.2  christos     * bfd_octets_per_byte (abfd, input_section);
   2163  1.1.1.2  christos   if (!bfd_reloc_offset_in_range (reloc_entry->howto, abfd,
   2164  1.1.1.2  christos 				  input_section, octets))
   2165  1.1.1.2  christos     return bfd_reloc_outofrange;
   2166  1.1.1.2  christos 
   2167  1.1.1.2  christos   unsigned int len = 0;
   2168  1.1.1.2  christos   bfd_byte *p = data + reloc_entry->address;
   2169  1.1.1.2  christos   bfd_vma old_value = _bfd_read_unsigned_leb128 (abfd, p, &len);
   2170  1.1.1.2  christos 
   2171  1.1.1.2  christos   switch (howto->type)
   2172  1.1.1.2  christos     {
   2173  1.1.1.2  christos     case R_LARCH_ADD_ULEB128:
   2174  1.1.1.2  christos       relocation = old_value + relocation;
   2175  1.1.1.2  christos       break;
   2176  1.1.1.2  christos 
   2177  1.1.1.2  christos     case R_LARCH_SUB_ULEB128:
   2178  1.1.1.2  christos       relocation = old_value - relocation;
   2179  1.1.1.2  christos       break;
   2180  1.1.1.2  christos     }
   2181  1.1.1.2  christos 
   2182  1.1.1.2  christos   bfd_vma mask = (1 << (7 * len)) - 1;
   2183  1.1.1.2  christos   relocation = relocation & mask;
   2184  1.1.1.2  christos   loongarch_write_unsigned_leb128 (p, len, relocation);
   2185  1.1.1.2  christos   return bfd_reloc_ok;
   2186      1.1  christos }
   2187      1.1  christos 
   2188  1.1.1.2  christos /* Write VALUE in uleb128 format to P.
   2189  1.1.1.2  christos    LEN is the uleb128 value length.
   2190  1.1.1.2  christos    Return a pointer to the byte following the last byte that was written.  */
   2191  1.1.1.2  christos bfd_byte *
   2192  1.1.1.2  christos loongarch_write_unsigned_leb128 (bfd_byte *p, unsigned int len, bfd_vma value)
   2193      1.1  christos {
   2194  1.1.1.2  christos   bfd_byte c;
   2195  1.1.1.2  christos   do
   2196  1.1.1.2  christos     {
   2197  1.1.1.2  christos       c = value & 0x7f;
   2198  1.1.1.2  christos       if (len > 1)
   2199  1.1.1.2  christos 	c |= 0x80;
   2200  1.1.1.2  christos       *(p++) = c;
   2201  1.1.1.2  christos       value >>= 7;
   2202  1.1.1.2  christos       len--;
   2203  1.1.1.2  christos     }
   2204  1.1.1.2  christos   while (len);
   2205  1.1.1.2  christos   return p;
   2206  1.1.1.2  christos }
   2207  1.1.1.2  christos 
   2208  1.1.1.2  christos int loongarch_get_uleb128_length (bfd_byte *buf)
   2209  1.1.1.2  christos {
   2210  1.1.1.2  christos   unsigned int len = 0;
   2211  1.1.1.2  christos   _bfd_read_unsigned_leb128 (NULL, buf, &len);
   2212  1.1.1.2  christos   return len;
   2213      1.1  christos }
   2214