aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authormengqinggang <mengqinggang@loongson.cn>2023-06-25 17:47:42 +0800
committerliuzhensong <liuzhensong@loongson.cn>2023-06-28 16:14:35 +0800
commitbe1ebb6710a8f707bd4b0eecbd00f4f4964050e5 (patch)
tree413bfa848b9cd768137c124d640890f63daf6fab /gas
parent69933be89fe5002d2d541ecf2145d5ccac19bbac (diff)
downloadfsf-binutils-gdb-be1ebb6710a8f707bd4b0eecbd00f4f4964050e5.zip
fsf-binutils-gdb-be1ebb6710a8f707bd4b0eecbd00f4f4964050e5.tar.gz
fsf-binutils-gdb-be1ebb6710a8f707bd4b0eecbd00f4f4964050e5.tar.bz2
LoongArch: Add R_LARCH_64_PCREL relocation support
Gas defaults to emit R_LARCH_ADD64/R_LARCH_SUB64 unless explcitly declared to emit R_LARCH_64_PCREL. The LoongArch ABI at here: https://github.com/loongson/la-abi-specs/blob/release/la-abi.adoc bfd/ChangeLog: * bfd-in2.h (not): Add R_LARCH_64_PCREL * elfnn-loongarch.c (perform_relocation): Likewise. * elfxx-loongarch.c: Likewise. * libbfd.h: Likewise. * reloc.c: Likewise. gas/ChangeLog: * config/tc-loongarch.c (loongarch_args_parser_can_match_arg_helper): (md_apply_fix): Add R_LARCH_64_PCREL. * testsuite/gas/loongarch/64_pcrel.d: New test. * testsuite/gas/loongarch/64_pcrel.s: New test. include/ChangeLog: * elf/loongarch.h (RELOC_NUMBER): Add R_LARCH_64_PCREL. ld/ChangeLog: * testsuite/ld-loongarch-elf/ld-loongarch-elf.exp: Add test. * testsuite/ld-loongarch-elf/64_pcrel.d: New test. * testsuite/ld-loongarch-elf/64_pcrel.s: New test.
Diffstat (limited to 'gas')
-rw-r--r--gas/config/tc-loongarch.c5
-rw-r--r--gas/testsuite/gas/loongarch/64_pcrel.d11
-rw-r--r--gas/testsuite/gas/loongarch/64_pcrel.s2
3 files changed, 15 insertions, 3 deletions
diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index ba5b626..4ea7b87 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -650,7 +650,7 @@ loongarch_args_parser_can_match_arg_helper (char esc_ch1, char esc_ch2,
esc_ch1, esc_ch2, bit_field, arg);
if (ip->reloc_info[0].type >= BFD_RELOC_LARCH_B16
- && ip->reloc_info[0].type < BFD_RELOC_LARCH_SUB_ULEB128)
+ && ip->reloc_info[0].type < BFD_RELOC_LARCH_64_PCREL)
{
/* As we compact stack-relocs, it is no need for pop operation.
But break out until here in order to check the imm field.
@@ -1230,8 +1230,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
function. If only fx_addsy not null, we generate
BFD_RELOC_LARCH_ADD24/16/8 only, then generate R_LARCH_24/16/8.
To avoid R_LARCH_ADDxx add extra value, we write 0 first
- (use md_number_to_chars (buf, 0, fixP->fx_size)).
- */
+ (use md_number_to_chars (buf, 0, fixP->fx_size)). */
case BFD_RELOC_64:
case BFD_RELOC_32:
if (fixP->fx_r_type == BFD_RELOC_32
diff --git a/gas/testsuite/gas/loongarch/64_pcrel.d b/gas/testsuite/gas/loongarch/64_pcrel.d
new file mode 100644
index 0000000..6d4654b
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/64_pcrel.d
@@ -0,0 +1,11 @@
+#as:
+#objdump: -dr
+
+.*:[ ]+file format .*
+
+
+Disassembly of section .text:
+
+00000000.* <.text>:
+[ ]+0:[ ]+03400000[ ]+andi[ ]+\$zero,[ ]+\$zero,[ ]+0x0
+[ ]+0:[ ]+R_LARCH_64_PCREL[ ]+\*ABS\*
diff --git a/gas/testsuite/gas/loongarch/64_pcrel.s b/gas/testsuite/gas/loongarch/64_pcrel.s
new file mode 100644
index 0000000..932e1bf
--- /dev/null
+++ b/gas/testsuite/gas/loongarch/64_pcrel.s
@@ -0,0 +1,2 @@
+nop
+.reloc 0, R_LARCH_64_PCREL, 0