From 81d3afbf59997dd76010e0994d9c6cae43f027b6 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Mon, 25 Apr 2022 18:07:21 +0200 Subject: [PATCH] - gdb: add missing patches --- ...e-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch | 55 ++++++++++++++++ ...-pt_-dsp-regs-uapi_pt_-dsp-regs-on-G.patch | 43 +++++++++++++ .../gdb/patches/0003-use-asm-sgidefs.h.patch | 40 ++++++++++++ .../0004-gdbserver-fix-build-for-m68k.patch | 63 +++++++++++++++++++ ...fork-inferior-include-linux-ptrace.h.patch | 53 ++++++++++++++++ ...getrandom-compile-for-uclibc-v1.0.35.patch | 39 ++++++++++++ .../0007-fix-musl-build-on-riscv.patch | 60 ++++++++++++++++++ ...-gdbserver-Makefile.in-fix-NLS-build.patch | 38 +++++++++++ 8 files changed, 391 insertions(+) create mode 100644 package/gdb/patches/0001-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch create mode 100644 package/gdb/patches/0002-sh-ptrace-Define-pt_-dsp-regs-uapi_pt_-dsp-regs-on-G.patch create mode 100644 package/gdb/patches/0003-use-asm-sgidefs.h.patch create mode 100644 package/gdb/patches/0004-gdbserver-fix-build-for-m68k.patch create mode 100644 package/gdb/patches/0005-nat-fork-inferior-include-linux-ptrace.h.patch create mode 100644 package/gdb/patches/0006-Fix-getrandom-compile-for-uclibc-v1.0.35.patch create mode 100644 package/gdb/patches/0007-fix-musl-build-on-riscv.patch create mode 100644 package/gdb/patches/0008-gdbserver-Makefile.in-fix-NLS-build.patch diff --git a/package/gdb/patches/0001-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch b/package/gdb/patches/0001-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch new file mode 100644 index 00000000..9369a14d --- /dev/null +++ b/package/gdb/patches/0001-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch @@ -0,0 +1,55 @@ +From 64b8ab56118d2fea027adfb7ebbc01668b29528e Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sat, 6 Aug 2016 17:32:50 -0700 +Subject: [PATCH] ppc/ptrace: Define pt_regs uapi_pt_regs on !GLIBC systems + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +Signed-off-by: Thomas Petazzoni +[Rebase on gdb 8.3] +Signed-off-by: Romain Naour +--- + gdb/nat/ppc-linux.h | 6 ++++++ + gdbserver/linux-ppc-low.cc | 6 ++++++ + 2 files changed, 12 insertions(+) + +diff --git a/gdb/nat/ppc-linux.h b/gdb/nat/ppc-linux.h +index d937a65b69c..1fd54b4a0e0 100644 +--- a/gdb/nat/ppc-linux.h ++++ b/gdb/nat/ppc-linux.h +@@ -18,7 +18,13 @@ + #ifndef NAT_PPC_LINUX_H + #define NAT_PPC_LINUX_H + ++#if !defined(__GLIBC__) ++# define pt_regs uapi_pt_regs ++#endif + #include ++#if !defined(__GLIBC__) ++# undef pt_regs ++#endif + #include + + /* This sometimes isn't defined. */ +diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc +index 337d555aee7..5d518f37268 100644 +--- a/gdbserver/linux-ppc-low.cc ++++ b/gdbserver/linux-ppc-low.cc +@@ -23,7 +23,13 @@ + #include "elf/common.h" + #include + #include ++#if !defined(__GLIBC__) ++# define pt_regs uapi_pt_regs ++#endif + #include ++#if !defined(__GLIBC__) ++# undef pt_regs ++#endif + + #include "arch/ppc-linux-common.h" + #include "arch/ppc-linux-tdesc.h" +-- +2.29.2 + diff --git a/package/gdb/patches/0002-sh-ptrace-Define-pt_-dsp-regs-uapi_pt_-dsp-regs-on-G.patch b/package/gdb/patches/0002-sh-ptrace-Define-pt_-dsp-regs-uapi_pt_-dsp-regs-on-G.patch new file mode 100644 index 00000000..2f96d298 --- /dev/null +++ b/package/gdb/patches/0002-sh-ptrace-Define-pt_-dsp-regs-uapi_pt_-dsp-regs-on-G.patch @@ -0,0 +1,43 @@ +From d205f398e1e36f9673f50f368a3f29fd1dfaa794 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Sat, 3 Jun 2017 21:23:52 +0200 +Subject: [PATCH] sh/ptrace: Define pt_{dsp,}regs uapi_pt_{dsp,}regs on !GLIBC + systems + +Fixes a pt_{dsp,}regs redefinition when building with the musl C library +on SuperH. + +Inspired by +http://git.yoctoproject.org/clean/cgit.cgi/poky/plain/meta/recipes-devtools/gdb/gdb/0004-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch, +adapted for SuperH. + +Signed-off-by: Thomas Petazzoni +[Rebase on gdb 8.0] +Signed-off-by: Romain Naour +--- + gdbserver/linux-sh-low.cc | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc +index a6d3fc60047..b83cce6b9fe 100644 +--- a/gdbserver/linux-sh-low.cc ++++ b/gdbserver/linux-sh-low.cc +@@ -76,7 +76,15 @@ extern const struct target_desc *tdesc_sh; + #include + #endif + ++#if !defined(__GLIBC__) ++# define pt_regs uapi_pt_regs ++# define pt_dspregs uapi_pt_dspregs ++#endif + #include ++#if !defined(__GLIBC__) ++# undef pt_regs ++# undef pt_dspregs ++#endif + + #define sh_num_regs 41 + +-- +2.29.2 + diff --git a/package/gdb/patches/0003-use-asm-sgidefs.h.patch b/package/gdb/patches/0003-use-asm-sgidefs.h.patch new file mode 100644 index 00000000..e04ebd1d --- /dev/null +++ b/package/gdb/patches/0003-use-asm-sgidefs.h.patch @@ -0,0 +1,40 @@ +From 65acc8800dba7e10da882871d4648241805c47ce Mon Sep 17 00:00:00 2001 +From: Andre McCurdy +Date: Sat, 30 Apr 2016 15:29:06 -0700 +Subject: [PATCH] use + +Build fix for MIPS with musl libc + +The MIPS specific header is provided by glibc and uclibc +but not by musl. Regardless of the libc, the kernel headers provide + which provides the same definitions, so use that +instead. + +Upstream-Status: Pending + +[Vincent: +Taken from: https://sourceware.org/bugzilla/show_bug.cgi?id=21070] + +Signed-off-by: Andre McCurdy +Signed-off-by: Khem Raj +Signed-off-by: Vicente Olivert Riera +--- + gdb/mips-linux-nat.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c +index 38ff461a35b..b6cf194b2bf 100644 +--- a/gdb/mips-linux-nat.c ++++ b/gdb/mips-linux-nat.c +@@ -31,7 +31,7 @@ + #include "gdb_proc_service.h" + #include "gregset.h" + +-#include ++#include + #include "nat/gdb_ptrace.h" + #include + #include "inf-ptrace.h" +-- +2.29.2 + diff --git a/package/gdb/patches/0004-gdbserver-fix-build-for-m68k.patch b/package/gdb/patches/0004-gdbserver-fix-build-for-m68k.patch new file mode 100644 index 00000000..846f7ed2 --- /dev/null +++ b/package/gdb/patches/0004-gdbserver-fix-build-for-m68k.patch @@ -0,0 +1,63 @@ +From 90ebe548922538b854de52e8b687384f44360984 Mon Sep 17 00:00:00 2001 +From: Romain Naour +Date: Fri, 22 Jun 2018 22:40:26 +0200 +Subject: [PATCH] gdbserver: fix build for m68k +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +As for strace [1], when is included after , +the build fails on m68k with the following diagnostics: + +In file included from ./../nat/linux-ptrace.h:28:0, + from linux-low.h:27, + from linux-m68k-low.c:20: +[...]/usr/include/sys/reg.h:26:3: error: expected identifier before numeric constant + PT_D1 = 0, + ^ +[...]usr/include/sys/reg.h:26:3: error: expected « } » before numeric constant +[...]usr/include/sys/reg.h:26:3: error: expected unqualified-id before numeric constant +In file included from linux-m68k-low.c:27:0: +[...]usr/include/sys/reg.h:99:1: error: expected declaration before « } » token + }; + ^ + +Fix this by moving on top of "linux-low.h". + +[1] https://github.com/strace/strace/commit/6ebf6c4f9e5ebca123a5b5f24afe67cf0473cf92 + +Signed-off-by: Romain Naour +--- + gdbserver/linux-m68k-low.cc | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc +index 838ba353b0b..36679682b9a 100644 +--- a/gdbserver/linux-m68k-low.cc ++++ b/gdbserver/linux-m68k-low.cc +@@ -17,6 +17,11 @@ + along with this program. If not, see . */ + + #include "server.h" ++ ++#ifdef HAVE_SYS_REG_H ++#include ++#endif ++ + #include "linux-low.h" + + /* Linux target op definitions for the m68k architecture. */ +@@ -80,10 +85,6 @@ m68k_target::low_decr_pc_after_break () + void init_registers_m68k (void); + extern const struct target_desc *tdesc_m68k; + +-#ifdef HAVE_SYS_REG_H +-#include +-#endif +- + #define m68k_num_regs 29 + #define m68k_num_gregs 18 + +-- +2.29.2 + diff --git a/package/gdb/patches/0005-nat-fork-inferior-include-linux-ptrace.h.patch b/package/gdb/patches/0005-nat-fork-inferior-include-linux-ptrace.h.patch new file mode 100644 index 00000000..33dce4d9 --- /dev/null +++ b/package/gdb/patches/0005-nat-fork-inferior-include-linux-ptrace.h.patch @@ -0,0 +1,53 @@ +From c8454711eca2e79437e17ed1e1e68b48b4c8d927 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Sun, 24 Jun 2018 23:33:55 +0200 +Subject: [PATCH] nat/fork-inferior: include linux-ptrace.h + +To decide whether fork() or vfork() should be used, fork-inferior.c +uses the following test: + + #if !(defined(__UCLIBC__) && defined(HAS_NOMMU)) + +However, HAS_NOMMU is never defined, because it gets defined in +linux-ptrace.h, which is not included by fork-inferior.c. Due to this, +gdbserver fails to build on noMMU architectures. This commit fixes +that by simply including linux-ptrace.h. + +This bug was introduced by commit +2090129c36c7e582943b7d300968d19b46160d84 ("Share fork_inferior et al +with gdbserver"). Indeed, the same fork()/vfork() selection was done, +but in another file where linux-ptrace.h was included. + +Fixes the following build issue: + +../nat/fork-inferior.c: In function 'pid_t fork_inferior(const char*, const string&, char**, void (*)(), void (*)(int), void (*)(), const char*, void (*)(const char*, char* const*, char* const*))': +../nat/fork-inferior.c:376:11: error: 'fork' was not declared in this scope + pid = fork (); + ^~~~ +../nat/fork-inferior.c:376:11: note: suggested alternative: 'vfork' + pid = fork (); + ^~~~ + vfork + +Signed-off-by: Thomas Petazzoni +[Romain: rebase on gdb 8.3] +Signed-off-by: Romain Naour +--- + gdb/nat/fork-inferior.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c +index 7ba0126871d..53e1ec72f09 100644 +--- a/gdb/nat/fork-inferior.c ++++ b/gdb/nat/fork-inferior.c +@@ -27,6 +27,7 @@ + #include "gdbsupport/pathstuff.h" + #include "gdbsupport/signals-state-save-restore.h" + #include "gdbsupport/gdb_tilde_expand.h" ++#include "linux-ptrace.h" + #include + + extern char **environ; +-- +2.29.2 + diff --git a/package/gdb/patches/0006-Fix-getrandom-compile-for-uclibc-v1.0.35.patch b/package/gdb/patches/0006-Fix-getrandom-compile-for-uclibc-v1.0.35.patch new file mode 100644 index 00000000..b02d63fc --- /dev/null +++ b/package/gdb/patches/0006-Fix-getrandom-compile-for-uclibc-v1.0.35.patch @@ -0,0 +1,39 @@ +From 879008ef9a48aa1363671f5c1736b49f30c5a379 Mon Sep 17 00:00:00 2001 +From: Peter Seiderer +Date: Sat, 6 Nov 2021 10:06:25 +0100 +Subject: [PATCH] Fix getrandom compile for uclibc < v1.0.35 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- fix getrandom compile for uclibc < v1.0.35, add missing stddef.h + include (fixed in uclibc since v1.0.35, see [1]) + +Fixes: + + .../host/x86_64-buildroot-linux-uclibc/sysroot/usr/include/sys/random.h:27:35: error: unknown type name ‘size_t’ + 27 | extern int getrandom(void *__buf, size_t count, unsigned int flags) + | ^~~~~~ + +[1] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/commit/?id=00972c02c2b6e0a95d5def4a71bdfb188e091782t + +Signed-off-by: Peter Seiderer +--- + gnulib/import/getrandom.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/gnulib/import/getrandom.c b/gnulib/import/getrandom.c +index 41212fb..0ad3f96 100644 +--- a/gnulib/import/getrandom.c ++++ b/gnulib/import/getrandom.c +@@ -19,6 +19,7 @@ + + #include + ++#include + #include + + #include +-- +2.33.1 + diff --git a/package/gdb/patches/0007-fix-musl-build-on-riscv.patch b/package/gdb/patches/0007-fix-musl-build-on-riscv.patch new file mode 100644 index 00000000..34ab08a9 --- /dev/null +++ b/package/gdb/patches/0007-fix-musl-build-on-riscv.patch @@ -0,0 +1,60 @@ +From c3fdbc0a24c83246f951ba79c7167547da979ae5 Mon Sep 17 00:00:00 2001 +From: Fabrice Fontaine +Date: Wed, 10 Nov 2021 23:14:54 +0100 +Subject: [PATCH] fix musl build on riscv + +Fix the following build failure raised with musl: + +../../gdbserver/linux-riscv-low.cc: In function 'void riscv_fill_fpregset(regcache*, void*)': +../../gdbserver/linux-riscv-low.cc:140:19: error: 'ELF_NFPREG' was not declared in this scope; did you mean 'ELF_NGREG'? + 140 | for (i = 0; i < ELF_NFPREG - 1; i++, regbuf += flen) + | ^~~~~~~~~~ + | ELF_NGREG + +musl fixed the issue with +https://git.musl-libc.org/cgit/musl/commit/?id=e5d2823631bbfebacf48e1a34ed28f28d7cb2570 + +Fixes: + - http://autobuild.buildroot.org/results/16b19198980ce9c81a618b3f6e8dc9fe28247a28 + +Signed-off-by: Fabrice Fontaine +--- + gdb/nat/riscv-linux-tdesc.c | 5 +++++ + gdbserver/linux-riscv-low.cc | 5 +++++ + 2 files changed, 10 insertions(+) + +diff --git a/gdb/nat/riscv-linux-tdesc.c b/gdb/nat/riscv-linux-tdesc.c +index 837b1707e0f..667c013006a 100644 +--- a/gdb/nat/riscv-linux-tdesc.c ++++ b/gdb/nat/riscv-linux-tdesc.c +@@ -31,6 +31,11 @@ + # define NFPREG 33 + #endif + ++/* Work around musl breakage since version 1.1.24. */ ++#ifndef ELF_NFPREG ++# define ELF_NFPREG 33 ++#endif ++ + /* See nat/riscv-linux-tdesc.h. */ + + struct riscv_gdbarch_features +diff --git a/gdbserver/linux-riscv-low.cc b/gdbserver/linux-riscv-low.cc +index 8bf97ea4aa3..1142dbc7b16 100644 +--- a/gdbserver/linux-riscv-low.cc ++++ b/gdbserver/linux-riscv-low.cc +@@ -30,6 +30,11 @@ + # define NFPREG 33 + #endif + ++/* Work around musl breakage since version 1.1.24. */ ++#ifndef ELF_NFPREG ++# define ELF_NFPREG 33 ++#endif ++ + /* Linux target op definitions for the RISC-V architecture. */ + + class riscv_target : public linux_process_target +-- +2.33.0 + diff --git a/package/gdb/patches/0008-gdbserver-Makefile.in-fix-NLS-build.patch b/package/gdb/patches/0008-gdbserver-Makefile.in-fix-NLS-build.patch new file mode 100644 index 00000000..903dc61d --- /dev/null +++ b/package/gdb/patches/0008-gdbserver-Makefile.in-fix-NLS-build.patch @@ -0,0 +1,38 @@ +From c098500aee945ee7a3021649eb0a2655b004103c Mon Sep 17 00:00:00 2001 +From: Fabrice Fontaine +Date: Thu, 18 Nov 2021 22:52:08 +0100 +Subject: [PATCH] gdbserver/Makefile.in: fix NLS build + +Fix the following build failure raised since gdb version 10.1 and +https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=9a665d62266e75f0519f3a663784c458885b5c63: + + CXXLD libinproctrace.so +/home/buildroot/autobuild/instance-2/output-1/host/opt/ext-toolchain/bin/../lib/gcc/i586-buildroot-linux-musl/9.3.0/../../../../i586-buildroot-linux-musl/bin/ld: gdbsupport/tdesc-ipa.o: in function `print_xml_feature::visit(tdesc_type_builtin const*)': +/home/buildroot/autobuild/instance-2/output-1/build/gdb-10.2/build/gdbserver/../../gdbserver/../gdbsupport/tdesc.cc:310: undefined reference to `libintl_gettext' + +Fixes: + - http://autobuild.buildroot.org/results/faacc874fe9d32b74cb3d3dea988ef661cb0e3d0 + +Signed-off-by: Fabrice Fontaine +[Upstream status: +https://sourceware.org/pipermail/gdb-patches/2021-November/183580.html] +--- + gdbserver/Makefile.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in +index 71c3c4ad959..e69fbc4dae4 100644 +--- a/gdbserver/Makefile.in ++++ b/gdbserver/Makefile.in +@@ -383,7 +383,7 @@ $(IPA_LIB): $(sort $(IPA_OBJS)) ${CDEPS} + $(ECHO_CXXLD) $(CC_LD) -shared -fPIC -Wl,--soname=$(IPA_LIB) \ + -Wl,--no-undefined $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) \ + $(CXXFLAGS) \ +- -o $(IPA_LIB) ${IPA_OBJS} $(LIBIBERTY_FOR_SHLIB) -ldl -pthread ++ -o $(IPA_LIB) ${IPA_OBJS} $(LIBIBERTY_FOR_SHLIB) -ldl -pthread $(INTL) + + # Put the proper machine-specific files first, so M-. on a machine + # specific routine gets the one for the correct machine. +-- +2.33.0 +