aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorLulu Cai <cailulu@loongson.cn>2023-10-31 16:11:29 +0800
committerliuzhensong <liuzhensong@loongson.cn>2023-12-25 11:46:22 +0800
commit26265e7fdf19d461563388495b6799eb3719f80a (patch)
tree3aaf2793a448b90fd5d55097ee5dbf9efa12ad4c /bfd
parent051b3736af7b9dc47a37e31a9c82556e942d1ed4 (diff)
downloadgdb-26265e7fdf19d461563388495b6799eb3719f80a.zip
gdb-26265e7fdf19d461563388495b6799eb3719f80a.tar.gz
gdb-26265e7fdf19d461563388495b6799eb3719f80a.tar.bz2
LoongArch: Add new relocs and macro for TLSDESC.
The normal DESC instruction sequence is: pcalau12i $a0,%desc_pc_hi20(var) #R_LARCH_TLS_DESC_PC_HI20 addi.d $a0,$a0,%desc_pc_lo12(var) #R_LARCH_TLS_DESC_PC_LO12 ld.d $ra,$a0,%desc_ld(var) #R_LARCH_TLS_DESC_LD jirl $ra,$ra,%desc_call(var) #R_LARCH_TLS_DESC_CALL add.d $a0,$a0,$tp
Diffstat (limited to 'bfd')
-rw-r--r--bfd/bfd-in2.h12
-rw-r--r--bfd/elfxx-loongarch.c210
-rw-r--r--bfd/libbfd.h12
-rw-r--r--bfd/reloc.c29
4 files changed, 261 insertions, 2 deletions
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 53c40ec..85251aa 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -7377,6 +7377,8 @@ enum bfd_reloc_code_real
BFD_RELOC_LARCH_TLS_DTPREL64,
BFD_RELOC_LARCH_TLS_TPREL32,
BFD_RELOC_LARCH_TLS_TPREL64,
+ BFD_RELOC_LARCH_TLS_DESC32,
+ BFD_RELOC_LARCH_TLS_DESC64,
BFD_RELOC_LARCH_MARK_LA,
BFD_RELOC_LARCH_MARK_PCREL,
BFD_RELOC_LARCH_SOP_PUSH_PCREL,
@@ -7461,6 +7463,16 @@ enum bfd_reloc_code_real
BFD_RELOC_LARCH_SUB_ULEB128,
BFD_RELOC_LARCH_64_PCREL,
BFD_RELOC_LARCH_CALL36,
+ BFD_RELOC_LARCH_TLS_DESC_PC_HI20,
+ BFD_RELOC_LARCH_TLS_DESC_PC_LO12,
+ BFD_RELOC_LARCH_TLS_DESC64_PC_LO20,
+ BFD_RELOC_LARCH_TLS_DESC64_PC_HI12,
+ BFD_RELOC_LARCH_TLS_DESC_HI20,
+ BFD_RELOC_LARCH_TLS_DESC_LO12,
+ BFD_RELOC_LARCH_TLS_DESC64_LO20,
+ BFD_RELOC_LARCH_TLS_DESC64_HI12,
+ BFD_RELOC_LARCH_TLS_DESC_LD,
+ BFD_RELOC_LARCH_TLS_DESC_CALL,
BFD_RELOC_UNUSED
};
typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
diff --git a/bfd/elfxx-loongarch.c b/bfd/elfxx-loongarch.c
index 679b79f..30a941a 100644
--- a/bfd/elfxx-loongarch.c
+++ b/bfd/elfxx-loongarch.c
@@ -293,8 +293,40 @@ static loongarch_reloc_howto_type loongarch_howto_table[] =
NULL, /* adjust_reloc_bits */
NULL), /* larch_reloc_type_name */
- LOONGARCH_EMPTY_HOWTO (13),
- LOONGARCH_EMPTY_HOWTO (14),
+ LOONGARCH_HOWTO (R_LARCH_TLS_DESC32, /* type (13). */
+ 0, /* rightshift. */
+ 4, /* size. */
+ 32, /* bitsize. */
+ false, /* pc_relative. */
+ 0, /* bitpos. */
+ complain_overflow_dont, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_LARCH_TLS_DESC32", /* name. */
+ false, /* partial_inplace. */
+ 0, /* src_mask. */
+ ALL_ONES, /* dst_mask. */
+ false, /* pcrel_offset. */
+ BFD_RELOC_LARCH_TLS_DESC32, /* bfd_reloc_code_real_type. */
+ NULL, /* adjust_reloc_bits. */
+ NULL), /* larch_reloc_type_name. */
+
+ LOONGARCH_HOWTO (R_LARCH_TLS_DESC64, /* type (14). */
+ 0, /* rightshift. */
+ 4, /* size. */
+ 64, /* bitsize. */
+ false, /* pc_relative. */
+ 0, /* bitpos. */
+ complain_overflow_dont, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_LARCH_TLS_DESC64", /* name. */
+ false, /* partial_inplace. */
+ 0, /* src_mask. */
+ ALL_ONES, /* dst_mask. */
+ false, /* pcrel_offset. */
+ BFD_RELOC_LARCH_TLS_DESC64, /* bfd_reloc_code_real_type. */
+ NULL, /* adjust_reloc_bits. */
+ NULL), /* larch_reloc_type_name. */
+
LOONGARCH_EMPTY_HOWTO (15),
LOONGARCH_EMPTY_HOWTO (16),
LOONGARCH_EMPTY_HOWTO (17),
@@ -1569,6 +1601,180 @@ static loongarch_reloc_howto_type loongarch_howto_table[] =
BFD_RELOC_LARCH_CALL36, /* bfd_reloc_code_real_type. */
reloc_sign_bits, /* adjust_reloc_bits. */
"call36"), /* larch_reloc_type_name. */
+
+ /* TLS_DESC PCREL. */
+ LOONGARCH_HOWTO (R_LARCH_TLS_DESC_PC_HI20, /* type (111). */
+ 12, /* rightshift. */
+ 4, /* size. */
+ 20, /* bitsize. */
+ true, /* pc_relative. */
+ 5, /* bitpos. */
+ complain_overflow_signed, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_LARCH_TLS_DESC_PC_HI20", /* name. */
+ false, /* partial_inplace. */
+ 0, /* src_mask. */
+ 0x1ffffe0, /* dst_mask. */
+ false, /* pcrel_offset. */
+ BFD_RELOC_LARCH_TLS_DESC_PC_HI20, /* bfd_reloc_code_real_type. */
+ reloc_bits, /* adjust_reloc_bits. */
+ "desc_pc_hi20"), /* larch_reloc_type_name. */
+
+ LOONGARCH_HOWTO (R_LARCH_TLS_DESC_PC_LO12, /* type (112). */
+ 0, /* rightshift. */
+ 4, /* size. */
+ 12, /* bitsize. */
+ true, /* pc_relative. */
+ 10, /* bitpos. */
+ complain_overflow_signed, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_LARCH_TLS_DESC_PC_LO12", /* name. */
+ false, /* partial_inplace. */
+ 0, /* src_mask. */
+ 0x3ffc00, /* dst_mask. */
+ false, /* pcrel_offset. */
+ BFD_RELOC_LARCH_TLS_DESC_PC_LO12, /* bfd_reloc_code_real_type. */
+ reloc_bits, /* adjust_reloc_bits. */
+ "desc_pc_lo12"), /* larch_reloc_type_name. */
+
+ /* TLS_DESC64 LARGE PCREL. */
+ LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_PC_LO20, /* type (113). */
+ 32, /* rightshift. */
+ 8, /* size. */
+ 20, /* bitsize. */
+ true, /* pc_relative. */
+ 5, /* bitpos. */
+ complain_overflow_signed, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_LARCH_TLS_DESC64_PC_LO20", /* name. */
+ false, /* partial_inplace. */
+ 0, /* src_mask. */
+ 0x1ffffe0, /* dst_mask. */
+ false, /* pcrel_offset. */
+ BFD_RELOC_LARCH_TLS_DESC64_PC_LO20, /* bfd_reloc_code_real_type. */
+ reloc_bits, /* adjust_reloc_bits. */
+ "desc64_pc_lo20"), /* larch_reloc_type_name. */
+
+ LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_PC_HI12, /* type (114). */
+ 52, /* rightshift. */
+ 8, /* size. */
+ 12, /* bitsize. */
+ true, /* pc_relative. */
+ 10, /* bitpos. */
+ complain_overflow_signed, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_LARCH_TLS_DESC64_PC_HI12", /* name. */
+ false, /* partial_inplace. */
+ 0, /* src_mask. */
+ 0x3ffc00, /* dst_mask. */
+ false, /* pcrel_offset. */
+ BFD_RELOC_LARCH_TLS_DESC64_PC_HI12, /* bfd_reloc_code_real_type. */
+ reloc_bits, /* adjust_reloc_bits. */
+ "desc64_pc_hi12"), /* larch_reloc_type_name. */
+
+ /* TLS_DESC ABS. */
+ LOONGARCH_HOWTO (R_LARCH_TLS_DESC_HI20, /* type (115). */
+ 12, /* rightshift. */
+ 4, /* size. */
+ 20, /* bitsize. */
+ false, /* pc_relative. */
+ 5, /* bitpos. */
+ complain_overflow_signed, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_LARCH_TLS_DESC_HI20", /* name. */
+ false, /* partial_inplace. */
+ 0, /* src_mask. */
+ 0x1ffffe0, /* dst_mask. */
+ false, /* pcrel_offset. */
+ BFD_RELOC_LARCH_TLS_DESC_HI20, /* bfd_reloc_code_real_type. */
+ reloc_bits, /* adjust_reloc_bits. */
+ "desc_hi20"), /* larch_reloc_type_name. */
+
+ LOONGARCH_HOWTO (R_LARCH_TLS_DESC_LO12, /* type (116). */
+ 0, /* rightshift. */
+ 4, /* size. */
+ 12, /* bitsize. */
+ false, /* pc_relative. */
+ 10, /* bitpos. */
+ complain_overflow_signed, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_LARCH_TLS_DESC_LO12", /* name. */
+ false, /* partial_inplace. */
+ 0, /* src_mask. */
+ 0x3ffc00, /* dst_mask. */
+ false, /* pcrel_offset. */
+ BFD_RELOC_LARCH_TLS_DESC_LO12, /* bfd_reloc_code_real_type. */
+ reloc_bits, /* adjust_reloc_bits. */
+ "desc_lo12"), /* larch_reloc_type_name. */
+
+ /* TLS_DESC64 LARGE ABS. */
+ LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_LO20, /* type (117). */
+ 32, /* rightshift. */
+ 8, /* size. */
+ 20, /* bitsize. */
+ false, /* pc_relative. */
+ 5, /* bitpos. */
+ complain_overflow_signed, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_LARCH_TLS_DESC64_LO20", /* name. */
+ false, /* partial_inplace. */
+ 0, /* src_mask. */
+ 0x1ffffe0, /* dst_mask. */
+ false, /* pcrel_offset. */
+ BFD_RELOC_LARCH_TLS_DESC64_LO20, /* bfd_reloc_code_real_type. */
+ reloc_bits, /* adjust_reloc_bits. */
+ "desc64_lo20"), /* larch_reloc_type_name. */
+
+ LOONGARCH_HOWTO (R_LARCH_TLS_DESC64_HI12, /* type (118). */
+ 52, /* rightshift. */
+ 8, /* size. */
+ 12, /* bitsize. */
+ false, /* pc_relative. */
+ 10, /* bitpos. */
+ complain_overflow_signed, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_LARCH_TLS_DESC64_HI12", /* name. */
+ false, /* partial_inplace. */
+ 0, /* src_mask. */
+ 0x3ffc00, /* dst_mask. */
+ false, /* pcrel_offset. */
+ BFD_RELOC_LARCH_TLS_DESC64_HI12, /* bfd_reloc_code_real_type. */
+ reloc_bits, /* adjust_reloc_bits. */
+ "desc64_hi12"), /* larch_reloc_type_name. */
+
+ LOONGARCH_HOWTO (R_LARCH_TLS_DESC_LD, /* type (119). */
+ 0, /* rightshift. */
+ 4, /* size. */
+ 0, /* bitsize. */
+ true, /* pc_relative. */
+ 0, /* bitpos. */
+ complain_overflow_signed, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_LARCH_TLS_DESC_LD", /* name. */
+ false, /* partial_inplace. */
+ 0, /* src_mask. */
+ 0, /* dst_mask. */
+ false, /* pcrel_offset. */
+ BFD_RELOC_LARCH_TLS_DESC_LD, /* bfd_reloc_code_real_type. */
+ NULL, /* adjust_reloc_bits. */
+ "desc_ld"), /* larch_reloc_type_name. */
+
+ LOONGARCH_HOWTO (R_LARCH_TLS_DESC_CALL, /* type (120). */
+ 0, /* rightshift. */
+ 4, /* size. */
+ 0, /* bitsize. */
+ false, /* pc_relative. */
+ 0, /* bitpos. */
+ complain_overflow_dont, /* complain_on_overflow. */
+ bfd_elf_generic_reloc, /* special_function. */
+ "R_LARCH_TLS_DESC_CALL", /* name. */
+ false, /* partial_inplace. */
+ 0, /* src_mask. */
+ 0, /* dst_mask. */
+ false, /* pcrel_offset. */
+ BFD_RELOC_LARCH_TLS_DESC_CALL, /* bfd_reloc_code_real_type. */
+ NULL, /* adjust_reloc_bits. */
+ "desc_call"), /* larch_reloc_type_name. */
};
reloc_howto_type *
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 399b1f6..71b03da 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -3516,6 +3516,8 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_LARCH_TLS_DTPREL64",
"BFD_RELOC_LARCH_TLS_TPREL32",
"BFD_RELOC_LARCH_TLS_TPREL64",
+ "BFD_RELOC_LARCH_TLS_DESC32",
+ "BFD_RELOC_LARCH_TLS_DESC64",
"BFD_RELOC_LARCH_MARK_LA",
"BFD_RELOC_LARCH_MARK_PCREL",
"BFD_RELOC_LARCH_SOP_PUSH_PCREL",
@@ -3600,6 +3602,16 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_LARCH_SUB_ULEB128",
"BFD_RELOC_LARCH_64_PCREL",
"BFD_RELOC_LARCH_CALL36",
+ "BFD_RELOC_LARCH_TLS_DESC_PC_HI20",
+ "BFD_RELOC_LARCH_TLS_DESC_PC_LO12",
+ "BFD_RELOC_LARCH_TLS_DESC64_PC_LO20",
+ "BFD_RELOC_LARCH_TLS_DESC64_PC_HI12",
+ "BFD_RELOC_LARCH_TLS_DESC_HI20",
+ "BFD_RELOC_LARCH_TLS_DESC_LO12",
+ "BFD_RELOC_LARCH_TLS_DESC64_LO20",
+ "BFD_RELOC_LARCH_TLS_DESC64_HI12",
+ "BFD_RELOC_LARCH_TLS_DESC_LD",
+ "BFD_RELOC_LARCH_TLS_DESC_CALL",
"@@overflow: BFD_RELOC_UNUSED@@",
};
#endif
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 4d3ac4c..f7fe0c7 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -8112,6 +8112,10 @@ ENUMX
ENUMX
BFD_RELOC_LARCH_TLS_TPREL64
ENUMX
+ BFD_RELOC_LARCH_TLS_DESC32
+ENUMX
+ BFD_RELOC_LARCH_TLS_DESC64
+ENUMX
BFD_RELOC_LARCH_MARK_LA
ENUMX
BFD_RELOC_LARCH_MARK_PCREL
@@ -8295,6 +8299,31 @@ ENUMX
ENUMX
BFD_RELOC_LARCH_CALL36
+ENUMX
+ BFD_RELOC_LARCH_TLS_DESC_PC_HI20
+ENUMX
+ BFD_RELOC_LARCH_TLS_DESC_PC_LO12
+
+ENUMX
+ BFD_RELOC_LARCH_TLS_DESC64_PC_LO20
+ENUMX
+ BFD_RELOC_LARCH_TLS_DESC64_PC_HI12
+
+ENUMX
+ BFD_RELOC_LARCH_TLS_DESC_HI20
+ENUMX
+ BFD_RELOC_LARCH_TLS_DESC_LO12
+
+ENUMX
+ BFD_RELOC_LARCH_TLS_DESC64_LO20
+ENUMX
+ BFD_RELOC_LARCH_TLS_DESC64_HI12
+
+ENUMX
+ BFD_RELOC_LARCH_TLS_DESC_LD
+ENUMX
+ BFD_RELOC_LARCH_TLS_DESC_CALL
+
ENUMDOC
LARCH relocations.