From 1c9d027997e1d1cab4fec45a98ddad3529d88824 Mon Sep 17 00:00:00 2001 From: Xing Li Date: Mon, 31 Oct 2022 20:55:04 +0800 Subject: [PATCH] LoongArch: Fix wrong line number in .debug_line Add missing opcode Signed-off-by: Xing Li --- ...Fix-wrong-line-number-in-.debug_line.patch | 39 +++++++++++++ binutils-LoongArch-Add-missing-opcode.patch | 55 +++++++++++++++++++ binutils.spec | 10 +++- 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 0001-LoongArch-Fix-wrong-line-number-in-.debug_line.patch create mode 100644 binutils-LoongArch-Add-missing-opcode.patch diff --git a/0001-LoongArch-Fix-wrong-line-number-in-.debug_line.patch b/0001-LoongArch-Fix-wrong-line-number-in-.debug_line.patch new file mode 100644 index 0000000..2154d36 --- /dev/null +++ b/0001-LoongArch-Fix-wrong-line-number-in-.debug_line.patch @@ -0,0 +1,39 @@ +From 3594c7862222e205d00fa9293882cb40abc17814 Mon Sep 17 00:00:00 2001 +From: Xing Li +Date: Mon, 31 Oct 2022 20:32:34 +0800 +Subject: [PATCH] LoongArch: Fix wrong line number in .debug_line + + The dwarf2_emit_insn() can create debuginfo of line. But it is called + too late in append_fixp_and_insn. It causes extra offs when debuginfo + of line sets address. + +Signed-off-by: Xing Li +--- + gas/config/tc-loongarch.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c +index 9c4a9102..26ee3f1a 100644 +--- a/gas/config/tc-loongarch.c ++++ b/gas/config/tc-loongarch.c +@@ -819,6 +819,9 @@ append_fixp_and_insn (struct loongarch_cl_insn *ip) + bfd_reloc_code_real_type reloc_type; + struct reloc_info *reloc_info = ip->reloc_info; + size_t i; ++ ++ dwarf2_emit_insn (0); ++ + for (i = 0; i < ip->reloc_num; i++) + { + reloc_type = reloc_info[i].type; +@@ -835,7 +838,6 @@ append_fixp_and_insn (struct loongarch_cl_insn *ip) + as_fatal (_("Internal error: not support relax now")); + else + append_fixed_insn (ip); +- dwarf2_emit_insn (0); + } + + //ask helper for returning a malloced c_str or NULL +-- +2.27.0 + diff --git a/binutils-LoongArch-Add-missing-opcode.patch b/binutils-LoongArch-Add-missing-opcode.patch new file mode 100644 index 0000000..70e4336 --- /dev/null +++ b/binutils-LoongArch-Add-missing-opcode.patch @@ -0,0 +1,55 @@ +From 5a23eb0a55775901a4056e5f12fc97ad266b0ffe Mon Sep 17 00:00:00 2001 +From: Xing Li +Date: Thu, 1 Dec 2022 15:46:52 +0800 +Subject: [PATCH] LoongArch: Add missing opcode + +Signed-off-by: Xing Li +--- + opcodes/loongarch-opc.c | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/opcodes/loongarch-opc.c b/opcodes/loongarch-opc.c +index 2c543027..fb36e561 100644 +--- a/opcodes/loongarch-opc.c ++++ b/opcodes/loongarch-opc.c +@@ -778,6 +778,18 @@ static struct loongarch_opcode loongarch_jmp_opcodes[] = + }; + static struct loongarch_opcode loongarch_128vec_opcodes[] = { + /* match, mask, name, format, macro, include, exclude, pinfo */ ++{0x2c000000, 0xffc00000, "vld", "v0:5,r5:5,s10:12", 0, 0, 0, 0}, ++{0x2c400000, 0xffc00000, "vst", "v0:5,r5:5,s10:12", 0, 0, 0, 0}, ++{0x30100000, 0xfff80000, "vldrepl.d", "v0:5,r5:5,s10:9<<3", 0, 0, 0, 0}, ++{0x30200000, 0xfff00000, "vldrepl.w", "v0:5,r5:5,s10:10<<2", 0, 0, 0, 0}, ++{0x30400000, 0xffe00000, "vldrepl.h", "v0:5,r5:5,s10:11<<1", 0, 0, 0, 0}, ++{0x30800000, 0xffc00000, "vldrepl.b", "v0:5,r5:5,s10:12", 0, 0, 0, 0}, ++{0x31100000, 0xfff80000, "vstelm.d", "v0:5,r5:5,s10:8<<3,u18:1", 0, 0, 0, 0}, ++{0x31200000, 0xfff00000, "vstelm.w", "v0:5,r5:5,s10:8<<2,u18:2", 0, 0, 0, 0}, ++{0x31400000, 0xffe00000, "vstelm.h", "v0:5,r5:5,s10:8<<1,u18:3", 0, 0, 0, 0}, ++{0x31800000, 0xffc00000, "vstelm.b", "v0:5,r5:5,s10:8,u18:4", 0, 0, 0, 0}, ++{0x38400000, 0xffff8000, "vldx", "v0:5,r5:5,r10:5", 0, 0, 0, 0}, ++{0x38440000, 0xffff8000, "vstx", "v0:5,r5:5,r10:5", 0, 0, 0, 0}, + {0x70000000, 0xffff8000, "vseq.b", "v0:5,v5:5,v10:5", 0, 0, 0, 0}, + {0x70008000, 0xffff8000, "vseq.h", "v0:5,v5:5,v10:5", 0, 0, 0, 0}, + {0x70010000, 0xffff8000, "vseq.w", "v0:5,v5:5,v10:5", 0, 0, 0, 0}, +@@ -1434,6 +1446,18 @@ static struct loongarch_opcode loongarch_128vec_opcodes[] = { + + static struct loongarch_opcode loongarch_256vec_opcodes[] = { + /* match, mask, name, format, macro, include, exclude, pinfo */ ++{0x2c800000, 0xffc00000, "xvld", "x0:5,r5:5,s10:12", 0, 0, 0, 0}, ++{0x2cc00000, 0xffc00000, "xvst", "x0:5,r5:5,s10:12", 0, 0, 0, 0}, ++{0x32100000, 0xfff80000, "xvldrepl.d", "x0:5,r5:5,s10:9<<3", 0, 0, 0, 0}, ++{0x32200000, 0xfff00000, "xvldrepl.w", "x0:5,r5:5,s10:10<<2", 0, 0, 0, 0}, ++{0x32400000, 0xffe00000, "xvldrepl.h", "x0:5,r5:5,s10:11<<1", 0, 0, 0, 0}, ++{0x32800000, 0xffc00000, "xvldrepl.b", "x0:5,r5:5,s10:12", 0, 0, 0, 0}, ++{0x33100000, 0xfff00000, "xvstelm.d", "x0:5,r5:5,s10:8<<3,u18:2", 0, 0, 0, 0}, ++{0x33200000, 0xffe00000, "xvstelm.w", "x0:5,r5:5,s10:8<<2,u18:3", 0, 0, 0, 0}, ++{0x33400000, 0xffc00000, "xvstelm.h", "x0:5,r5:5,s10:8<<1,u18:4", 0, 0, 0, 0}, ++{0x33800000, 0xff800000, "xvstelm.b", "x0:5,r5:5,s10:8,u18:5", 0, 0, 0, 0}, ++{0x38480000, 0xffff8000, "xvldx", "x0:5,r5:5,r10:5", 0, 0, 0, 0}, ++{0x384c0000, 0xffff8000, "xvstx", "x0:5,r5:5,r10:5", 0, 0, 0, 0}, + {0x74000000, 0xffff8000, "xvseq.b", "x0:5,x5:5,x10:5", 0, 0, 0, 0}, + {0x74008000, 0xffff8000, "xvseq.h", "x0:5,x5:5,x10:5", 0, 0, 0, 0}, + {0x74010000, 0xffff8000, "xvseq.w", "x0:5,x5:5,x10:5", 0, 0, 0, 0}, +-- +2.27.0 + diff --git a/binutils.spec b/binutils.spec index 511edb7..6010e0f 100644 --- a/binutils.spec +++ b/binutils.spec @@ -24,7 +24,7 @@ # /usr/bin/aarch64-linux-gnu-ar # /usr/bin/aarch64-linux-gnu-as # [etc] -%define anolis_release .0.2 +%define anolis_release .0.3 %if 0%{!?binutils_target:1} @@ -616,6 +616,8 @@ Patch97: binutils-plugin-error.patch Patch1000: 0001-binutils-anolis-rebrand.patch Patch1001: binutils-loongarch-support.patch +Patch1002: 0001-LoongArch-Fix-wrong-line-number-in-.debug_line.patch +Patch1003: binutils-LoongArch-Add-missing-opcode.patch #end #---------------------------------------------------------------------------- @@ -856,6 +858,8 @@ using libelf instead of BFD. %patch97 -p1 %patch1000 -p1 %patch1001 -p1 +%patch1002 -p1 +%patch1003 -p1 # We cannot run autotools as there is an exact requirement of autoconf-2.59. # FIXME - this is no longer true. Maybe try reinstating autotool use ? @@ -1305,6 +1309,10 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Thu Dec 1 2022 Xing Li - 2.30-113.0.3 +- Fixup LoongArch wrong debug line. +- Add LoongArch missing opcode. + * Wed Jun 22 2022 Xing Li - 2.30-113.0.2 - Add loongarch support. -- Gitee