aboutsummaryrefslogtreecommitdiff
path: root/bfd
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 /bfd
parent69933be89fe5002d2d541ecf2145d5ccac19bbac (diff)
downloadgdb-be1ebb6710a8f707bd4b0eecbd00f4f4964050e5.zip
gdb-be1ebb6710a8f707bd4b0eecbd00f4f4964050e5.tar.gz
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 'bfd')
-rw-r--r--bfd/bfd-in2.h1
-rw-r--r--bfd/elfnn-loongarch.c1
-rw-r--r--bfd/elfxx-loongarch.c18
-rw-r--r--bfd/libbfd.h1
-rw-r--r--bfd/reloc.c3
5 files changed, 24 insertions, 0 deletions
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 7399fb0..c4fa0c1 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -7343,6 +7343,7 @@ assembler and not (currently) written to any object files. */
BFD_RELOC_LARCH_SUB6,
BFD_RELOC_LARCH_ADD_ULEB128,
BFD_RELOC_LARCH_SUB_ULEB128,
+ BFD_RELOC_LARCH_64_PCREL,
BFD_RELOC_UNUSED };
typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index b16066c..d3d8419 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -2070,6 +2070,7 @@ perform_relocation (const Elf_Internal_Rela *rel, asection *input_section,
/* For eh_frame and debug info. */
case R_LARCH_32_PCREL:
+ case R_LARCH_64_PCREL:
{
value -= sec_addr (input_section) + rel->r_offset;
value += rel->r_addend;
diff --git a/bfd/elfxx-loongarch.c b/bfd/elfxx-loongarch.c
index cb312c4..da440d5 100644
--- a/bfd/elfxx-loongarch.c
+++ b/bfd/elfxx-loongarch.c
@@ -1535,6 +1535,24 @@ static loongarch_reloc_howto_type loongarch_howto_table[] =
NULL, /* adjust_reloc_bits. */
NULL), /* larch_reloc_type_name. */
+ /* 64-bit PC relative. */
+ LOONGARCH_HOWTO (R_LARCH_64_PCREL, /* type (109). */
+ 0, /* rightshift. */
+ 8, /* size. */
+ 64, /* bitsize. */
+ true, /* pc_relative. */
+ 0, /* bitpos. */
+ complain_overflow_signed, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_LARCH_64_PCREL", /* name. */
+ false, /* partial_inplace. */
+ 0, /* src_mask */
+ 0xffffffffffffffff, /* dst_mask */
+ false, /* pcrel_offset */
+ BFD_RELOC_LARCH_64_PCREL, /* bfd_reloc_code_real_type */
+ NULL, /* adjust_reloc_bits */
+ NULL), /* larch_reloc_type_name */
+
};
reloc_howto_type *
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 55aa8f9..d4fb310 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -3524,6 +3524,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_LARCH_SUB6",
"BFD_RELOC_LARCH_ADD_ULEB128",
"BFD_RELOC_LARCH_SUB_ULEB128",
+ "BFD_RELOC_LARCH_64_PCREL",
"@@overflow: BFD_RELOC_UNUSED@@",
};
#endif
diff --git a/bfd/reloc.c b/bfd/reloc.c
index b38cb32..fbc67ac 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -8153,6 +8153,9 @@ ENUMX
ENUMX
BFD_RELOC_LARCH_SUB_ULEB128
+ENUMX
+ BFD_RELOC_LARCH_64_PCREL
+
ENUMDOC
LARCH relocations.