File crash-LoongArch64-Fixed-link-errors-when-build-on-LOONGARC.patch of Package crash.41263
From 3f205d1d4af5a1246bc91465bbbcee441ab79ebd Mon Sep 17 00:00:00 2001
From: Ming Wang <wangming01@loongson.cn>
Date: Fri, 8 Mar 2024 11:18:53 +0800
Subject: [PATCH] LoongArch64: Fixed link errors when build on LOONGARCH64
machine
The following link error exists when building with LOONGARCH64
machine:
/usr/bin/ld: proc-service.o: in function `.LVL71':
proc-service.c:(.text+0x324): undefined reference to `fill_gregset ...
/usr/bin/ld: proc-service.o: in function `.LVL77':
proc-service.c:(.text+0x364): undefined reference to `supply_gregset ...
/usr/bin/ld: proc-service.o: in function `.LVL87':
proc-service.c:(.text+0x3c4): undefined reference to `fill_fpregset ...
/usr/bin/ld: proc-service.o: in function `.LVL93':
proc-service.c:(.text+0x404): undefined reference to `supply_fpregset
collect2: error: ld returned 1 exit status
The cause of the error is that the definition of a function such as
fill_gregset is not implemented. This patch is used to fix this error.
[ kh: added rm command for gdb files added and modified multiple times. ]
Reported-by: Xiujie Jiang <jiangxiujie@kylinos.cn>
Signed-off-by: Ming Wang <wangming01@loongson.cn>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
gdb-10.2.patch | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/gdb-10.2.patch b/gdb-10.2.patch
index fbf7910..7416efe 100644
--- a/gdb-10.2.patch
+++ b/gdb-10.2.patch
@@ -18,6 +18,10 @@ tar xvzmf gdb-10.2.tar.gz \
gdb-10.2/gdb/objfiles.h \
gdb-10.2/bfd/elf-bfd.h
+# For newly added gdb files, remove them to be its original state.
+
+rm -f gdb-10.2/gdb/loongarch-linux-tdep.c
+
exit 0
--- gdb-10.2/Makefile.in.orig
@@ -16057,3 +16061,36 @@ exit 0
m10200-dis.c
m10200-opc.c
m10300-dis.c
+--- gdb-10.2/gdb/loongarch-linux-tdep.c.orig
++++ gdb-10.2/gdb/loongarch-linux-tdep.c
+@@ -707,3 +707,30 @@ _initialize_loongarch_linux_tdep ()
+ gdbarch_register_osabi (bfd_arch_loongarch, bfd_mach_loongarch64,
+ GDB_OSABI_LINUX, loongarch_linux_init_abi);
+ }
++
++/* Wrapper functions. These are only used by libthread_db. */
++#include <sys/procfs.h>
++extern void supply_gregset (struct regcache *regcache,const prgregset_t *gregset);
++extern void fill_gregset (const struct regcache *regcache, prgregset_t *gregset, int regno);
++extern void supply_fpregset (struct regcache *regcache, const prfpregset_t *fpregset);
++extern void fill_fpregset (const struct regcache *regcache, prfpregset_t *fpregset, int regno);
++
++void supply_gregset (struct regcache *regcache, const prgregset_t *gregset)
++{
++ loongarch_elf_gregset.supply_regset (NULL, regcache, -1, gregset, sizeof (prgregset_t));
++}
++
++void fill_gregset (const struct regcache *regcache, prgregset_t *gregset, int regno)
++{
++ loongarch_elf_gregset.collect_regset (NULL, regcache, regno, gregset, sizeof (prgregset_t));
++}
++
++void supply_fpregset (struct regcache *regcache, const prfpregset_t *fpregset)
++{
++ loongarch_elf_fpregset.supply_regset (NULL, regcache, -1, fpregset, sizeof (prfpregset_t));
++}
++
++void fill_fpregset (const struct regcache *regcache, prfpregset_t *fpregset, int regno)
++{
++ loongarch_elf_fpregset.collect_regset (NULL, regcache, regno, fpregset, sizeof (prfpregset_t));
++}
--
2.43.0