]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
LoongArch: LoongArch64 allows relocations to use 64-bit addends
authorLulu Cai <cailulu@loongson.cn>
Wed, 7 Aug 2024 10:04:26 +0000 (18:04 +0800)
committerliuzhensong <liuzhensong@loongson.cn>
Fri, 30 Aug 2024 03:53:31 +0000 (11:53 +0800)
Relocations using 64-bit addends allow larger constant offset address
calculations to be fused.

gas/config/tc-loongarch.c
gas/testsuite/gas/loongarch/large_addend.d [new file with mode: 0644]
gas/testsuite/gas/loongarch/large_addend.s [new file with mode: 0644]

index 5ca33c6e2e82321c70d95d507c579dddc9872616..2d2fc74b80e4a6bfb34357bffe0b9410a1d70396 100644 (file)
@@ -1221,6 +1221,9 @@ append_fixp_and_insn (struct loongarch_cl_insn *ip)
                                         bfd_get_reloc_size (howto),
                                         &reloc_info[i].value, FALSE, r_type);
            }
+         /* Allow LoongArch 64 to use 64-bit addends.  */
+         if (LARCH_opts.ase_lp64)
+           ip->fixp[i]->fx_no_overflow = 1;
        }
     }
 
diff --git a/gas/testsuite/gas/loongarch/large_addend.d b/gas/testsuite/gas/loongarch/large_addend.d
new file mode 100644 (file)
index 0000000..18eb33a
--- /dev/null
@@ -0,0 +1,12 @@
+#as:
+#objdump: -r
+#skip: loongarch32-*-*
+
+.*:     file format elf64-loongarch
+
+RELOCATION RECORDS FOR \[\.text\]:
+OFFSET           TYPE              VALUE
+0000000000000000 R_LARCH_PCALA_HI20  _start\+0x7fffabcd12345678
+0000000000000004 R_LARCH_PCALA_LO12  _start\+0x7fffabcd12345678
+0000000000000008 R_LARCH_PCALA64_LO20  _start\+0x7fffabcd12345678
+000000000000000c R_LARCH_PCALA64_HI12  _start\+0x7fffabcd12345678
diff --git a/gas/testsuite/gas/loongarch/large_addend.s b/gas/testsuite/gas/loongarch/large_addend.s
new file mode 100644 (file)
index 0000000..7db9052
--- /dev/null
@@ -0,0 +1,8 @@
+    .text
+    .global _start
+_start:
+    pcalau12i  $a0, %pc_hi20(_start+0x7fffabcd12345678)
+    addi.d     $a1, $zero, %pc_lo12(_start+0x7fffabcd12345678)
+    lu32i.d    $a1, %pc64_lo20(_start+0x7fffabcd12345678)
+    lu52i.d    $a1, $a1, %pc64_hi12(_start+0x7fffabcd12345678)
+    add.d      $a0, $a1, $a0