LoongArch: opcodes: Add support for linker relaxation.
authormengqinggang <mengqinggang@loongson.cn>
Thu, 1 Dec 2022 08:01:27 +0000 (16:01 +0800)
committerliuzhensong <liuzhensong@loongson.cn>
Tue, 30 May 2023 11:56:43 +0000 (19:56 +0800)
Set gas default to enable relax.

opcodes/ChangeLog:

* loongarch-opc.c (struct loongarch_ASEs_option): New member relax
with the default value 1.

bfd/elfnn-loongarch.c
opcodes/loongarch-opc.c

index d501991e4cfd1a685ae0f57f06e96abb1a0e3188..b16066c5d91c6d455277dbeff385351ce9c629dd 100644 (file)
@@ -3698,7 +3698,7 @@ loongarch_relax_delete_bytes (bfd *abfd,
 
 /* Relax pcalau12i,addi.d => pcaddi.  */
 static bool
-loongarch_relax_pcala_addi(bfd *abfd, asection *sec,
+loongarch_relax_pcala_addi (bfd *abfd, asection *sec,
                       Elf_Internal_Rela *rel_hi, bfd_vma symval)
 {
   bfd_byte *contents = elf_section_data (sec)->this_hdr.contents;
@@ -3967,7 +3967,7 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec,
            {
              if (i + 4 > sec->reloc_count)
                break;
-             loongarch_relax_pcala_addi(abfd, sec, rel, symval);
+             loongarch_relax_pcala_addi (abfd, sec, rel, symval);
            }
          break;
        case R_LARCH_GOT_PC_HI20:
@@ -3977,7 +3977,7 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec,
                break;
              if (loongarch_relax_pcala_ld (abfd, sec, rel))
                {
-                 loongarch_relax_pcala_addi(abfd, sec, rel, symval);
+                 loongarch_relax_pcala_addi (abfd, sec, rel, symval);
                }
            }
          break;
index 39d724a3398ea9a5eb6cec25b21f318be5f5090d..573b691c1fdc90610a0e54be87dbfa86e249ff61 100644 (file)
 #include "opcode/loongarch.h"
 #include "libiberty.h"
 
-struct loongarch_ASEs_option LARCH_opts;
+struct loongarch_ASEs_option LARCH_opts =
+{
+  .relax = 1
+};
 
 size_t
 loongarch_insn_length (insn_t insn ATTRIBUTE_UNUSED)