From 15e61520b42b513914e6c985147ac95f82723ca42c1fa575c51f353f448505b1 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Wed, 22 May 2019 12:16:56 +0000 Subject: [PATCH] Accepting request 704690 from home:marxin:branches:devel:gcc - Add gdb-gcc9-fix-build-with-latest-GCC-9.0-tree.patch and gdb-gcc9-warning-on-elf32-arm.c-elf32_arm_final_link.patch in order to fix build with GCC9. OBS-URL: https://build.opensuse.org/request/show/704690 OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=203 --- ...9-fix-build-with-latest-GCC-9.0-tree.patch | 50 +++++++++++++++++++ ...-on-elf32-arm.c-elf32_arm_final_link.patch | 48 ++++++++++++++++++ gdb.changes | 7 +++ gdb.spec | 6 ++- 4 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 gdb-gcc9-fix-build-with-latest-GCC-9.0-tree.patch create mode 100644 gdb-gcc9-warning-on-elf32-arm.c-elf32_arm_final_link.patch diff --git a/gdb-gcc9-fix-build-with-latest-GCC-9.0-tree.patch b/gdb-gcc9-fix-build-with-latest-GCC-9.0-tree.patch new file mode 100644 index 0000000..15d63f8 --- /dev/null +++ b/gdb-gcc9-fix-build-with-latest-GCC-9.0-tree.patch @@ -0,0 +1,50 @@ +From 7406a50077773e78282a495cb32ef5b8179f6a33 Mon Sep 17 00:00:00 2001 +From: Dimitar Dimitrov +Date: Mon, 17 Dec 2018 21:30:52 +0200 +Subject: [PATCH] Fix build with latest GCC 9.0 tree + +A recent patch [1] to fix a GCC PR [2] actually broke the GDB build. +To fix, remove the stack pointer clobber. GCC will ignore the clobber +marker, and will not save or restore the stack pointer. + +I ran "make check-gdb" on x86_64 to ensure there are no regressions. + +gdb/ChangeLog: + +2018-12-17 Dimitar Dimitrov + + * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Remove sp clobbers. + +[1] https://gcc.gnu.org/ml/gcc-patches/2018-12/msg00532.html +[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52813 + +Signed-off-by: Dimitar Dimitrov +--- + gdb/ChangeLog | 5 +++++ + gdb/nat/linux-ptrace.c | 4 ++-- + 2 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c +index d4c1b8f9fd..187cfeb9bc 100644 +--- a/gdb/nat/linux-ptrace.c ++++ b/gdb/nat/linux-ptrace.c +@@ -161,14 +161,14 @@ linux_ptrace_test_ret_to_nx (void) + ".globl linux_ptrace_test_ret_to_nx_instr;" + "linux_ptrace_test_ret_to_nx_instr:" + "ret" +- : : "r" (return_address) : "%esp", "memory"); ++ : : "r" (return_address) : "memory"); + #elif defined __x86_64__ + asm volatile ("pushq %0;" + ".globl linux_ptrace_test_ret_to_nx_instr;" + "linux_ptrace_test_ret_to_nx_instr:" + "ret" + : : "r" ((uint64_t) (uintptr_t) return_address) +- : "%rsp", "memory"); ++ : "memory"); + #else + # error "!__i386__ && !__x86_64__" + #endif +-- +2.21.0 + diff --git a/gdb-gcc9-warning-on-elf32-arm.c-elf32_arm_final_link.patch b/gdb-gcc9-warning-on-elf32-arm.c-elf32_arm_final_link.patch new file mode 100644 index 0000000..b596982 --- /dev/null +++ b/gdb-gcc9-warning-on-elf32-arm.c-elf32_arm_final_link.patch @@ -0,0 +1,48 @@ +From 453f8e1e4918171bc12e4d03aab7ee8360dfcfef Mon Sep 17 00:00:00 2001 +From: Sergio Durigan Junior +Date: Mon, 21 Jan 2019 15:36:41 -0500 +Subject: [PATCH] Fix GCC9 warning on elf32-arm.c:elf32_arm_final_link_relocate + +Fedora Rawhide has just switched to GCC9, and now GDB doesn't compile +because of a BFD warning: + + BUILDSTDERR: ../../bfd/elf32-arm.c: In function 'elf32_arm_final_link_relocate': + BUILDSTDERR: ../../bfd/elf32-arm.c:10907:10: error: absolute value function 'labs' given an argument of type 'bfd_signed_vma' {aka 'long long int'} but has parameter of type 'long int' which may cause truncation of value [-Werror=absolute-value] + BUILDSTDERR: 10907 | value = labs (relocation); + BUILDSTDERR: | ^~~~ + +You can take a look at the full build log here: + + https://kojipkgs.fedoraproject.org//work/tasks/4828/32174828/build.log + +The fix is (apparently) simple: instead of using 'labs', we should use +'llabs', since we're passing a 'bfd_signed_vma' to it, which is at +least a 'long long int', as far as I have checked. This is what this +patch does. + +bfd/ChangeLog: +2019-01-25 Sergio Durigan Junior + + * elf32-arm.c (elf32_arm_final_link_relocate): Use 'llabs' instead + of 'labs' (and fix GCC warning). +--- + bfd/ChangeLog | 5 +++++ + bfd/elf32-arm.c | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c +index 53baea269b..28ee9d55a8 100644 +--- a/bfd/elf32-arm.c ++++ b/bfd/elf32-arm.c +@@ -10904,7 +10904,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, + + /* PR 21523: Use an absolute value. The user of this reloc will + have already selected an ADD or SUB insn appropriately. */ +- value = labs (relocation); ++ value = llabs (relocation); + + if (value >= 0x1000) + return bfd_reloc_overflow; +-- +2.21.0 + diff --git a/gdb.changes b/gdb.changes index 680318b..7c42963 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed May 22 08:44:01 UTC 2019 - Martin Liška + +- Add gdb-gcc9-fix-build-with-latest-GCC-9.0-tree.patch and + gdb-gcc9-warning-on-elf32-arm.c-elf32_arm_final_link.patch + in order to fix build with GCC9. + ------------------------------------------------------------------- Thu Jan 24 10:13:33 UTC 2019 - tdevries@suse.com diff --git a/gdb.spec b/gdb.spec index fce08aa..86b4a1d 100644 --- a/gdb.spec +++ b/gdb.spec @@ -13,7 +13,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -244,6 +244,8 @@ Patch1002: gdb-6.6-buildid-locate-rpm-suse.patch Patch1004: gdb-fix-buf-overflow.diff Patch1005: gdb-7.10-swo18929.patch Patch1007: gdb-fix-s390-build.diff +Patch1008: gdb-gcc9-fix-build-with-latest-GCC-9.0-tree.patch +Patch1009: gdb-gcc9-warning-on-elf32-arm.c-elf32_arm_final_link.patch # Backports from master Patch2000: gdb-fix-crash-when-reading-core.patch @@ -570,6 +572,8 @@ find -name "*.info*"|xargs rm -f %patch1004 -p1 %patch1005 -p1 %patch1007 -p1 +%patch1008 -p1 +%patch1009 -p1 %patch2000 -p1 %patch2001 -p1