Home | History | Annotate | Line # | Download | only in bfd
elfxx-loongarch.c revision 1.1.1.1
      1  1.1  christos /* LoongArch-specific support for ELF.
      2  1.1  christos    Copyright (C) 2021-2022 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  christos   bool (*adjust_reloc_bits)(reloc_howto_type *, bfd_vma *);
     38  1.1  christos   const char *larch_reloc_type_name;
     39  1.1  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  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  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  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  christos   { EMPTY_HOWTO (C), BFD_RELOC_NONE, NULL, NULL }
     53  1.1  christos 
     54  1.1  christos static bool
     55  1.1  christos reloc_bits (reloc_howto_type *howto, bfd_vma *val);
     56  1.1  christos static bool
     57  1.1  christos reloc_bits_b16 (reloc_howto_type *howto, bfd_vma *fix_val);
     58  1.1  christos static bool
     59  1.1  christos reloc_bits_b21 (reloc_howto_type *howto, bfd_vma *fix_val);
     60  1.1  christos static bool
     61  1.1  christos reloc_bits_b26 (reloc_howto_type *howto, bfd_vma *val);
     62  1.1  christos 
     63  1.1  christos /* This does not include any relocation information, but should be
     64  1.1  christos    good enough for GDB or objdump to read the file.  */
     65  1.1  christos static loongarch_reloc_howto_type loongarch_howto_table[] =
     66  1.1  christos {
     67  1.1  christos   /* No relocation.  */
     68  1.1  christos     LOONGARCH_HOWTO (R_LARCH_NONE,	  /* type (0).  */
     69  1.1  christos 	 0,				  /* rightshift */
     70  1.1  christos 	 0,				  /* size */
     71  1.1  christos 	 0,				  /* bitsize */
     72  1.1  christos 	 false,				  /* pc_relative */
     73  1.1  christos 	 0,				  /* bitpos */
     74  1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
     75  1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
     76  1.1  christos 	 "R_LARCH_NONE",		  /* name */
     77  1.1  christos 	 false,				  /* partial_inplace */
     78  1.1  christos 	 0,				  /* src_mask */
     79  1.1  christos 	 0,				  /* dst_mask */
     80  1.1  christos 	 false,				  /* pcrel_offset */
     81  1.1  christos 	 BFD_RELOC_NONE,		  /* bfd_reloc_code_real_type */
     82  1.1  christos 	 NULL,				  /* adjust_reloc_bits */
     83  1.1  christos 	 NULL),				  /* larch_reloc_type_name */
     84  1.1  christos 
     85  1.1  christos   /* 32 bit relocation.  */
     86  1.1  christos   LOONGARCH_HOWTO (R_LARCH_32,		  /* type (1).  */
     87  1.1  christos 	 0,				  /* rightshift */
     88  1.1  christos 	 4,				  /* size */
     89  1.1  christos 	 32,				  /* bitsize */
     90  1.1  christos 	 false,				  /* pc_relative */
     91  1.1  christos 	 0,				  /* bitpos */
     92  1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
     93  1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
     94  1.1  christos 	 "R_LARCH_32",			  /* name */
     95  1.1  christos 	 false,				  /* partial_inplace */
     96  1.1  christos 	 0,				  /* src_mask */
     97  1.1  christos 	 ALL_ONES,			  /* dst_mask */
     98  1.1  christos 	 false,				  /* pcrel_offset */
     99  1.1  christos 	 BFD_RELOC_32,			  /* bfd_reloc_code_real_type */
    100  1.1  christos 	 NULL,				  /* adjust_reloc_bits */
    101  1.1  christos 	 NULL),				  /* larch_reloc_type_name */
    102  1.1  christos 
    103  1.1  christos   /* 64 bit relocation.  */
    104  1.1  christos   LOONGARCH_HOWTO (R_LARCH_64,		  /* type (2).  */
    105  1.1  christos 	 0,				  /* rightshift */
    106  1.1  christos 	 8,				  /* size */
    107  1.1  christos 	 64,				  /* bitsize */
    108  1.1  christos 	 false,				  /* pc_relative */
    109  1.1  christos 	 0,				  /* bitpos */
    110  1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    111  1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    112  1.1  christos 	 "R_LARCH_64",			  /* name */
    113  1.1  christos 	 false,				  /* partial_inplace */
    114  1.1  christos 	 0,				  /* src_mask */
    115  1.1  christos 	 ALL_ONES,			  /* dst_mask */
    116  1.1  christos 	 false,				  /* pcrel_offset */
    117  1.1  christos 	 BFD_RELOC_64,			  /* bfd_reloc_code_real_type */
    118  1.1  christos 	 NULL,				  /* adjust_reloc_bits */
    119  1.1  christos 	 NULL),				  /* larch_reloc_type_name */
    120  1.1  christos 
    121  1.1  christos   LOONGARCH_HOWTO (R_LARCH_RELATIVE,	  /* type (3).  */
    122  1.1  christos 	 0,				  /* rightshift */
    123  1.1  christos 	 4,				  /* size */
    124  1.1  christos 	 32,				  /* bitsize */
    125  1.1  christos 	 false,				  /* pc_relative */
    126  1.1  christos 	 0,				  /* bitpos */
    127  1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    128  1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    129  1.1  christos 	 "R_LARCH_RELATIVE",		  /* name */
    130  1.1  christos 	 false,				  /* partial_inplace */
    131  1.1  christos 	 0,				  /* src_mask */
    132  1.1  christos 	 ALL_ONES,			  /* dst_mask */
    133  1.1  christos 	 false,				  /* pcrel_offset */
    134  1.1  christos 	 BFD_RELOC_NONE,		  /* undefined?  */
    135  1.1  christos 	 NULL,				  /* adjust_reloc_bits */
    136  1.1  christos 	 NULL),				  /* larch_reloc_type_name */
    137  1.1  christos 
    138  1.1  christos   LOONGARCH_HOWTO (R_LARCH_COPY,	  /* type (4).  */
    139  1.1  christos 	 0,				  /* rightshift */
    140  1.1  christos 	 0,				  /* this one is variable size */
    141  1.1  christos 	 0,				  /* bitsize */
    142  1.1  christos 	 false,				  /* pc_relative */
    143  1.1  christos 	 0,				  /* bitpos */
    144  1.1  christos 	 complain_overflow_bitfield,	  /* complain_on_overflow */
    145  1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    146  1.1  christos 	 "R_LARCH_COPY",		  /* name */
    147  1.1  christos 	 false,				  /* partial_inplace */
    148  1.1  christos 	 0,				  /* src_mask */
    149  1.1  christos 	 0,				  /* dst_mask */
    150  1.1  christos 	 false,				  /* pcrel_offset */
    151  1.1  christos 	 BFD_RELOC_NONE,		  /* undefined?  */
    152  1.1  christos 	 NULL,				  /* adjust_reloc_bits */
    153  1.1  christos 	 NULL),				  /* larch_reloc_type_name */
    154  1.1  christos 
    155  1.1  christos   LOONGARCH_HOWTO (R_LARCH_JUMP_SLOT,	  /* type (5).  */
    156  1.1  christos 	 0,				  /* rightshift */
    157  1.1  christos 	 8,				  /* size */
    158  1.1  christos 	 64,				  /* bitsize */
    159  1.1  christos 	 false,				  /* pc_relative */
    160  1.1  christos 	 0,				  /* bitpos */
    161  1.1  christos 	 complain_overflow_bitfield,	  /* complain_on_overflow */
    162  1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    163  1.1  christos 	 "R_LARCH_JUMP_SLOT",		  /* name */
    164  1.1  christos 	 false,				  /* partial_inplace */
    165  1.1  christos 	 0,				  /* src_mask */
    166  1.1  christos 	 0,				  /* dst_mask */
    167  1.1  christos 	 false,				  /* pcrel_offset */
    168  1.1  christos 	 BFD_RELOC_NONE,		  /* undefined?  */
    169  1.1  christos 	 NULL,				  /* adjust_reloc_bits */
    170  1.1  christos 	 NULL),				  /* larch_reloc_type_name */
    171  1.1  christos 
    172  1.1  christos   /* Dynamic TLS relocations.  */
    173  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DTPMOD32,  /* type (6).  */
    174  1.1  christos 	 0,				  /* rightshift */
    175  1.1  christos 	 4,				  /* size */
    176  1.1  christos 	 32,				  /* bitsize */
    177  1.1  christos 	 false,				  /* pc_relative */
    178  1.1  christos 	 0,				  /* bitpos */
    179  1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    180  1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    181  1.1  christos 	 "R_LARCH_TLS_DTPMOD32",	  /* name */
    182  1.1  christos 	 false,				  /* partial_inplace */
    183  1.1  christos 	 0,				  /* src_mask */
    184  1.1  christos 	 ALL_ONES,			  /* dst_mask */
    185  1.1  christos 	 false,				  /* pcrel_offset */
    186  1.1  christos 	 BFD_RELOC_LARCH_TLS_DTPMOD32,	  /* bfd_reloc_code_real_type */
    187  1.1  christos 	 NULL,				  /* adjust_reloc_bits */
    188  1.1  christos 	 NULL),				  /* larch_reloc_type_name */
    189  1.1  christos 
    190  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DTPMOD64,  /* type (7).  */
    191  1.1  christos 	 0,				  /* rightshift */
    192  1.1  christos 	 8,				  /* size */
    193  1.1  christos 	 64,				  /* bitsize */
    194  1.1  christos 	 false,				  /* pc_relative */
    195  1.1  christos 	 0,				  /* bitpos */
    196  1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    197  1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    198  1.1  christos 	 "R_LARCH_TLS_DTPMOD64",	  /* name */
    199  1.1  christos 	 false,				  /* partial_inplace */
    200  1.1  christos 	 0,				  /* src_mask */
    201  1.1  christos 	 ALL_ONES,			  /* dst_mask */
    202  1.1  christos 	 false,				  /* pcrel_offset */
    203  1.1  christos 	 BFD_RELOC_LARCH_TLS_DTPMOD64,	  /* bfd_reloc_code_real_type */
    204  1.1  christos 	 NULL,				  /* adjust_reloc_bits */
    205  1.1  christos 	 NULL),				  /* larch_reloc_type_name */
    206  1.1  christos 
    207  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DTPREL32,  /* type (8). */
    208  1.1  christos 	 0,				  /* rightshift */
    209  1.1  christos 	 4,				  /* size */
    210  1.1  christos 	 32,				  /* bitsize */
    211  1.1  christos 	 false,				  /* pc_relative */
    212  1.1  christos 	 0,				  /* bitpos */
    213  1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    214  1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    215  1.1  christos 	 "R_LARCH_TLS_DTPREL32",	  /* name */
    216  1.1  christos 	 true,				  /* partial_inplace */
    217  1.1  christos 	 0,				  /* src_mask */
    218  1.1  christos 	 ALL_ONES,			  /* dst_mask */
    219  1.1  christos 	 false,				  /* pcrel_offset */
    220  1.1  christos 	 BFD_RELOC_LARCH_TLS_DTPREL32,	  /* bfd_reloc_code_real_type */
    221  1.1  christos 	 NULL,				  /* adjust_reloc_bits */
    222  1.1  christos 	 NULL),				  /* larch_reloc_type_name */
    223  1.1  christos 
    224  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_DTPREL64,  /* type (9).  */
    225  1.1  christos 	 0,				  /* rightshift */
    226  1.1  christos 	 8,				  /* size */
    227  1.1  christos 	 64,				  /* bitsize */
    228  1.1  christos 	 false,				  /* pc_relative */
    229  1.1  christos 	 0,				  /* bitpos */
    230  1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    231  1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    232  1.1  christos 	 "R_LARCH_TLS_DTPREL64",	  /* name */
    233  1.1  christos 	 true,				  /* partial_inplace */
    234  1.1  christos 	 0,				  /* src_mask */
    235  1.1  christos 	 ALL_ONES,			  /* dst_mask */
    236  1.1  christos 	 false,				  /* pcrel_offset */
    237  1.1  christos 	 BFD_RELOC_LARCH_TLS_DTPREL64,	  /* bfd_reloc_code_real_type */
    238  1.1  christos 	 NULL,				  /* adjust_reloc_bits */
    239  1.1  christos 	 NULL),				  /* larch_reloc_type_name */
    240  1.1  christos 
    241  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_TPREL32,	  /* type (10).  */
    242  1.1  christos 	 0,				  /* rightshift */
    243  1.1  christos 	 4,				  /* size */
    244  1.1  christos 	 32,				  /* bitsize */
    245  1.1  christos 	 false,				  /* pc_relative */
    246  1.1  christos 	 0,				  /* bitpos */
    247  1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    248  1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    249  1.1  christos 	 "R_LARCH_TLS_TPREL32",		  /* name */
    250  1.1  christos 	 false,				  /* partial_inplace */
    251  1.1  christos 	 0,				  /* src_mask */
    252  1.1  christos 	 ALL_ONES,			  /* dst_mask */
    253  1.1  christos 	 false,				  /* pcrel_offset */
    254  1.1  christos 	 BFD_RELOC_LARCH_TLS_TPREL32,	  /* bfd_reloc_code_real_type */
    255  1.1  christos 	 NULL,				  /* adjust_reloc_bits */
    256  1.1  christos 	 NULL),				  /* larch_reloc_type_name */
    257  1.1  christos 
    258  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_TPREL64,	  /* type (11).  */
    259  1.1  christos 	 0,				  /* rightshift */
    260  1.1  christos 	 8,				  /* size */
    261  1.1  christos 	 64,				  /* bitsize */
    262  1.1  christos 	 false,				  /* pc_relative */
    263  1.1  christos 	 0,				  /* bitpos */
    264  1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    265  1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    266  1.1  christos 	 "R_LARCH_TLS_TPREL64",		  /* name */
    267  1.1  christos 	 false,				  /* partial_inplace */
    268  1.1  christos 	 0,				  /* src_mask */
    269  1.1  christos 	 ALL_ONES,			  /* dst_mask */
    270  1.1  christos 	 false,				  /* pcrel_offset */
    271  1.1  christos 	 BFD_RELOC_LARCH_TLS_TPREL64,	  /* bfd_reloc_code_real_type */
    272  1.1  christos 	 NULL,				  /* adjust_reloc_bits */
    273  1.1  christos 	 NULL),				  /* larch_reloc_type_name */
    274  1.1  christos 
    275  1.1  christos   LOONGARCH_HOWTO (R_LARCH_IRELATIVE,	  /* type (12).  */
    276  1.1  christos 	 0,				  /* rightshift */
    277  1.1  christos 	 4,				  /* size */
    278  1.1  christos 	 32,				  /* bitsize */
    279  1.1  christos 	 false,				  /* pc_relative */
    280  1.1  christos 	 0,				  /* bitpos */
    281  1.1  christos 	 complain_overflow_dont,	  /* complain_on_overflow */
    282  1.1  christos 	 bfd_elf_generic_reloc,		  /* special_function */
    283  1.1  christos 	 "R_LARCH_IRELATIVE",		  /* name */
    284  1.1  christos 	 false,				  /* partial_inplace */
    285  1.1  christos 	 0,				  /* src_mask */
    286  1.1  christos 	 ALL_ONES,			  /* dst_mask */
    287  1.1  christos 	 false,				  /* pcrel_offset */
    288  1.1  christos 	 BFD_RELOC_NONE,		  /* undefined?  */
    289  1.1  christos 	 NULL,				  /* adjust_reloc_bits */
    290  1.1  christos 	 NULL),				  /* larch_reloc_type_name */
    291  1.1  christos 
    292  1.1  christos   LOONGARCH_EMPTY_HOWTO (13),
    293  1.1  christos   LOONGARCH_EMPTY_HOWTO (14),
    294  1.1  christos   LOONGARCH_EMPTY_HOWTO (15),
    295  1.1  christos   LOONGARCH_EMPTY_HOWTO (16),
    296  1.1  christos   LOONGARCH_EMPTY_HOWTO (17),
    297  1.1  christos   LOONGARCH_EMPTY_HOWTO (18),
    298  1.1  christos   LOONGARCH_EMPTY_HOWTO (19),
    299  1.1  christos 
    300  1.1  christos   LOONGARCH_HOWTO (R_LARCH_MARK_LA,		/* type (20).  */
    301  1.1  christos 	 0,					/* rightshift.  */
    302  1.1  christos 	 0,					/* size.  */
    303  1.1  christos 	 0,					/* bitsize.  */
    304  1.1  christos 	 false,					/* pc_relative.  */
    305  1.1  christos 	 0,					/* bitpos.  */
    306  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    307  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    308  1.1  christos 	 "R_LARCH_MARK_LA",			/* name.  */
    309  1.1  christos 	 false,					/* partial_inplace.  */
    310  1.1  christos 	 0,					/* src_mask.  */
    311  1.1  christos 	 0,					/* dst_mask.  */
    312  1.1  christos 	 false,					/* pcrel_offset */
    313  1.1  christos 	 BFD_RELOC_LARCH_MARK_LA,		/* bfd_reloc_code_real_type */
    314  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    315  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    316  1.1  christos 
    317  1.1  christos   LOONGARCH_HOWTO (R_LARCH_MARK_PCREL,		/* type (21).  */
    318  1.1  christos 	 0,					/* rightshift.  */
    319  1.1  christos 	 0,					/* size.  */
    320  1.1  christos 	 0,					/* bitsize.  */
    321  1.1  christos 	 false,					/* pc_relative.  */
    322  1.1  christos 	 0,					/* bitpos.  */
    323  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    324  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    325  1.1  christos 	 "R_LARCH_MARK_PCREL",			/* name.  */
    326  1.1  christos 	 false,					/* partial_inplace.  */
    327  1.1  christos 	 0,					/* src_mask.  */
    328  1.1  christos 	 0,					/* dst_mask.  */
    329  1.1  christos 	 false,					/* pcrel_offset */
    330  1.1  christos 	 BFD_RELOC_LARCH_MARK_PCREL,		/* bfd_reloc_code_real_type */
    331  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    332  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    333  1.1  christos 
    334  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_PUSH_PCREL,	/* type (22).  */
    335  1.1  christos 	 2,					/* rightshift.  */
    336  1.1  christos 	 4,					/* size.  */
    337  1.1  christos 	 32,					/* bitsize.  */
    338  1.1  christos 	 true /* FIXME: somewhat use this.  */,	/* pc_relative.  */
    339  1.1  christos 	 0,					/* bitpos.  */
    340  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    341  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    342  1.1  christos 	 "R_LARCH_SOP_PUSH_PCREL",		/* name.  */
    343  1.1  christos 	 false,					/* partial_inplace.  */
    344  1.1  christos 	 0x03ffffff,				/* src_mask.  */
    345  1.1  christos 	 0x03ffffff,				/* dst_mask.  */
    346  1.1  christos 	 false,					/* pcrel_offset */
    347  1.1  christos 	 BFD_RELOC_LARCH_SOP_PUSH_PCREL,	/* bfd_reloc_code_real_type */
    348  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    349  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    350  1.1  christos 
    351  1.1  christos   /* type 23-37.  */
    352  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_ABSOLUTE),
    353  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_DUP),
    354  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_GPREL),
    355  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_TLS_TPREL),
    356  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_TLS_GOT),
    357  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_TLS_GD),
    358  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_PUSH_PLT_PCREL),
    359  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_ASSERT),
    360  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_NOT),
    361  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_SUB),
    362  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_SL),
    363  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_SR),
    364  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_ADD),
    365  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_AND),
    366  1.1  christos   LOONGARCH_DEFAULT_HOWTO (SOP_IF_ELSE),
    367  1.1  christos 
    368  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_10_5,	  /* type (38).  */
    369  1.1  christos 	 0,					  /* rightshift.  */
    370  1.1  christos 	 4,					  /* size.  */
    371  1.1  christos 	 5,					  /* bitsize.  */
    372  1.1  christos 	 false,					  /* pc_relative.  */
    373  1.1  christos 	 10,					  /* bitpos.  */
    374  1.1  christos 	 complain_overflow_signed,		  /* complain_on_overflow.  */
    375  1.1  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    376  1.1  christos 	 "R_LARCH_SOP_POP_32_S_10_5",		  /* name.  */
    377  1.1  christos 	 false,					  /* partial_inplace.  */
    378  1.1  christos 	 0,					  /* src_mask */
    379  1.1  christos 	 0x7c00,				  /* dst_mask */
    380  1.1  christos 	 false,					  /* pcrel_offset */
    381  1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_10_5,	  /* bfd_reloc_code_real_type */
    382  1.1  christos 	 reloc_bits,				  /* adjust_reloc_bits */
    383  1.1  christos 	 NULL),					  /* larch_reloc_type_name */
    384  1.1  christos 
    385  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_U_10_12,	  /* type (39).  */
    386  1.1  christos 	 0,					  /* rightshift.  */
    387  1.1  christos 	 4,					  /* size.  */
    388  1.1  christos 	 12,					  /* bitsize.  */
    389  1.1  christos 	 false,					  /* pc_relative.  */
    390  1.1  christos 	 10,					  /* bitpos.  */
    391  1.1  christos 	 complain_overflow_unsigned,		  /* complain_on_overflow.  */
    392  1.1  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    393  1.1  christos 	 "R_LARCH_SOP_POP_32_U_10_12",		  /* name.  */
    394  1.1  christos 	 false,					  /* partial_inplace.  */
    395  1.1  christos 	 0,					  /* src_mask */
    396  1.1  christos 	 0x3ffc00,				  /* dst_mask */
    397  1.1  christos 	 false,					  /* pcrel_offset */
    398  1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_U_10_12,	  /* bfd_reloc_code_real_type */
    399  1.1  christos 	 reloc_bits,				  /* adjust_reloc_bits */
    400  1.1  christos 	 NULL),					  /* larch_reloc_type_name */
    401  1.1  christos 
    402  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_10_12,	  /* type (40).  */
    403  1.1  christos 	 0,					  /* rightshift.  */
    404  1.1  christos 	 4,					  /* size.  */
    405  1.1  christos 	 12,					  /* bitsize.  */
    406  1.1  christos 	 false,					  /* pc_relative.  */
    407  1.1  christos 	 10,					  /* bitpos.  */
    408  1.1  christos 	 complain_overflow_signed,		  /* complain_on_overflow.  */
    409  1.1  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    410  1.1  christos 	 "R_LARCH_SOP_POP_32_S_10_12",		  /* name.  */
    411  1.1  christos 	 false,					  /* partial_inplace.  */
    412  1.1  christos 	 0,					  /* src_mask */
    413  1.1  christos 	 0x3ffc00,				  /* dst_mask */
    414  1.1  christos 	 false,					  /* pcrel_offset */
    415  1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_10_12,	  /* bfd_reloc_code_real_type */
    416  1.1  christos 	 reloc_bits,				  /* adjust_reloc_bits */
    417  1.1  christos 	 NULL),					  /* larch_reloc_type_name */
    418  1.1  christos 
    419  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_10_16,	  /* type (41).  */
    420  1.1  christos 	 0,					  /* rightshift.  */
    421  1.1  christos 	 4,					  /* size.  */
    422  1.1  christos 	 16,					  /* bitsize.  */
    423  1.1  christos 	 false,					  /* pc_relative.  */
    424  1.1  christos 	 10,					  /* bitpos.  */
    425  1.1  christos 	 complain_overflow_signed,		  /* complain_on_overflow.  */
    426  1.1  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    427  1.1  christos 	 "R_LARCH_SOP_POP_32_S_10_16",		  /* name.  */
    428  1.1  christos 	 false,					  /* partial_inplace.  */
    429  1.1  christos 	 0,					  /* src_mask */
    430  1.1  christos 	 0x3fffc00,				  /* dst_mask */
    431  1.1  christos 	 false,					  /* pcrel_offset */
    432  1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_10_16,	  /* bfd_reloc_code_real_type */
    433  1.1  christos 	 reloc_bits,				  /* adjust_reloc_bits */
    434  1.1  christos 	 NULL),					  /* larch_reloc_type_name */
    435  1.1  christos 
    436  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_10_16_S2, /* type (42).  */
    437  1.1  christos 	 2,					  /* rightshift.  */
    438  1.1  christos 	 4,					  /* size.  */
    439  1.1  christos 	 16,					  /* bitsize.  */
    440  1.1  christos 	 false,					  /* pc_relative.  */
    441  1.1  christos 	 10,					  /* bitpos.  */
    442  1.1  christos 	 complain_overflow_signed,		  /* complain_on_overflow.  */
    443  1.1  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    444  1.1  christos 	 "R_LARCH_SOP_POP_32_S_10_16_S2",	  /* name.  */
    445  1.1  christos 	 false,					  /* partial_inplace.  */
    446  1.1  christos 	 0,					  /* src_mask */
    447  1.1  christos 	 0x3fffc00,				  /* dst_mask */
    448  1.1  christos 	 false,					  /* pcrel_offset */
    449  1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_10_16_S2,	  /* bfd_reloc_code_real_type */
    450  1.1  christos 	 reloc_bits_b16,			  /* adjust_reloc_bits */
    451  1.1  christos 	 NULL),					  /* larch_reloc_type_name */
    452  1.1  christos 
    453  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_5_20,	  /* type (43).  */
    454  1.1  christos 	 0,					  /* rightshift.  */
    455  1.1  christos 	 4,					  /* size.  */
    456  1.1  christos 	 20,					  /* bitsize.  */
    457  1.1  christos 	 false,					  /* pc_relative.  */
    458  1.1  christos 	 5,					  /* bitpos.  */
    459  1.1  christos 	 complain_overflow_signed,		  /* complain_on_overflow.  */
    460  1.1  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    461  1.1  christos 	 "R_LARCH_SOP_POP_32_S_5_20",		  /* name.  */
    462  1.1  christos 	 false,					  /* partial_inplace.  */
    463  1.1  christos 	 0,					  /* src_mask */
    464  1.1  christos 	 0x1ffffe0,				  /* dst_mask */
    465  1.1  christos 	 false,					  /* pcrel_offset */
    466  1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_5_20,	  /* bfd_reloc_code_real_type */
    467  1.1  christos 	 reloc_bits,				  /* adjust_reloc_bits */
    468  1.1  christos 	 NULL),					  /* larch_reloc_type_name */
    469  1.1  christos 
    470  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_0_5_10_16_S2,
    471  1.1  christos 						  /* type (44).  */
    472  1.1  christos 	 2,					  /* rightshift.  */
    473  1.1  christos 	 4,					  /* size.  */
    474  1.1  christos 	 21,					  /* bitsize.  */
    475  1.1  christos 	 false,					  /* pc_relative.  */
    476  1.1  christos 	 0,					  /* bitpos.  */
    477  1.1  christos 	 complain_overflow_signed,		  /* complain_on_overflow.  */
    478  1.1  christos 	 bfd_elf_generic_reloc,			  /* special_function.  */
    479  1.1  christos 	 "R_LARCH_SOP_POP_32_S_0_5_10_16_S2",	  /* name.  */
    480  1.1  christos 	 false,					  /* partial_inplace.  */
    481  1.1  christos 	 0xfc0003e0,				  /* src_mask */
    482  1.1  christos 	 0xfc0003e0,				  /* dst_mask */
    483  1.1  christos 	 false,					  /* pcrel_offset */
    484  1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_0_5_10_16_S2,
    485  1.1  christos 						  /* bfd_reloc_code_real_type */
    486  1.1  christos 	 reloc_bits_b21,			  /* adjust_reloc_bits */
    487  1.1  christos 	 NULL),					  /* larch_reloc_type_name */
    488  1.1  christos 
    489  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_S_0_10_10_16_S2,	/* type (45).  */
    490  1.1  christos 	 2,					/* rightshift.  */
    491  1.1  christos 	 4,					/* size.  */
    492  1.1  christos 	 26,					/* bitsize.  */
    493  1.1  christos 	 false,					/* pc_relative.  */
    494  1.1  christos 	 0,					/* bitpos.  */
    495  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    496  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    497  1.1  christos 	 "R_LARCH_SOP_POP_32_S_0_10_10_16_S2",	/* name.  */
    498  1.1  christos 	 false,					/* partial_inplace.  */
    499  1.1  christos 	 0,					/* src_mask */
    500  1.1  christos 	 0x03ffffff,				/* dst_mask */
    501  1.1  christos 	 false,					/* pcrel_offset */
    502  1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_S_0_10_10_16_S2,
    503  1.1  christos 						/* bfd_reloc_code_real_type */
    504  1.1  christos 	 reloc_bits_b26,			/* adjust_reloc_bits */
    505  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    506  1.1  christos 
    507  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SOP_POP_32_U,	/* type (46).  */
    508  1.1  christos 	 0,					/* rightshift.  */
    509  1.1  christos 	 4,					/* size.  */
    510  1.1  christos 	 32,					/* bitsize.  */
    511  1.1  christos 	 false,					/* pc_relative.  */
    512  1.1  christos 	 0,					/* bitpos.  */
    513  1.1  christos 	 complain_overflow_unsigned,		/* complain_on_overflow.  */
    514  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    515  1.1  christos 	 "R_LARCH_SOP_POP_32_S_U",		/* name.  */
    516  1.1  christos 	 false,					/* partial_inplace.  */
    517  1.1  christos 	 0xffffffff00000000,			/* src_mask */
    518  1.1  christos 	 0x00000000ffffffff,			/* dst_mask */
    519  1.1  christos 	 false,					/* pcrel_offset */
    520  1.1  christos 	 BFD_RELOC_LARCH_SOP_POP_32_U,		/* bfd_reloc_code_real_type */
    521  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
    522  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    523  1.1  christos 
    524  1.1  christos   LOONGARCH_HOWTO (R_LARCH_ADD8,		/* type (47).  */
    525  1.1  christos 	 0,					/* rightshift.  */
    526  1.1  christos 	 4,					/* size.  */
    527  1.1  christos 	 8,					/* bitsize.  */
    528  1.1  christos 	 false,					/* pc_relative.  */
    529  1.1  christos 	 0,					/* bitpos.  */
    530  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    531  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    532  1.1  christos 	 "R_LARCH_ADD8",			/* name.  */
    533  1.1  christos 	 false,					/* partial_inplace.  */
    534  1.1  christos 	 0,					/* src_mask */
    535  1.1  christos 	 ALL_ONES,				/* dst_mask */
    536  1.1  christos 	 false,					/* pcrel_offset */
    537  1.1  christos 	 BFD_RELOC_LARCH_ADD8,			/* bfd_reloc_code_real_type */
    538  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    539  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    540  1.1  christos 
    541  1.1  christos   LOONGARCH_HOWTO (R_LARCH_ADD16,		/* type (48).  */
    542  1.1  christos 	 0,					/* rightshift.  */
    543  1.1  christos 	 4,					/* size.  */
    544  1.1  christos 	 16,					/* bitsize.  */
    545  1.1  christos 	 false,					/* pc_relative.  */
    546  1.1  christos 	 0,					/* bitpos.  */
    547  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    548  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    549  1.1  christos 	 "R_LARCH_ADD16",			/* name.  */
    550  1.1  christos 	 false,					/* partial_inplace.  */
    551  1.1  christos 	 0,					/* src_mask */
    552  1.1  christos 	 ALL_ONES,				/* dst_mask */
    553  1.1  christos 	 false,					/* pcrel_offset */
    554  1.1  christos 	 BFD_RELOC_LARCH_ADD16,			/* bfd_reloc_code_real_type */
    555  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    556  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    557  1.1  christos 
    558  1.1  christos   LOONGARCH_HOWTO (R_LARCH_ADD24,		/* type (49).  */
    559  1.1  christos 	 0,					/* rightshift.  */
    560  1.1  christos 	 4,					/* size.  */
    561  1.1  christos 	 24,					/* bitsize.  */
    562  1.1  christos 	 false,					/* pc_relative.  */
    563  1.1  christos 	 0,					/* bitpos.  */
    564  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    565  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    566  1.1  christos 	 "R_LARCH_ADD24",			/* name.  */
    567  1.1  christos 	 false,					/* partial_inplace.  */
    568  1.1  christos 	 0,					/* src_mask */
    569  1.1  christos 	 ALL_ONES,				/* dst_mask */
    570  1.1  christos 	 false,					/* pcrel_offset */
    571  1.1  christos 	 BFD_RELOC_LARCH_ADD24,			/* bfd_reloc_code_real_type */
    572  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    573  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    574  1.1  christos 
    575  1.1  christos   LOONGARCH_HOWTO (R_LARCH_ADD32,		/* type (50).  */
    576  1.1  christos 	 0,					/* rightshift.  */
    577  1.1  christos 	 4,					/* size.  */
    578  1.1  christos 	 32,					/* bitsize.  */
    579  1.1  christos 	 false,					/* pc_relative.  */
    580  1.1  christos 	 0,					/* bitpos.  */
    581  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    582  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    583  1.1  christos 	 "R_LARCH_ADD32",			/* name.  */
    584  1.1  christos 	 false,					/* partial_inplace.  */
    585  1.1  christos 	 0,					/* src_mask */
    586  1.1  christos 	 ALL_ONES,				/* dst_mask */
    587  1.1  christos 	 false,					/* pcrel_offset */
    588  1.1  christos 	 BFD_RELOC_LARCH_ADD32,			/* bfd_reloc_code_real_type */
    589  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    590  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    591  1.1  christos 
    592  1.1  christos   LOONGARCH_HOWTO (R_LARCH_ADD64,		/* type (51).  */
    593  1.1  christos 	 0,					/* rightshift.  */
    594  1.1  christos 	 8,					/* size.  */
    595  1.1  christos 	 64,					/* bitsize.  */
    596  1.1  christos 	 false,					/* pc_relative.  */
    597  1.1  christos 	 0,					/* bitpos.  */
    598  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    599  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    600  1.1  christos 	 "R_LARCH_ADD64",			/* name.  */
    601  1.1  christos 	 false,					/* partial_inplace.  */
    602  1.1  christos 	 0,					/* src_mask */
    603  1.1  christos 	 ALL_ONES,				/* dst_mask */
    604  1.1  christos 	 false,					/* pcrel_offset */
    605  1.1  christos 	 BFD_RELOC_LARCH_ADD64,			/* bfd_reloc_code_real_type */
    606  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    607  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    608  1.1  christos 
    609  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SUB8,		/* type (52).  */
    610  1.1  christos 	 0,					/* rightshift.  */
    611  1.1  christos 	 4,					/* size.  */
    612  1.1  christos 	 8,					/* bitsize.  */
    613  1.1  christos 	 false,					/* pc_relative.  */
    614  1.1  christos 	 0,					/* bitpos.  */
    615  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    616  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    617  1.1  christos 	 "R_LARCH_SUB8",			/* name.  */
    618  1.1  christos 	 false,					/* partial_inplace.  */
    619  1.1  christos 	 0,					/* src_mask */
    620  1.1  christos 	 ALL_ONES,				/* dst_mask */
    621  1.1  christos 	 false,					/* pcrel_offset */
    622  1.1  christos 	 BFD_RELOC_LARCH_SUB8,			/* bfd_reloc_code_real_type */
    623  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    624  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    625  1.1  christos 
    626  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SUB16,		/* type (53).  */
    627  1.1  christos 	 0,					/* rightshift.  */
    628  1.1  christos 	 4,					/* size.  */
    629  1.1  christos 	 16,					/* bitsize.  */
    630  1.1  christos 	 false,					/* pc_relative.  */
    631  1.1  christos 	 0,					/* bitpos.  */
    632  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    633  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    634  1.1  christos 	 "R_LARCH_SUB16",			/* name.  */
    635  1.1  christos 	 false,					/* partial_inplace.  */
    636  1.1  christos 	 0,					/* src_mask */
    637  1.1  christos 	 ALL_ONES,				/* dst_mask */
    638  1.1  christos 	 false,					/* pcrel_offset */
    639  1.1  christos 	 BFD_RELOC_LARCH_SUB16,			/* bfd_reloc_code_real_type */
    640  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    641  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    642  1.1  christos 
    643  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SUB24,		/* type (54).  */
    644  1.1  christos 	 0,					/* rightshift.  */
    645  1.1  christos 	 4,					/* size.  */
    646  1.1  christos 	 24,					/* bitsize.  */
    647  1.1  christos 	 false,					/* pc_relative.  */
    648  1.1  christos 	 0,					/* bitpos.  */
    649  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    650  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    651  1.1  christos 	 "R_LARCH_SUB24",			/* name.  */
    652  1.1  christos 	 false,					/* partial_inplace.  */
    653  1.1  christos 	 0,					/* src_mask */
    654  1.1  christos 	 ALL_ONES,				/* dst_mask */
    655  1.1  christos 	 false,					/* pcrel_offset */
    656  1.1  christos 	 BFD_RELOC_LARCH_SUB24,			/* bfd_reloc_code_real_type */
    657  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    658  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    659  1.1  christos 
    660  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SUB32,		/* type (55).  */
    661  1.1  christos 	 0,					/* rightshift.  */
    662  1.1  christos 	 4,					/* size.  */
    663  1.1  christos 	 32,					/* bitsize.  */
    664  1.1  christos 	 false,					/* pc_relative.  */
    665  1.1  christos 	 0,					/* bitpos.  */
    666  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    667  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    668  1.1  christos 	 "R_LARCH_SUB32",			/* name.  */
    669  1.1  christos 	 false,					/* partial_inplace.  */
    670  1.1  christos 	 0,					/* src_mask */
    671  1.1  christos 	 ALL_ONES,				/* dst_mask */
    672  1.1  christos 	 false,					/* pcrel_offset */
    673  1.1  christos 	 BFD_RELOC_LARCH_SUB32,			/* bfd_reloc_code_real_type */
    674  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    675  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    676  1.1  christos 
    677  1.1  christos   LOONGARCH_HOWTO (R_LARCH_SUB64,		/* type (56).  */
    678  1.1  christos 	 0,					/* rightshift.  */
    679  1.1  christos 	 8,					/* size.  */
    680  1.1  christos 	 64,					/* bitsize.  */
    681  1.1  christos 	 false,					/* pc_relative.  */
    682  1.1  christos 	 0,					/* bitpos.  */
    683  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    684  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    685  1.1  christos 	 "R_LARCH_SUB64",			/* name.  */
    686  1.1  christos 	 false,					/* partial_inplace.  */
    687  1.1  christos 	 0,					/* src_mask */
    688  1.1  christos 	 ALL_ONES,				/* dst_mask */
    689  1.1  christos 	 false,					/* pcrel_offset */
    690  1.1  christos 	 BFD_RELOC_LARCH_SUB64,			/* bfd_reloc_code_real_type */
    691  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    692  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    693  1.1  christos 
    694  1.1  christos   LOONGARCH_HOWTO (R_LARCH_GNU_VTINHERIT,	/* type (57).  */
    695  1.1  christos 	 0,					/* rightshift.  */
    696  1.1  christos 	 0,					/* size.  */
    697  1.1  christos 	 0,					/* bitsize.  */
    698  1.1  christos 	 false,					/* pc_relative.  */
    699  1.1  christos 	 0,					/* bitpos.  */
    700  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    701  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    702  1.1  christos 	 "R_LARCH_GNU_VTINHERIT",		/* name.  */
    703  1.1  christos 	 false,					/* partial_inplace.  */
    704  1.1  christos 	 0,					/* src_mask */
    705  1.1  christos 	 0,					/* dst_mask */
    706  1.1  christos 	 false,					/* pcrel_offset */
    707  1.1  christos 	 BFD_RELOC_NONE,			/* bfd_reloc_code_real_type */
    708  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    709  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    710  1.1  christos 
    711  1.1  christos   LOONGARCH_HOWTO (R_LARCH_GNU_VTENTRY,		/* type (58).  */
    712  1.1  christos 	 0,					/* rightshift.  */
    713  1.1  christos 	 0,					/* size.  */
    714  1.1  christos 	 0,					/* bitsize.  */
    715  1.1  christos 	 false,					/* pc_relative.  */
    716  1.1  christos 	 0,					/* bitpos.  */
    717  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    718  1.1  christos 	 NULL,					/* special_function.  */
    719  1.1  christos 	 "R_LARCH_GNU_VTENTRY",			/* name.  */
    720  1.1  christos 	 false,					/* partial_inplace.  */
    721  1.1  christos 	 0,					/* src_mask */
    722  1.1  christos 	 0,					/* dst_mask */
    723  1.1  christos 	 false,					/* pcrel_offset */
    724  1.1  christos 	 BFD_RELOC_NONE,			/* bfd_reloc_code_real_type */
    725  1.1  christos 	 NULL,					/* adjust_reloc_bits */
    726  1.1  christos 	 NULL),					/* larch_reloc_type_name */
    727  1.1  christos 
    728  1.1  christos   LOONGARCH_EMPTY_HOWTO (59),
    729  1.1  christos   LOONGARCH_EMPTY_HOWTO (60),
    730  1.1  christos   LOONGARCH_EMPTY_HOWTO (61),
    731  1.1  christos   LOONGARCH_EMPTY_HOWTO (62),
    732  1.1  christos   LOONGARCH_EMPTY_HOWTO (63),
    733  1.1  christos 
    734  1.1  christos   /* New reloc types.  */
    735  1.1  christos   LOONGARCH_HOWTO (R_LARCH_B16,			/* type (64).  */
    736  1.1  christos 	 2,					/* rightshift.  */
    737  1.1  christos 	 4,					/* size.  */
    738  1.1  christos 	 16,					/* bitsize.  */
    739  1.1  christos 	 false,					/* pc_relative.  */
    740  1.1  christos 	 10,					/* bitpos.  */
    741  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    742  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    743  1.1  christos 	 "R_LARCH_B16",				/* name.  */
    744  1.1  christos 	 false,					/* partial_inplace.  */
    745  1.1  christos 	 0x3fffc00,				/* src_mask */
    746  1.1  christos 	 0x3fffc00,				/* dst_mask */
    747  1.1  christos 	 false,					/* pcrel_offset */
    748  1.1  christos 	 BFD_RELOC_LARCH_B16,			/* bfd_reloc_code_real_type */
    749  1.1  christos 	 reloc_bits_b16,			/* adjust_reloc_bits */
    750  1.1  christos 	 "b16"),				/* larch_reloc_type_name */
    751  1.1  christos 
    752  1.1  christos   LOONGARCH_HOWTO (R_LARCH_B21,			/* type (65).  */
    753  1.1  christos 	 2,					/* rightshift.  */
    754  1.1  christos 	 4,					/* size.  */
    755  1.1  christos 	 21,					/* bitsize.  */
    756  1.1  christos 	 false,					/* pc_relative.  */
    757  1.1  christos 	 0,					/* bitpos.  */
    758  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    759  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    760  1.1  christos 	 "R_LARCH_B21",				/* name.  */
    761  1.1  christos 	 false,					/* partial_inplace.  */
    762  1.1  christos 	 0xfc0003e0,				/* src_mask */
    763  1.1  christos 	 0xfc0003e0,				/* dst_mask */
    764  1.1  christos 	 false,					/* pcrel_offset */
    765  1.1  christos 	 BFD_RELOC_LARCH_B21,			/* bfd_reloc_code_real_type */
    766  1.1  christos 	 reloc_bits_b21,			/* adjust_reloc_bits */
    767  1.1  christos 	 "b21"),				/* larch_reloc_type_name */
    768  1.1  christos 
    769  1.1  christos   LOONGARCH_HOWTO (R_LARCH_B26,			/* type (66).  */
    770  1.1  christos 	 2,					/* rightshift.  */
    771  1.1  christos 	 4,					/* size.  */
    772  1.1  christos 	 26,					/* bitsize.  */
    773  1.1  christos 	 false,					/* pc_relative.  */
    774  1.1  christos 	 0,					/* bitpos.  */
    775  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    776  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    777  1.1  christos 	 "R_LARCH_B26",				/* name.  */
    778  1.1  christos 	 false,					/* partial_inplace.  */
    779  1.1  christos 	 0,					/* src_mask */
    780  1.1  christos 	 0x03ffffff,				/* dst_mask */
    781  1.1  christos 	 false,					/* pcrel_offset */
    782  1.1  christos 	 BFD_RELOC_LARCH_B26,			/* bfd_reloc_code_real_type */
    783  1.1  christos 	 reloc_bits_b26,			/* adjust_reloc_bits */
    784  1.1  christos 	 "b26"),				/* larch_reloc_type_name */
    785  1.1  christos 
    786  1.1  christos   LOONGARCH_HOWTO (R_LARCH_ABS_HI20,		/* type (67).  */
    787  1.1  christos 	 12,					/* rightshift.  */
    788  1.1  christos 	 4,					/* size.  */
    789  1.1  christos 	 20,					/* bitsize.  */
    790  1.1  christos 	 false,					/* pc_relative.  */
    791  1.1  christos 	 5,					/* bitpos.  */
    792  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    793  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    794  1.1  christos 	 "R_LARCH_ABS_HI20",			/* name.  */
    795  1.1  christos 	 false,					/* partial_inplace.  */
    796  1.1  christos 	 0,					/* src_mask */
    797  1.1  christos 	 0x1ffffe0,				/* dst_mask */
    798  1.1  christos 	 false,					/* pcrel_offset */
    799  1.1  christos 	 BFD_RELOC_LARCH_ABS_HI20,		/* bfd_reloc_code_real_type */
    800  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
    801  1.1  christos 	 "abs_hi20"),				/* larch_reloc_type_name */
    802  1.1  christos 
    803  1.1  christos   LOONGARCH_HOWTO (R_LARCH_ABS_LO12,		/* type (68).  */
    804  1.1  christos 	 0,					/* rightshift.  */
    805  1.1  christos 	 4,					/* size.  */
    806  1.1  christos 	 12,					/* bitsize.  */
    807  1.1  christos 	 false,					/* pc_relative.  */
    808  1.1  christos 	 10,					/* bitpos.  */
    809  1.1  christos 	 complain_overflow_unsigned,		/* complain_on_overflow.  */
    810  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    811  1.1  christos 	 "R_LARCH_ABS_LO12",			/* name.  */
    812  1.1  christos 	 false,					/* partial_inplace.  */
    813  1.1  christos 	 0,					/* src_mask */
    814  1.1  christos 	 0x3ffc00,				/* dst_mask */
    815  1.1  christos 	 false,					/* pcrel_offset */
    816  1.1  christos 	 BFD_RELOC_LARCH_ABS_LO12,		/* bfd_reloc_code_real_type */
    817  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
    818  1.1  christos 	 "abs_lo12"),				/* larch_reloc_type_name */
    819  1.1  christos 
    820  1.1  christos   LOONGARCH_HOWTO (R_LARCH_ABS64_LO20,		/* type (69).  */
    821  1.1  christos 	 32,					/* rightshift.  */
    822  1.1  christos 	 4,					/* size.  */
    823  1.1  christos 	 20,					/* bitsize.  */
    824  1.1  christos 	 false,					/* pc_relative.  */
    825  1.1  christos 	 5,					/* bitpos.  */
    826  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    827  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    828  1.1  christos 	 "R_LARCH_ABS64_LO20",			/* name.  */
    829  1.1  christos 	 false,					/* partial_inplace.  */
    830  1.1  christos 	 0,					/* src_mask */
    831  1.1  christos 	 0x1ffffe0,				/* dst_mask */
    832  1.1  christos 	 false,					/* pcrel_offset */
    833  1.1  christos 	 BFD_RELOC_LARCH_ABS64_LO20,		/* bfd_reloc_code_real_type */
    834  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
    835  1.1  christos 	 "abs64_lo20"),				/* larch_reloc_type_name */
    836  1.1  christos 
    837  1.1  christos   LOONGARCH_HOWTO (R_LARCH_ABS64_HI12,		/* type (70).  */
    838  1.1  christos 	 52,					/* rightshift.  */
    839  1.1  christos 	 4,					/* size.  */
    840  1.1  christos 	 12,					/* bitsize.  */
    841  1.1  christos 	 false,					/* pc_relative.  */
    842  1.1  christos 	 10,					/* bitpos.  */
    843  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    844  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    845  1.1  christos 	 "R_LARCH_ABS64_HI12",			/* name.  */
    846  1.1  christos 	 false,					/* partial_inplace.  */
    847  1.1  christos 	 0,					/* src_mask */
    848  1.1  christos 	 0x3ffc00,				/* dst_mask */
    849  1.1  christos 	 false,					/* pcrel_offset */
    850  1.1  christos 	 BFD_RELOC_LARCH_ABS64_HI12,		/* bfd_reloc_code_real_type */
    851  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
    852  1.1  christos 	 "abs64_hi12"),				/* larch_reloc_type_name */
    853  1.1  christos 
    854  1.1  christos   LOONGARCH_HOWTO (R_LARCH_PCALA_HI20,		/* type (71).  */
    855  1.1  christos 	 12,					/* rightshift.  */
    856  1.1  christos 	 4,					/* size.  */
    857  1.1  christos 	 20,					/* bitsize.  */
    858  1.1  christos 	 false,					/* pc_relative.  */
    859  1.1  christos 	 5,					/* bitpos.  */
    860  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    861  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    862  1.1  christos 	 "R_LARCH_PCALA_HI20",			/* name.  */
    863  1.1  christos 	 false,					/* partial_inplace.  */
    864  1.1  christos 	 0,					/* src_mask */
    865  1.1  christos 	 0x1ffffe0,				/* dst_mask */
    866  1.1  christos 	 false,					/* pcrel_offset */
    867  1.1  christos 	 BFD_RELOC_LARCH_PCALA_HI20,		/* bfd_reloc_code_real_type */
    868  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
    869  1.1  christos 	 "pc_hi20"),				/* larch_reloc_type_name */
    870  1.1  christos 
    871  1.1  christos   LOONGARCH_HOWTO (R_LARCH_PCALA_LO12,		/* type (72).  */
    872  1.1  christos 	 0,					/* rightshift.  */
    873  1.1  christos 	 4,					/* size.  */
    874  1.1  christos 	 12,					/* bitsize.  */
    875  1.1  christos 	 false,					/* pc_relative.  */
    876  1.1  christos 	 10,					/* bitpos.  */
    877  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    878  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    879  1.1  christos 	 "R_LARCH_PCALA_LO12",			/* name.  */
    880  1.1  christos 	 false,					/* partial_inplace.  */
    881  1.1  christos 	 0,					/* src_mask */
    882  1.1  christos 	 0x3ffc00,				/* dst_mask */
    883  1.1  christos 	 false,					/* pcrel_offset */
    884  1.1  christos 	 BFD_RELOC_LARCH_PCALA_LO12,		/* bfd_reloc_code_real_type */
    885  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
    886  1.1  christos 	 "pc_lo12"),				/* larch_reloc_type_name */
    887  1.1  christos 
    888  1.1  christos   LOONGARCH_HOWTO (R_LARCH_PCALA64_LO20,	/* type (73).  */
    889  1.1  christos 	 32,					/* rightshift.  */
    890  1.1  christos 	 4,					/* size.  */
    891  1.1  christos 	 20,					/* bitsize.  */
    892  1.1  christos 	 false,					/* pc_relative.  */
    893  1.1  christos 	 5,					/* bitpos.  */
    894  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    895  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    896  1.1  christos 	 "R_LARCH_PCALA64_LO20",		/* name.  */
    897  1.1  christos 	 false,					/* partial_inplace.  */
    898  1.1  christos 	 0,					/* src_mask */
    899  1.1  christos 	 0x1ffffe0,				/* dst_mask */
    900  1.1  christos 	 false,					/* pcrel_offset */
    901  1.1  christos 	 BFD_RELOC_LARCH_PCALA64_LO20,		/* bfd_reloc_code_real_type */
    902  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
    903  1.1  christos 	 "pc64_lo20"),				/* larch_reloc_type_name */
    904  1.1  christos 
    905  1.1  christos   LOONGARCH_HOWTO (R_LARCH_PCALA64_HI12,	/* type (74).  */
    906  1.1  christos 	 52,					/* rightshift.  */
    907  1.1  christos 	 4,					/* size.  */
    908  1.1  christos 	 12,					/* bitsize.  */
    909  1.1  christos 	 false,					/* pc_relative.  */
    910  1.1  christos 	 10,					/* bitpos.  */
    911  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    912  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    913  1.1  christos 	 "R_LARCH_PCALA64_HI12",		/* name.  */
    914  1.1  christos 	 false,					/* partial_inplace.  */
    915  1.1  christos 	 0,					/* src_mask */
    916  1.1  christos 	 0x3ffc00,				/* dst_mask */
    917  1.1  christos 	 false,					/* pcrel_offset */
    918  1.1  christos 	 BFD_RELOC_LARCH_PCALA64_HI12,		/* bfd_reloc_code_real_type */
    919  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
    920  1.1  christos 	 "pc64_hi12"),				/* larch_reloc_type_name */
    921  1.1  christos 
    922  1.1  christos   LOONGARCH_HOWTO (R_LARCH_GOT_PC_HI20,		/* type (75).  */
    923  1.1  christos 	 12,					/* rightshift.  */
    924  1.1  christos 	 4,					/* size.  */
    925  1.1  christos 	 20,					/* bitsize.  */
    926  1.1  christos 	 false,					/* pc_relative.  */
    927  1.1  christos 	 5,					/* bitpos.  */
    928  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    929  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    930  1.1  christos 	 "R_LARCH_GOT_PC_HI20",			/* name.  */
    931  1.1  christos 	 false,					/* partial_inplace.  */
    932  1.1  christos 	 0,					/* src_mask */
    933  1.1  christos 	 0x1ffffe0,				/* dst_mask */
    934  1.1  christos 	 false,					/* pcrel_offset */
    935  1.1  christos 	 BFD_RELOC_LARCH_GOT_PC_HI20,		/* bfd_reloc_code_real_type */
    936  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
    937  1.1  christos 	 "got_pc_hi20"),			/* larch_reloc_type_name */
    938  1.1  christos 
    939  1.1  christos   LOONGARCH_HOWTO (R_LARCH_GOT_PC_LO12,		/* type (76).  */
    940  1.1  christos 	 0,					/* rightshift.  */
    941  1.1  christos 	 4,					/* size.  */
    942  1.1  christos 	 12,					/* bitsize.  */
    943  1.1  christos 	 false,					/* pc_relative.  */
    944  1.1  christos 	 10,					/* bitpos.  */
    945  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    946  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    947  1.1  christos 	 "R_LARCH_GOT_PC_LO12",			/* name.  */
    948  1.1  christos 	 false,					/* partial_inplace.  */
    949  1.1  christos 	 0,					/* src_mask */
    950  1.1  christos 	 0x3ffc00,				/* dst_mask */
    951  1.1  christos 	 false,					/* pcrel_offset */
    952  1.1  christos 	 BFD_RELOC_LARCH_GOT_PC_LO12,		/* bfd_reloc_code_real_type */
    953  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
    954  1.1  christos 	 "got_pc_lo12"),			/* larch_reloc_type_name */
    955  1.1  christos 
    956  1.1  christos   LOONGARCH_HOWTO (R_LARCH_GOT64_PC_LO20,	/* type (77).  */
    957  1.1  christos 	 32,					/* rightshift.  */
    958  1.1  christos 	 4,					/* size.  */
    959  1.1  christos 	 20,					/* bitsize.  */
    960  1.1  christos 	 false,					/* pc_relative.  */
    961  1.1  christos 	 5,					/* bitpos.  */
    962  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    963  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    964  1.1  christos 	 "R_LARCH_GOT64_PC_LO20",		/* name.  */
    965  1.1  christos 	 false,					/* partial_inplace.  */
    966  1.1  christos 	 0,					/* src_mask */
    967  1.1  christos 	 0x1ffffe0,				/* dst_mask */
    968  1.1  christos 	 false,					/* pcrel_offset */
    969  1.1  christos 	 BFD_RELOC_LARCH_GOT64_PC_LO20,		/* bfd_reloc_code_real_type */
    970  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
    971  1.1  christos 	 "got64_pc_lo20"),			/* larch_reloc_type_name */
    972  1.1  christos 
    973  1.1  christos   LOONGARCH_HOWTO (R_LARCH_GOT64_PC_HI12,	/* type (78).  */
    974  1.1  christos 	 52,					/* rightshift.  */
    975  1.1  christos 	 4,					/* size.  */
    976  1.1  christos 	 12,					/* bitsize.  */
    977  1.1  christos 	 false,					/* pc_relative.  */
    978  1.1  christos 	 10,					/* bitpos.  */
    979  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    980  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    981  1.1  christos 	 "R_LARCH_GOT64_PC_HI12",		/* name.  */
    982  1.1  christos 	 false,					/* partial_inplace.  */
    983  1.1  christos 	 0,					/* src_mask */
    984  1.1  christos 	 0x3ffc00,				/* dst_mask */
    985  1.1  christos 	 false,					/* pcrel_offset */
    986  1.1  christos 	 BFD_RELOC_LARCH_GOT64_PC_HI12,		/* bfd_reloc_code_real_type */
    987  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
    988  1.1  christos 	 "got64_pc_hi12"),			/* larch_reloc_type_name */
    989  1.1  christos 
    990  1.1  christos   LOONGARCH_HOWTO (R_LARCH_GOT_HI20,		/* type (79).  */
    991  1.1  christos 	 12,					/* rightshift.  */
    992  1.1  christos 	 4,					/* size.  */
    993  1.1  christos 	 20,					/* bitsize.  */
    994  1.1  christos 	 false,					/* pc_relative.  */
    995  1.1  christos 	 5,					/* bitpos.  */
    996  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
    997  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
    998  1.1  christos 	 "R_LARCH_GOT_HI20",			/* name.  */
    999  1.1  christos 	 false,					/* partial_inplace.  */
   1000  1.1  christos 	 0,					/* src_mask */
   1001  1.1  christos 	 0x1ffffe0,				/* dst_mask */
   1002  1.1  christos 	 false,					/* pcrel_offset */
   1003  1.1  christos 	 BFD_RELOC_LARCH_GOT_HI20,		/* bfd_reloc_code_real_type */
   1004  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1005  1.1  christos 	 "got_hi20"),				/* larch_reloc_type_name */
   1006  1.1  christos 
   1007  1.1  christos   LOONGARCH_HOWTO (R_LARCH_GOT_LO12,		/* type (80).  */
   1008  1.1  christos 	 0,					/* rightshift.  */
   1009  1.1  christos 	 4,					/* size.  */
   1010  1.1  christos 	 12,					/* bitsize.  */
   1011  1.1  christos 	 false,					/* pc_relative.  */
   1012  1.1  christos 	 10,					/* bitpos.  */
   1013  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1014  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1015  1.1  christos 	 "R_LARCH_GOT_LO12",			/* name.  */
   1016  1.1  christos 	 false,					/* partial_inplace.  */
   1017  1.1  christos 	 0,					/* src_mask */
   1018  1.1  christos 	 0x3ffc00,				/* dst_mask */
   1019  1.1  christos 	 false,					/* pcrel_offset */
   1020  1.1  christos 	 BFD_RELOC_LARCH_GOT_LO12,		/* bfd_reloc_code_real_type */
   1021  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1022  1.1  christos 	 "got_lo12"),				/* larch_reloc_type_name */
   1023  1.1  christos 
   1024  1.1  christos   LOONGARCH_HOWTO (R_LARCH_GOT64_LO20,		/* type (81).  */
   1025  1.1  christos 	 32,					/* rightshift.  */
   1026  1.1  christos 	 4,					/* size.  */
   1027  1.1  christos 	 20,					/* bitsize.  */
   1028  1.1  christos 	 false,					/* pc_relative.  */
   1029  1.1  christos 	 5,					/* bitpos.  */
   1030  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1031  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1032  1.1  christos 	 "R_LARCH_GOT64_LO20",			/* name.  */
   1033  1.1  christos 	 false,					/* partial_inplace.  */
   1034  1.1  christos 	 0,					/* src_mask */
   1035  1.1  christos 	 0x1ffffe0,				/* dst_mask */
   1036  1.1  christos 	 false,					/* pcrel_offset */
   1037  1.1  christos 	 BFD_RELOC_LARCH_GOT64_LO20,		/* bfd_reloc_code_real_type */
   1038  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1039  1.1  christos 	 "got64_lo20"),				/* larch_reloc_type_name */
   1040  1.1  christos 
   1041  1.1  christos   LOONGARCH_HOWTO (R_LARCH_GOT64_HI12,		/* type (82).  */
   1042  1.1  christos 	 52,					/* rightshift.  */
   1043  1.1  christos 	 4,					/* size.  */
   1044  1.1  christos 	 12,					/* bitsize.  */
   1045  1.1  christos 	 false,					/* pc_relative.  */
   1046  1.1  christos 	 10,					/* bitpos.  */
   1047  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1048  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1049  1.1  christos 	 "R_LARCH_GOT64_HI12",			/* name.  */
   1050  1.1  christos 	 false,					/* partial_inplace.  */
   1051  1.1  christos 	 0,					/* src_mask */
   1052  1.1  christos 	 0x3ffc00,				/* dst_mask */
   1053  1.1  christos 	 false,					/* pcrel_offset */
   1054  1.1  christos 	 BFD_RELOC_LARCH_GOT64_HI12,		/* bfd_reloc_code_real_type */
   1055  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1056  1.1  christos 	 "got64_hi12"),				/* larch_reloc_type_name */
   1057  1.1  christos 
   1058  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LE_HI20,		/* type (83).  */
   1059  1.1  christos 	 12,					/* rightshift.  */
   1060  1.1  christos 	 4,					/* size.  */
   1061  1.1  christos 	 20,					/* bitsize.  */
   1062  1.1  christos 	 false,					/* pc_relative.  */
   1063  1.1  christos 	 5,					/* bitpos.  */
   1064  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1065  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1066  1.1  christos 	 "R_LARCH_TLS_LE_HI20",			/* name.  */
   1067  1.1  christos 	 false,					/* partial_inplace.  */
   1068  1.1  christos 	 0,					/* src_mask */
   1069  1.1  christos 	 0x1ffffe0,				/* dst_mask */
   1070  1.1  christos 	 false,					/* pcrel_offset */
   1071  1.1  christos 	 BFD_RELOC_LARCH_TLS_LE_HI20,		/* bfd_reloc_code_real_type */
   1072  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1073  1.1  christos 	 "le_hi20"),				/* larch_reloc_type_name */
   1074  1.1  christos 
   1075  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LE_LO12,		/* type (84).  */
   1076  1.1  christos 	 0,					/* rightshift.  */
   1077  1.1  christos 	 4,					/* size.  */
   1078  1.1  christos 	 12,					/* bitsize.  */
   1079  1.1  christos 	 false,					/* pc_relative.  */
   1080  1.1  christos 	 10,					/* bitpos.  */
   1081  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1082  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1083  1.1  christos 	 "R_LARCH_TLS_LE_LO12",			/* name.  */
   1084  1.1  christos 	 false,					/* partial_inplace.  */
   1085  1.1  christos 	 0,					/* src_mask */
   1086  1.1  christos 	 0x3ffc00,				/* dst_mask */
   1087  1.1  christos 	 false,					/* pcrel_offset */
   1088  1.1  christos 	 BFD_RELOC_LARCH_TLS_LE_LO12,		/* bfd_reloc_code_real_type */
   1089  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1090  1.1  christos 	 "le_lo12"),				/* larch_reloc_type_name */
   1091  1.1  christos 
   1092  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LE64_LO20,	/* type (85).  */
   1093  1.1  christos 	 32,					/* rightshift.  */
   1094  1.1  christos 	 4,					/* size.  */
   1095  1.1  christos 	 20,					/* bitsize.  */
   1096  1.1  christos 	 false,					/* pc_relative.  */
   1097  1.1  christos 	 5,					/* bitpos.  */
   1098  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1099  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1100  1.1  christos 	 "R_LARCH_TLS_LE64_LO20",		/* name.  */
   1101  1.1  christos 	 false,					/* partial_inplace.  */
   1102  1.1  christos 	 0,					/* src_mask */
   1103  1.1  christos 	 0x1ffffe0,				/* dst_mask */
   1104  1.1  christos 	 false,					/* pcrel_offset */
   1105  1.1  christos 	 BFD_RELOC_LARCH_TLS_LE64_LO20,		/* bfd_reloc_code_real_type */
   1106  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1107  1.1  christos 	 "le64_lo20"),				/* larch_reloc_type_name */
   1108  1.1  christos 
   1109  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LE64_HI12,	/* type (86).  */
   1110  1.1  christos 	 52,					/* rightshift.  */
   1111  1.1  christos 	 4,					/* size.  */
   1112  1.1  christos 	 12,					/* bitsize.  */
   1113  1.1  christos 	 false,					/* pc_relative.  */
   1114  1.1  christos 	 10,					/* bitpos.  */
   1115  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1116  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1117  1.1  christos 	 "R_LARCH_TLS_LE64_HI12",		/* name.  */
   1118  1.1  christos 	 false,					/* partial_inplace.  */
   1119  1.1  christos 	 0,					/* src_mask */
   1120  1.1  christos 	 0x3ffc00,				/* dst_mask */
   1121  1.1  christos 	 false,					/* pcrel_offset */
   1122  1.1  christos 	 BFD_RELOC_LARCH_TLS_LE64_HI12,		/* bfd_reloc_code_real_type */
   1123  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1124  1.1  christos 	 "le64_hi12"),				/* larch_reloc_type_name */
   1125  1.1  christos 
   1126  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE_PC_HI20,	/* type (87).  */
   1127  1.1  christos 	 12,					/* rightshift.  */
   1128  1.1  christos 	 4,					/* size.  */
   1129  1.1  christos 	 20,					/* bitsize.  */
   1130  1.1  christos 	 false,					/* pc_relative.  */
   1131  1.1  christos 	 5,					/* bitpos.  */
   1132  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1133  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1134  1.1  christos 	 "R_LARCH_TLS_IE_PC_HI20",		/* name.  */
   1135  1.1  christos 	 false,					/* partial_inplace.  */
   1136  1.1  christos 	 0,					/* src_mask */
   1137  1.1  christos 	 0x1ffffe0,				/* dst_mask */
   1138  1.1  christos 	 false,					/* pcrel_offset */
   1139  1.1  christos 	 BFD_RELOC_LARCH_TLS_IE_PC_HI20,	/* bfd_reloc_code_real_type */
   1140  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1141  1.1  christos 	 "ie_pc_hi20"),				/* larch_reloc_type_name */
   1142  1.1  christos 
   1143  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE_PC_LO12,	/* type (88).  */
   1144  1.1  christos 	 0,					/* rightshift.  */
   1145  1.1  christos 	 4,					/* size.  */
   1146  1.1  christos 	 12,					/* bitsize.  */
   1147  1.1  christos 	 false,					/* pc_relative.  */
   1148  1.1  christos 	 10,					/* bitpos.  */
   1149  1.1  christos 	 complain_overflow_unsigned,		/* complain_on_overflow.  */
   1150  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1151  1.1  christos 	 "R_LARCH_TLS_IE_PC_LO12",		/* name.  */
   1152  1.1  christos 	 false,					/* partial_inplace.  */
   1153  1.1  christos 	 0,					/* src_mask */
   1154  1.1  christos 	 0x3ffc00,				/* dst_mask */
   1155  1.1  christos 	 false,					/* pcrel_offset */
   1156  1.1  christos 	 BFD_RELOC_LARCH_TLS_IE_PC_LO12,	/* bfd_reloc_code_real_type */
   1157  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1158  1.1  christos 	 "ie_pc_lo12"),				/* larch_reloc_type_name */
   1159  1.1  christos 
   1160  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE64_PC_LO20,	/* type (89).  */
   1161  1.1  christos 	 32,					/* rightshift.  */
   1162  1.1  christos 	 4,					/* size.  */
   1163  1.1  christos 	 20,					/* bitsize.  */
   1164  1.1  christos 	 false,					/* pc_relative.  */
   1165  1.1  christos 	 5,					/* bitpos.  */
   1166  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1167  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1168  1.1  christos 	 "R_LARCH_TLS_IE64_PC_LO20",		/* name.  */
   1169  1.1  christos 	 false,					/* partial_inplace.  */
   1170  1.1  christos 	 0,					/* src_mask */
   1171  1.1  christos 	 0x1ffffe0,				/* dst_mask */
   1172  1.1  christos 	 false,					/* pcrel_offset */
   1173  1.1  christos 	 BFD_RELOC_LARCH_TLS_IE64_PC_LO20,	/* bfd_reloc_code_real_type */
   1174  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1175  1.1  christos 	 "ie64_pc_lo20"),			/* larch_reloc_type_name */
   1176  1.1  christos 
   1177  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE64_PC_HI12,	/* type (90).  */
   1178  1.1  christos 	 52,					/* rightshift.  */
   1179  1.1  christos 	 4,					/* size.  */
   1180  1.1  christos 	 12,					/* bitsize.  */
   1181  1.1  christos 	 false,					/* pc_relative.  */
   1182  1.1  christos 	 10,					/* bitpos.  */
   1183  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1184  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1185  1.1  christos 	 "R_LARCH_TLS_IE64_PC_HI12",		/* name.  */
   1186  1.1  christos 	 false,					/* partial_inplace.  */
   1187  1.1  christos 	 0,					/* src_mask */
   1188  1.1  christos 	 0x3ffc00,				/* dst_mask */
   1189  1.1  christos 	 false,					/* pcrel_offset */
   1190  1.1  christos 	 BFD_RELOC_LARCH_TLS_IE64_PC_HI12,	/* bfd_reloc_code_real_type */
   1191  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1192  1.1  christos 	 "ie64_pc_hi12"),			/* larch_reloc_type_name */
   1193  1.1  christos 
   1194  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE_HI20,	/* type (91).  */
   1195  1.1  christos 	 12,					/* rightshift.  */
   1196  1.1  christos 	 4,					/* size.  */
   1197  1.1  christos 	 20,					/* bitsize.  */
   1198  1.1  christos 	 false,					/* pc_relative.  */
   1199  1.1  christos 	 5,					/* bitpos.  */
   1200  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1201  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1202  1.1  christos 	 "R_LARCH_TLS_IE_HI20",			/* name.  */
   1203  1.1  christos 	 false,					/* partial_inplace.  */
   1204  1.1  christos 	 0,					/* src_mask */
   1205  1.1  christos 	 0x1ffffe0,				/* dst_mask */
   1206  1.1  christos 	 false,					/* pcrel_offset */
   1207  1.1  christos 	 BFD_RELOC_LARCH_TLS_IE_HI20,		/* bfd_reloc_code_real_type */
   1208  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1209  1.1  christos 	 "ie_hi20"),				/* larch_reloc_type_name */
   1210  1.1  christos 
   1211  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE_LO12,		/* type (92).  */
   1212  1.1  christos 	 0,					/* rightshift.  */
   1213  1.1  christos 	 4,					/* size.  */
   1214  1.1  christos 	 12,					/* bitsize.  */
   1215  1.1  christos 	 false,					/* pc_relative.  */
   1216  1.1  christos 	 10,					/* bitpos.  */
   1217  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1218  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1219  1.1  christos 	 "R_LARCH_TLS_IE_LO12",			/* name.  */
   1220  1.1  christos 	 false,					/* partial_inplace.  */
   1221  1.1  christos 	 0,					/* src_mask */
   1222  1.1  christos 	 0x3ffc00,				/* dst_mask */
   1223  1.1  christos 	 false,					/* pcrel_offset */
   1224  1.1  christos 	 BFD_RELOC_LARCH_TLS_IE_LO12,		/* bfd_reloc_code_real_type */
   1225  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1226  1.1  christos 	 "ie_lo12"),				/* larch_reloc_type_name */
   1227  1.1  christos 
   1228  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE64_LO20,	/* type (93).  */
   1229  1.1  christos 	 32,					/* rightshift.  */
   1230  1.1  christos 	 4,					/* size.  */
   1231  1.1  christos 	 20,					/* bitsize.  */
   1232  1.1  christos 	 false,					/* pc_relative.  */
   1233  1.1  christos 	 5,					/* bitpos.  */
   1234  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1235  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1236  1.1  christos 	 "R_LARCH_TLS_IE64_LO20",		/* name.  */
   1237  1.1  christos 	 false,					/* partial_inplace.  */
   1238  1.1  christos 	 0,					/* src_mask */
   1239  1.1  christos 	 0x1ffffe0,				/* dst_mask */
   1240  1.1  christos 	 false,					/* pcrel_offset */
   1241  1.1  christos 	 BFD_RELOC_LARCH_TLS_IE64_LO20,		/* bfd_reloc_code_real_type */
   1242  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1243  1.1  christos 	 "ie64_lo20"),				/* larch_reloc_type_name */
   1244  1.1  christos 
   1245  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_IE64_HI12,	/* type (94).  */
   1246  1.1  christos 	 52,					/* rightshift.  */
   1247  1.1  christos 	 4,					/* size.  */
   1248  1.1  christos 	 12,					/* bitsize.  */
   1249  1.1  christos 	 false,					/* pc_relative.  */
   1250  1.1  christos 	 10,					/* bitpos.  */
   1251  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1252  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1253  1.1  christos 	 "R_LARCH_TLS_IE64_HI12",		/* name.  */
   1254  1.1  christos 	 false,					/* partial_inplace.  */
   1255  1.1  christos 	 0,					/* src_mask */
   1256  1.1  christos 	 0x3ffc00,				/* dst_mask */
   1257  1.1  christos 	 false,					/* pcrel_offset */
   1258  1.1  christos 	 BFD_RELOC_LARCH_TLS_IE64_HI12,		/* bfd_reloc_code_real_type */
   1259  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1260  1.1  christos 	 "ie64_hi12"),				/* larch_reloc_type_name */
   1261  1.1  christos 
   1262  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LD_PC_HI20,	/* type (95).  */
   1263  1.1  christos 	 12,					/* rightshift.  */
   1264  1.1  christos 	 4,					/* size.  */
   1265  1.1  christos 	 20,					/* bitsize.  */
   1266  1.1  christos 	 false,					/* pc_relative.  */
   1267  1.1  christos 	 5,					/* bitpos.  */
   1268  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1269  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1270  1.1  christos 	 "R_LARCH_TLS_LD_PC_HI20",		/* name.  */
   1271  1.1  christos 	 false,					/* partial_inplace.  */
   1272  1.1  christos 	 0,					/* src_mask */
   1273  1.1  christos 	 0x1ffffe0,				/* dst_mask */
   1274  1.1  christos 	 false,					/* pcrel_offset */
   1275  1.1  christos 	 BFD_RELOC_LARCH_TLS_LD_PC_HI20,	/* bfd_reloc_code_real_type */
   1276  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1277  1.1  christos 	 "ld_pc_hi20"),				/* larch_reloc_type_name */
   1278  1.1  christos 
   1279  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_LD_HI20,		/* type (96).  */
   1280  1.1  christos 	 12,					/* rightshift.  */
   1281  1.1  christos 	 4,					/* size.  */
   1282  1.1  christos 	 20,					/* bitsize.  */
   1283  1.1  christos 	 false,					/* pc_relative.  */
   1284  1.1  christos 	 5,					/* bitpos.  */
   1285  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1286  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1287  1.1  christos 	 "R_LARCH_TLS_LD_HI20",			/* name.  */
   1288  1.1  christos 	 false,					/* partial_inplace.  */
   1289  1.1  christos 	 0,					/* src_mask */
   1290  1.1  christos 	 0x1ffffe0,				/* dst_mask */
   1291  1.1  christos 	 false,					/* pcrel_offset */
   1292  1.1  christos 	 BFD_RELOC_LARCH_TLS_LD_HI20,		/* bfd_reloc_code_real_type */
   1293  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1294  1.1  christos 	 "ld_hi20"),				/* larch_reloc_type_name */
   1295  1.1  christos 
   1296  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_GD_PC_HI20,	/* type (97).  */
   1297  1.1  christos 	 12,					/* rightshift.  */
   1298  1.1  christos 	 4,					/* size.  */
   1299  1.1  christos 	 20,					/* bitsize.  */
   1300  1.1  christos 	 false,					/* pc_relative.  */
   1301  1.1  christos 	 5,					/* bitpos.  */
   1302  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1303  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1304  1.1  christos 	 "R_LARCH_TLS_GD_PC_HI20",		/* name.  */
   1305  1.1  christos 	 false,					/* partial_inplace.  */
   1306  1.1  christos 	 0,					/* src_mask */
   1307  1.1  christos 	 0x1ffffe0,				/* dst_mask */
   1308  1.1  christos 	 false,					/* pcrel_offset */
   1309  1.1  christos 	 BFD_RELOC_LARCH_TLS_GD_PC_HI20,	/* bfd_reloc_code_real_type */
   1310  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1311  1.1  christos 	 "gd_pc_hi20"),				/* larch_reloc_type_name */
   1312  1.1  christos 
   1313  1.1  christos   LOONGARCH_HOWTO (R_LARCH_TLS_GD_HI20,		/* type (98).  */
   1314  1.1  christos 	 12,					/* rightshift.  */
   1315  1.1  christos 	 4,					/* size.  */
   1316  1.1  christos 	 20,					/* bitsize.  */
   1317  1.1  christos 	 false,					/* pc_relative.  */
   1318  1.1  christos 	 5,					/* bitpos.  */
   1319  1.1  christos 	 complain_overflow_signed,		/* complain_on_overflow.  */
   1320  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1321  1.1  christos 	 "R_LARCH_TLS_GD_HI20",			/* name.  */
   1322  1.1  christos 	 false,					/* partial_inplace.  */
   1323  1.1  christos 	 0,					/* src_mask */
   1324  1.1  christos 	 0x1ffffe0,				/* dst_mask */
   1325  1.1  christos 	 false,					/* pcrel_offset */
   1326  1.1  christos 	 BFD_RELOC_LARCH_TLS_GD_HI20,		/* bfd_reloc_code_real_type */
   1327  1.1  christos 	 reloc_bits,				/* adjust_reloc_bits */
   1328  1.1  christos 	 "gd_hi20"),				/* larch_reloc_type_name */
   1329  1.1  christos 
   1330  1.1  christos   LOONGARCH_HOWTO (R_LARCH_32_PCREL,		/* type (99).  */
   1331  1.1  christos 	 0,					/* rightshift.  */
   1332  1.1  christos 	 4,					/* size.  */
   1333  1.1  christos 	 32,					/* bitsize.  */
   1334  1.1  christos 	 true,					/* pc_relative.  */
   1335  1.1  christos 	 0,					/* bitpos.  */
   1336  1.1  christos 	 complain_overflow_dont,		/* complain_on_overflow.  */
   1337  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function.  */
   1338  1.1  christos 	 "R_LARCH_32_PCREL",			/* name.  */
   1339  1.1  christos 	 false,					/* partial_inplace.  */
   1340  1.1  christos 	 0,					/* src_mask */
   1341  1.1  christos 	 0xffffffff,				/* dst_mask */
   1342  1.1  christos 	 false,					/* pcrel_offset */
   1343  1.1  christos 	 BFD_RELOC_LARCH_32_PCREL,		/* bfd_reloc_code_real_type */
   1344  1.1  christos 	 NULL,					/* adjust_reloc_bits */
   1345  1.1  christos 	 NULL),					/* larch_reloc_type_name */
   1346  1.1  christos 
   1347  1.1  christos   LOONGARCH_HOWTO (R_LARCH_RELAX,		/* type (100).  */
   1348  1.1  christos 	 0,					/* rightshift */
   1349  1.1  christos 	 1,					/* size */
   1350  1.1  christos 	 0,					/* bitsize */
   1351  1.1  christos 	 false,					/* pc_relative */
   1352  1.1  christos 	 0,					/* bitpos */
   1353  1.1  christos 	 complain_overflow_dont,		/* complain_on_overflow */
   1354  1.1  christos 	 bfd_elf_generic_reloc,			/* special_function */
   1355  1.1  christos 	 "R_LARCH_RELAX",			/* name */
   1356  1.1  christos 	 false,					/* partial_inplace */
   1357  1.1  christos 	 0,					/* src_mask */
   1358  1.1  christos 	 0,					/* dst_mask */
   1359  1.1  christos 	 false,					/* pcrel_offset */
   1360  1.1  christos 	 BFD_RELOC_LARCH_RELAX,			/* bfd_reloc_code_real_type */
   1361  1.1  christos 	 NULL,					/* adjust_reloc_bits */
   1362  1.1  christos 	 NULL),					/* larch_reloc_type_name */
   1363  1.1  christos 
   1364  1.1  christos };
   1365  1.1  christos 
   1366  1.1  christos reloc_howto_type *
   1367  1.1  christos loongarch_elf_rtype_to_howto (bfd *abfd, unsigned int r_type)
   1368  1.1  christos {
   1369  1.1  christos   if(r_type < R_LARCH_count)
   1370  1.1  christos     {
   1371  1.1  christos       /* For search table fast.  */
   1372  1.1  christos       BFD_ASSERT (ARRAY_SIZE (loongarch_howto_table) == R_LARCH_count);
   1373  1.1  christos 
   1374  1.1  christos       if (loongarch_howto_table[r_type].howto.type == r_type)
   1375  1.1  christos 	return (reloc_howto_type *)&loongarch_howto_table[r_type];
   1376  1.1  christos 
   1377  1.1  christos       for (size_t i = 0; i < ARRAY_SIZE (loongarch_howto_table); i++)
   1378  1.1  christos 	if (loongarch_howto_table[i].howto.type == r_type)
   1379  1.1  christos 	  return (reloc_howto_type *)&loongarch_howto_table[i];
   1380  1.1  christos     }
   1381  1.1  christos 
   1382  1.1  christos   (*_bfd_error_handler) (_("%pB: unsupported relocation type %#x"),
   1383  1.1  christos 			 abfd, r_type);
   1384  1.1  christos   bfd_set_error (bfd_error_bad_value);
   1385  1.1  christos   return NULL;
   1386  1.1  christos }
   1387  1.1  christos 
   1388  1.1  christos reloc_howto_type *
   1389  1.1  christos loongarch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
   1390  1.1  christos {
   1391  1.1  christos   BFD_ASSERT (ARRAY_SIZE (loongarch_howto_table) == R_LARCH_count);
   1392  1.1  christos 
   1393  1.1  christos   for (size_t i = 0; i < ARRAY_SIZE (loongarch_howto_table); i++)
   1394  1.1  christos     if (loongarch_howto_table[i].howto.name
   1395  1.1  christos 	&& strcasecmp (loongarch_howto_table[i].howto.name, r_name) == 0)
   1396  1.1  christos       return (reloc_howto_type *)&loongarch_howto_table[i];
   1397  1.1  christos 
   1398  1.1  christos   (*_bfd_error_handler) (_("%pB: unsupported relocation type %s"),
   1399  1.1  christos 			 abfd, r_name);
   1400  1.1  christos   bfd_set_error (bfd_error_bad_value);
   1401  1.1  christos 
   1402  1.1  christos   return NULL;
   1403  1.1  christos }
   1404  1.1  christos 
   1405  1.1  christos /* Cost so much.  */
   1406  1.1  christos reloc_howto_type *
   1407  1.1  christos loongarch_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   1408  1.1  christos 			     bfd_reloc_code_real_type code)
   1409  1.1  christos {
   1410  1.1  christos   BFD_ASSERT (ARRAY_SIZE (loongarch_howto_table) == R_LARCH_count);
   1411  1.1  christos 
   1412  1.1  christos   /* Fast search for new reloc types.  */
   1413  1.1  christos   if (BFD_RELOC_LARCH_B16 <= code && code < BFD_RELOC_LARCH_RELAX)
   1414  1.1  christos     {
   1415  1.1  christos       BFD_ASSERT (BFD_RELOC_LARCH_RELAX - BFD_RELOC_LARCH_B16
   1416  1.1  christos 		  == R_LARCH_RELAX - R_LARCH_B16);
   1417  1.1  christos       loongarch_reloc_howto_type *ht = NULL;
   1418  1.1  christos       ht = &loongarch_howto_table[code - BFD_RELOC_LARCH_B16 + R_LARCH_B16];
   1419  1.1  christos       BFD_ASSERT (ht->bfd_type == code);
   1420  1.1  christos       return (reloc_howto_type *)ht;
   1421  1.1  christos     }
   1422  1.1  christos 
   1423  1.1  christos   for (size_t i = 0; i < ARRAY_SIZE (loongarch_howto_table); i++)
   1424  1.1  christos     if (loongarch_howto_table[i].bfd_type == code)
   1425  1.1  christos       return (reloc_howto_type *)&loongarch_howto_table[i];
   1426  1.1  christos 
   1427  1.1  christos   (*_bfd_error_handler) (_("%pB: unsupported bfd relocation type %#x"),
   1428  1.1  christos 			 abfd, code);
   1429  1.1  christos   bfd_set_error (bfd_error_bad_value);
   1430  1.1  christos 
   1431  1.1  christos   return NULL;
   1432  1.1  christos }
   1433  1.1  christos 
   1434  1.1  christos bfd_reloc_code_real_type
   1435  1.1  christos loongarch_larch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   1436  1.1  christos 				   const char *l_r_name)
   1437  1.1  christos {
   1438  1.1  christos   for (size_t i = 0; i < ARRAY_SIZE (loongarch_howto_table); i++)
   1439  1.1  christos     {
   1440  1.1  christos       loongarch_reloc_howto_type *lht = &loongarch_howto_table[i];
   1441  1.1  christos       if ((NULL != lht->larch_reloc_type_name)
   1442  1.1  christos 	  && (0 == strcmp (lht->larch_reloc_type_name, l_r_name)))
   1443  1.1  christos 	return lht->bfd_type;
   1444  1.1  christos     }
   1445  1.1  christos 
   1446  1.1  christos   (*_bfd_error_handler) (_("%pB: unsupported relocation type name %s"),
   1447  1.1  christos 			 abfd, l_r_name);
   1448  1.1  christos   bfd_set_error (bfd_error_bad_value);
   1449  1.1  christos   return BFD_RELOC_NONE;
   1450  1.1  christos }
   1451  1.1  christos 
   1452  1.1  christos 
   1453  1.1  christos /* Functions for reloc bits field.
   1454  1.1  christos    1.  Signed extend *fix_val.
   1455  1.1  christos    2.  Return false if overflow.  */
   1456  1.1  christos 
   1457  1.1  christos #define LARCH_RELOC_BFD_VMA_BIT_MASK(bitsize) \
   1458  1.1  christos   (~((((bfd_vma)0x1) << (bitsize)) - 1))
   1459  1.1  christos 
   1460  1.1  christos /* Adjust val to perform insn
   1461  1.1  christos    BFD_RELOC_LARCH_SOP_POP_32_S_10_5
   1462  1.1  christos    BFD_RELOC_LARCH_SOP_POP_32_S_10_12
   1463  1.1  christos    BFD_RELOC_LARCH_SOP_POP_32_U_10_12
   1464  1.1  christos    BFD_RELOC_LARCH_SOP_POP_32_S_10_16
   1465  1.1  christos    BFD_RELOC_LARCH_SOP_POP_32_S_5_20
   1466  1.1  christos    BFD_RELOC_LARCH_SOP_POP_32_U.  */
   1467  1.1  christos static bool
   1468  1.1  christos reloc_bits (reloc_howto_type *howto, bfd_vma *fix_val)
   1469  1.1  christos {
   1470  1.1  christos   bfd_signed_vma val = ((bfd_signed_vma)(*fix_val)) >> howto->rightshift;
   1471  1.1  christos 
   1472  1.1  christos   /* Perform insn bits field.  */
   1473  1.1  christos   val = val & (((bfd_vma)0x1 << howto->bitsize) - 1);
   1474  1.1  christos   val <<= howto->bitpos;
   1475  1.1  christos 
   1476  1.1  christos   *fix_val = (bfd_vma)val;
   1477  1.1  christos 
   1478  1.1  christos   return true;
   1479  1.1  christos }
   1480  1.1  christos 
   1481  1.1  christos /* Adjust val to perform insn
   1482  1.1  christos    R_LARCH_SOP_POP_32_S_10_16_S2
   1483  1.1  christos    R_LARCH_B16.  */
   1484  1.1  christos static bool
   1485  1.1  christos reloc_bits_b16 (reloc_howto_type *howto, bfd_vma *fix_val)
   1486  1.1  christos {
   1487  1.1  christos   if (howto->complain_on_overflow != complain_overflow_signed)
   1488  1.1  christos     return false;
   1489  1.1  christos 
   1490  1.1  christos   bfd_signed_vma val = *fix_val;
   1491  1.1  christos 
   1492  1.1  christos   /* Judge whether 4 bytes align.  */
   1493  1.1  christos   if (val & ((0x1UL << howto->rightshift) - 1))
   1494  1.1  christos     return false;
   1495  1.1  christos 
   1496  1.1  christos   int bitsize = howto->bitsize + howto->rightshift;
   1497  1.1  christos   bfd_signed_vma sig_bit = (val >> (bitsize - 1)) & 0x1;
   1498  1.1  christos 
   1499  1.1  christos   /* If val < 0, sign bit is 1.  */
   1500  1.1  christos   if (sig_bit)
   1501  1.1  christos     {
   1502  1.1  christos       /* Signed bits is 1.  */
   1503  1.1  christos       if ((LARCH_RELOC_BFD_VMA_BIT_MASK (bitsize - 1) & val)
   1504  1.1  christos 	  != LARCH_RELOC_BFD_VMA_BIT_MASK (bitsize - 1))
   1505  1.1  christos 	return false;
   1506  1.1  christos     }
   1507  1.1  christos   else
   1508  1.1  christos     {
   1509  1.1  christos       /* Signed bits is 0.  */
   1510  1.1  christos       if (LARCH_RELOC_BFD_VMA_BIT_MASK (bitsize) & val)
   1511  1.1  christos 	return false;
   1512  1.1  christos     }
   1513  1.1  christos 
   1514  1.1  christos   /* Perform insn bits field.  */
   1515  1.1  christos   val >>= howto->rightshift;
   1516  1.1  christos   val = val & (((bfd_vma)0x1 << howto->bitsize) - 1);
   1517  1.1  christos   val <<= howto->bitpos;
   1518  1.1  christos 
   1519  1.1  christos   *fix_val = val;
   1520  1.1  christos 
   1521  1.1  christos   return true;
   1522  1.1  christos }
   1523  1.1  christos 
   1524  1.1  christos /* Reloc type :
   1525  1.1  christos    R_LARCH_SOP_POP_32_S_0_5_10_16_S2
   1526  1.1  christos    R_LARCH_B21.  */
   1527  1.1  christos static bool
   1528  1.1  christos reloc_bits_b21 (reloc_howto_type *howto,
   1529  1.1  christos 		bfd_vma *fix_val)
   1530  1.1  christos {
   1531  1.1  christos   if (howto->complain_on_overflow != complain_overflow_signed)
   1532  1.1  christos     return false;
   1533  1.1  christos 
   1534  1.1  christos   bfd_signed_vma val = *fix_val;
   1535  1.1  christos 
   1536  1.1  christos   if (val & ((0x1UL << howto->rightshift) - 1))
   1537  1.1  christos     return false;
   1538  1.1  christos 
   1539  1.1  christos   int bitsize = howto->bitsize + howto->rightshift;
   1540  1.1  christos   bfd_signed_vma sig_bit = (val >> (bitsize - 1)) & 0x1;
   1541  1.1  christos 
   1542  1.1  christos   /* If val < 0.  */
   1543  1.1  christos   if (sig_bit)
   1544  1.1  christos     {
   1545  1.1  christos       if ((LARCH_RELOC_BFD_VMA_BIT_MASK (bitsize - 1) & val)
   1546  1.1  christos 	  != LARCH_RELOC_BFD_VMA_BIT_MASK (bitsize - 1))
   1547  1.1  christos 	return false;
   1548  1.1  christos     }
   1549  1.1  christos   else
   1550  1.1  christos     {
   1551  1.1  christos       if (LARCH_RELOC_BFD_VMA_BIT_MASK (bitsize) & val)
   1552  1.1  christos 	return false;
   1553  1.1  christos     }
   1554  1.1  christos 
   1555  1.1  christos   /* Perform insn bits field.  */
   1556  1.1  christos   val >>= howto->rightshift;
   1557  1.1  christos   val = val & (((bfd_vma)0x1 << howto->bitsize) - 1);
   1558  1.1  christos 
   1559  1.1  christos   /* Perform insn bits field.  15:0<<10, 20:16>>16.  */
   1560  1.1  christos   val = ((val & 0xffff) << 10) | ((val >> 16) & 0x1f);
   1561  1.1  christos 
   1562  1.1  christos   *fix_val = val;
   1563  1.1  christos 
   1564  1.1  christos   return true;
   1565  1.1  christos }
   1566  1.1  christos 
   1567  1.1  christos /* Reloc type:
   1568  1.1  christos    R_LARCH_SOP_POP_32_S_0_10_10_16_S2
   1569  1.1  christos    R_LARCH_B26.  */
   1570  1.1  christos static bool
   1571  1.1  christos reloc_bits_b26 (reloc_howto_type *howto,
   1572  1.1  christos 		bfd_vma *fix_val)
   1573  1.1  christos {
   1574  1.1  christos   /* Return false if overflow.  */
   1575  1.1  christos   if (howto->complain_on_overflow != complain_overflow_signed)
   1576  1.1  christos     return false;
   1577  1.1  christos 
   1578  1.1  christos   bfd_signed_vma val = *fix_val;
   1579  1.1  christos 
   1580  1.1  christos   if (val & ((0x1UL << howto->rightshift) - 1))
   1581  1.1  christos     return false;
   1582  1.1  christos 
   1583  1.1  christos   int bitsize = howto->bitsize + howto->rightshift;
   1584  1.1  christos   bfd_signed_vma sig_bit = (val >> (bitsize - 1)) & 0x1;
   1585  1.1  christos 
   1586  1.1  christos   /* If val < 0.  */
   1587  1.1  christos   if (sig_bit)
   1588  1.1  christos     {
   1589  1.1  christos       if ((LARCH_RELOC_BFD_VMA_BIT_MASK (bitsize - 1) & val)
   1590  1.1  christos 	  != LARCH_RELOC_BFD_VMA_BIT_MASK (bitsize - 1))
   1591  1.1  christos 	return false;
   1592  1.1  christos     }
   1593  1.1  christos   else
   1594  1.1  christos     {
   1595  1.1  christos       if (LARCH_RELOC_BFD_VMA_BIT_MASK (bitsize) & val)
   1596  1.1  christos 	return false;
   1597  1.1  christos     }
   1598  1.1  christos 
   1599  1.1  christos   /* Perform insn bits field.  */
   1600  1.1  christos   val >>= howto->rightshift;
   1601  1.1  christos   val = val & (((bfd_vma)0x1 << howto->bitsize) - 1);
   1602  1.1  christos 
   1603  1.1  christos   /* Perform insn bits field.  25:16>>16, 15:0<<10.  */
   1604  1.1  christos   val = ((val & 0xffff) << 10) | ((val >> 16) & 0x3ff);
   1605  1.1  christos 
   1606  1.1  christos   *fix_val = val;
   1607  1.1  christos 
   1608  1.1  christos   return true;
   1609  1.1  christos }
   1610  1.1  christos 
   1611  1.1  christos bool
   1612  1.1  christos loongarch_adjust_reloc_bitsfield (reloc_howto_type *howto,
   1613  1.1  christos 				  bfd_vma *fix_val)
   1614  1.1  christos {
   1615  1.1  christos   BFD_ASSERT (((loongarch_reloc_howto_type *)howto)->adjust_reloc_bits);
   1616  1.1  christos   return ((loongarch_reloc_howto_type *)
   1617  1.1  christos 	  howto)->adjust_reloc_bits(howto, fix_val);
   1618  1.1  christos }
   1619