[binutils-gdb] LoongArch: Add linker relaxation support for R_LARCH_CALL30
liu zhensong
liuzhensong@sourceware.org
Wed Dec 10 08:08:30 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=da99165f7140e24be472ca92c34183e72e1090e5
commit da99165f7140e24be472ca92c34183e72e1090e5
Author: mengqinggang <mengqinggang@loongson.cn>
Date: Tue Sep 9 15:39:38 2025 +0800
LoongArch: Add linker relaxation support for R_LARCH_CALL30
Relax call30 to bl, relax tail30 to b.
Diff:
---
bfd/elfnn-loongarch.c | 7 ++++---
gas/config/tc-loongarch.c | 3 ++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 5e5eb237abd..62696b83397 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -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;
diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index a3e6fcb056c..284bbdcc12a 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -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;
More information about the Binutils-cvs
mailing list