From 26c3ff3f79068bff98b49c2f666682eb10ebfa2b Mon Sep 17 00:00:00 2001 From: Xing Li Date: Mon, 31 Oct 2022 20:55:04 +0800 Subject: [PATCH 1/2] LoongArch:Fix wrong line number in .debug_line Signed-off-by: Xing Li --- ...Fix-wrong-line-number-in-.debug_line.patch | 39 +++++++++++++++++++ binutils.spec | 7 +++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 0001-LoongArch-Fix-wrong-line-number-in-.debug_line.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.spec b/binutils.spec index 511edb7..7df47e8 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,7 @@ 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 #end #---------------------------------------------------------------------------- @@ -856,6 +857,7 @@ using libelf instead of BFD. %patch97 -p1 %patch1000 -p1 %patch1001 -p1 +%patch1002 -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 +1307,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Mon Oct 31 2022 Xing Li - 2.30-113.0.3 +- Fixup LoongArch wrong debug line. + * Wed Jun 22 2022 Xing Li - 2.30-113.0.2 - Add loongarch support. -- Gitee From 6053e499cb8a176558ebcd2b32b08d29e18424ad Mon Sep 17 00:00:00 2001 From: Xing Li Date: Thu, 1 Dec 2022 16:10:30 +0800 Subject: [PATCH 2/2] LoongArch: Add missing opcode Signed-off-by: Xing Li --- binutils.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/binutils.spec b/binutils.spec index 7df47e8..aa42ba7 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.3 +%define anolis_release .0.4 %if 0%{!?binutils_target:1} @@ -617,6 +617,7 @@ 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 #---------------------------------------------------------------------------- @@ -858,6 +859,7 @@ using libelf instead of BFD. %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 ? @@ -1307,6 +1309,9 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Mon Dec 1 2022 Xing Li - 2.30-113.0.4 +- Add LoongArch missing opcode. + * Mon Oct 31 2022 Xing Li - 2.30-113.0.3 - Fixup LoongArch wrong debug line. -- Gitee