]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
LoongArch: Add linker relaxation support for R_LARCH_CALL30
authormengqinggang <mengqinggang@loongson.cn>
Tue, 9 Sep 2025 07:39:38 +0000 (15:39 +0800)
committermengqinggang <mengqinggang@loongson.cn>
Wed, 10 Dec 2025 08:06:47 +0000 (16:06 +0800)
Relax call30 to bl, relax tail30 to b.

bfd/elfnn-loongarch.c
gas/config/tc-loongarch.c

index 5e5eb237abdb049838a7bc3fa782953e3b8a2950..62696b83397a589a147237a4cf7ac72a2493e024 100644 (file)
@@ -6100,6 +6100,7 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec,
              relax_func = loongarch_relax_pcala_ld;
              break;
            case R_LARCH_CALL36:
+           case R_LARCH_CALL30:
              relax_func = loongarch_relax_call36;
              break;
            case R_LARCH_TLS_LE_HI20_R:
@@ -6158,7 +6159,7 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec,
                                    + r_symndx;
 
          if ((ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
-              && r_type != R_LARCH_CALL36)
+              && (r_type != R_LARCH_CALL36 || r_type != R_LARCH_CALL30))
              || sym->st_shndx == SHN_ABS)
            continue;
 
@@ -6195,7 +6196,7 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec,
             is not set yet.  */
          if (h != NULL
              && ((h->type == STT_GNU_IFUNC
-                  && r_type != R_LARCH_CALL36)
+                  && (r_type != R_LARCH_CALL36 || r_type != R_LARCH_CALL30))
                  || bfd_is_abs_section (h->root.u.def.section)
                  || h->start_stop))
            continue;
@@ -6223,7 +6224,7 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec,
             Undefweak for other relocations handing in the future.  */
          else if (h->root.type == bfd_link_hash_undefweak
                    && !h->root.linker_def
-                   && r_type == R_LARCH_CALL36)
+                   && (r_type == R_LARCH_CALL36 || r_type == R_LARCH_CALL30))
            {
              sym_sec = sec;
              symval = rel->r_offset;
index a3e6fcb056cf2087801c598e7e2ed208a707f788..284bbdcc12a6cd17dc4606cbac457dfbcc3368ea 100644 (file)
@@ -880,7 +880,8 @@ loongarch_args_parser_can_match_arg_helper (char esc_ch1, char esc_ch2,
                        || BFD_RELOC_LARCH_TLS_LE_LO12 == reloc_type
                        || BFD_RELOC_LARCH_TLS_LE64_LO20 == reloc_type
                        || BFD_RELOC_LARCH_TLS_LE64_HI12 == reloc_type
-                       || BFD_RELOC_LARCH_CALL36 == reloc_type))
+                       || BFD_RELOC_LARCH_CALL36 == reloc_type
+                       || BFD_RELOC_LARCH_CALL30 == reloc_type))
                {
                  ip->reloc_info[ip->reloc_num].type = BFD_RELOC_LARCH_RELAX;
                  ip->reloc_info[ip->reloc_num].value = const_0;