Blame SOURCES/gdb-6.3-bz140532-ppc-unwinding-test.patch

a8223e
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
a8223e
From: Fedora GDB patches <invalid@email.com>
a8223e
Date: Fri, 27 Oct 2017 21:07:50 +0200
a8223e
Subject: gdb-6.3-bz140532-ppc-unwinding-test.patch
a8223e
a8223e
;; Update PPC unwinding patches to their upstream variants (BZ 140532).
a8223e
;;=fedoratest
a8223e
a8223e
diff --git a/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S
a8223e
new file mode 100644
a8223e
--- /dev/null
a8223e
+++ b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm32.S
a8223e
@@ -0,0 +1,78 @@
a8223e
+/* This testcase is part of GDB, the GNU debugger.
a8223e
+
a8223e
+   Copyright 2007 Free Software Foundation, Inc.
a8223e
+
a8223e
+   This program is free software; you can redistribute it and/or modify
a8223e
+   it under the terms of the GNU General Public License as published by
a8223e
+   the Free Software Foundation; either version 2 of the License, or
a8223e
+   (at your option) any later version.
a8223e
+
a8223e
+   This program is distributed in the hope that it will be useful,
a8223e
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a8223e
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a8223e
+   GNU General Public License for more details.
a8223e
+
a8223e
+   You should have received a copy of the GNU General Public License
a8223e
+   along with this program; if not, write to the Free Software
a8223e
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
a8223e
+
a8223e
+	.section	".text"
a8223e
+	.align 2
a8223e
+	.globl func0
a8223e
+	.type	func0, @function
a8223e
+func0:
a8223e
+	stwu 1,-16(1)
a8223e
+	mflr 0
a8223e
+	stw 31,12(1)
a8223e
+	stw 0,20(1)
a8223e
+	mr 31,1
a8223e
+	bl abort
a8223e
+	.size	func0, .-func0
a8223e
+	.align 2
a8223e
+	.globl func1
a8223e
+	.type	func1, @function
a8223e
+func1:
a8223e
+	stwu 1,-16(1)
a8223e
+	mflr 0
a8223e
+/* 20 = BO = branch always
a8223e
+   31 = BI = CR bit (ignored)  */
a8223e
+	bcl 20,31,.Lpie
a8223e
+.Lpie:	stw 31,12(1)
a8223e
+	stw 0,20(1)
a8223e
+	mr 31,1
a8223e
+	bl func0
a8223e
+	mr 0,3
a8223e
+	lis 9,var@ha
a8223e
+	lwz 9,var@l(9)
a8223e
+	add 0,0,9
a8223e
+	mr 3,0
a8223e
+	lwz 11,0(1)
a8223e
+	lwz 0,4(11)
a8223e
+	mtlr 0
a8223e
+	lwz 31,-4(11)
a8223e
+	mr 1,11
a8223e
+	blr
a8223e
+	.size	func1, .-func1
a8223e
+	.section	.note.GNU-stack,"",@progbits
a8223e
+	.ident	"GCC: (GNU) 3.4.6 20060404 (Red Hat 3.4.6-8)"
a8223e
+
a8223e
+/* Original source file:
a8223e
+
a8223e
+#include <stdlib.h>
a8223e
+
a8223e
+extern volatile int var;
a8223e
+
a8223e
+int func0 (void) __attribute__((__noinline__));
a8223e
+int func0 (void)
a8223e
+{
a8223e
+  abort ();
a8223e
+  return var;
a8223e
+}
a8223e
+
a8223e
+int func1 (void) __attribute__((__noinline__));
a8223e
+int func1 (void)
a8223e
+{
a8223e
+  return func0 () + var;
a8223e
+}
a8223e
+
a8223e
+*/
a8223e
diff --git a/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S
a8223e
new file mode 100644
a8223e
--- /dev/null
a8223e
+++ b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue-asm64.S
a8223e
@@ -0,0 +1,98 @@
a8223e
+/* This testcase is part of GDB, the GNU debugger.
a8223e
+
a8223e
+   Copyright 2007 Free Software Foundation, Inc.
a8223e
+
a8223e
+   This program is free software; you can redistribute it and/or modify
a8223e
+   it under the terms of the GNU General Public License as published by
a8223e
+   the Free Software Foundation; either version 2 of the License, or
a8223e
+   (at your option) any later version.
a8223e
+
a8223e
+   This program is distributed in the hope that it will be useful,
a8223e
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a8223e
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a8223e
+   GNU General Public License for more details.
a8223e
+
a8223e
+   You should have received a copy of the GNU General Public License
a8223e
+   along with this program; if not, write to the Free Software
a8223e
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
a8223e
+
a8223e
+	.section	".toc","aw"
a8223e
+	.section	".text"
a8223e
+	.align 2
a8223e
+	.globl func0
a8223e
+	.section	".opd","aw"
a8223e
+	.align 3
a8223e
+func0:
a8223e
+	.quad	.L.func0,.TOC.@tocbase
a8223e
+	.previous
a8223e
+	.type	func0, @function
a8223e
+.L.func0:
a8223e
+	mflr 0
a8223e
+	std 31,-8(1)
a8223e
+	std 0,16(1)
a8223e
+	stdu 1,-128(1)
a8223e
+	mr 31,1
a8223e
+	bl abort
a8223e
+	nop
a8223e
+	.long 0
a8223e
+	.byte 0,0,0,1,128,1,0,1
a8223e
+	.size	func0,.-.L.func0
a8223e
+	.section	".toc","aw"
a8223e
+.LC1:
a8223e
+	.tc var[TC],var
a8223e
+	.section	".text"
a8223e
+	.align 2
a8223e
+	.globl func1
a8223e
+	.section	".opd","aw"
a8223e
+	.align 3
a8223e
+func1:
a8223e
+	.quad	.L.func1,.TOC.@tocbase
a8223e
+	.previous
a8223e
+	.type	func1, @function
a8223e
+.L.func1:
a8223e
+	mflr 0
a8223e
+/* 20 = BO = branch always
a8223e
+   31 = BI = CR bit (ignored)  */
a8223e
+	bcl 20,31,.Lpie
a8223e
+.Lpie:	std 31,-8(1)
a8223e
+	std 0,16(1)
a8223e
+	stdu 1,-128(1)
a8223e
+	mr 31,1
a8223e
+	bl func0
a8223e
+	mr 11,3
a8223e
+	ld 9,.LC1@toc(2)
a8223e
+	lwz 0,0(9)
a8223e
+	add 0,11,0
a8223e
+	extsw 0,0
a8223e
+	mr 3,0
a8223e
+	ld 1,0(1)
a8223e
+	ld 0,16(1)
a8223e
+	mtlr 0
a8223e
+	ld 31,-8(1)
a8223e
+	blr
a8223e
+	.long 0
a8223e
+	.byte 0,0,0,1,128,1,0,1
a8223e
+	.size	func1,.-.L.func1
a8223e
+	.section	.note.GNU-stack,"",@progbits
a8223e
+	.ident	"GCC: (GNU) 3.4.6 20060404 (Red Hat 3.4.6-8)"
a8223e
+
a8223e
+/* Original source file:
a8223e
+
a8223e
+#include <stdlib.h>
a8223e
+
a8223e
+extern volatile int var;
a8223e
+
a8223e
+int func0 (void) __attribute__((__noinline__));
a8223e
+int func0 (void)
a8223e
+{
a8223e
+  abort ();
a8223e
+  return var;
a8223e
+}
a8223e
+
a8223e
+int func1 (void) __attribute__((__noinline__));
a8223e
+int func1 (void)
a8223e
+{
a8223e
+  return func0 () + var;
a8223e
+}
a8223e
+
a8223e
+*/
a8223e
diff --git a/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c
a8223e
new file mode 100644
a8223e
--- /dev/null
a8223e
+++ b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.c
a8223e
@@ -0,0 +1,29 @@
a8223e
+/* This testcase is part of GDB, the GNU debugger.
a8223e
+
a8223e
+   Copyright 2007 Free Software Foundation, Inc.
a8223e
+
a8223e
+   This program is free software; you can redistribute it and/or modify
a8223e
+   it under the terms of the GNU General Public License as published by
a8223e
+   the Free Software Foundation; either version 2 of the License, or
a8223e
+   (at your option) any later version.
a8223e
+
a8223e
+   This program is distributed in the hope that it will be useful,
a8223e
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a8223e
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a8223e
+   GNU General Public License for more details.
a8223e
+
a8223e
+   You should have received a copy of the GNU General Public License
a8223e
+   along with this program; if not, write to the Free Software
a8223e
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
a8223e
+
a8223e
+/* Force `-fpie' double jump bl->blrl.  */
a8223e
+/* No longer used.  */
a8223e
+volatile int var;
a8223e
+
a8223e
+extern int func1 (void);
a8223e
+
a8223e
+int main (void)
a8223e
+{
a8223e
+  func1 ();
a8223e
+  return 0;
a8223e
+}
a8223e
diff --git a/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp
a8223e
new file mode 100644
a8223e
--- /dev/null
a8223e
+++ b/gdb/testsuite/gdb.arch/powerpc-bcl-prologue.exp
a8223e
@@ -0,0 +1,72 @@
a8223e
+#   Copyright 2006, 2007 Free Software Foundation, Inc.
a8223e
+
a8223e
+# This program is free software; you can redistribute it and/or modify
a8223e
+# it under the terms of the GNU General Public License as published by
a8223e
+# the Free Software Foundation; either version 2 of the License, or
a8223e
+# (at your option) any later version.
a8223e
+#
a8223e
+# This program is distributed in the hope that it will be useful,
a8223e
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
a8223e
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a8223e
+# GNU General Public License for more details.
a8223e
+#
a8223e
+# You should have received a copy of the GNU General Public License
a8223e
+# along with this program; if not, write to the Free Software
a8223e
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
a8223e
+
a8223e
+# Test unwinding fixes of the PPC platform, specifically on the coping with BCL
a8223e
+# jump of the PIE code.
a8223e
+
a8223e
+if ![istarget "powerpc*-*-linux*"] then {
a8223e
+    verbose "Skipping powerpc-linux prologue tests."
a8223e
+    return
a8223e
+}
a8223e
+
a8223e
+set testfile "powerpc-bcl-prologue"
a8223e
+set srcfile1 ${testfile}.c
a8223e
+set flags "debug"
a8223e
+if [istarget "powerpc-*"] then {
a8223e
+    set srcfile2 ${testfile}-asm32.S
a8223e
+    set flags "$flags additional_flags=-m32"
a8223e
+} elseif [istarget "powerpc64-*"] then {
a8223e
+    set srcfile2 ${testfile}-asm64.S
a8223e
+    set flags "$flags additional_flags=-m64"
a8223e
+} else {
a8223e
+   fail "powerpc arch test"
a8223e
+   return
a8223e
+}
a8223e
+set objfile2 [standard_output_file ${testfile}-asm.o]
a8223e
+set binfile [standard_output_file ${testfile}]
a8223e
+
a8223e
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${srcdir}/${subdir}/${srcfile2}" ${binfile} executable $flags] != ""} {
a8223e
+    return -1
a8223e
+}
a8223e
+
a8223e
+gdb_exit
a8223e
+gdb_start
a8223e
+gdb_reinitialize_dir $srcdir/$subdir
a8223e
+gdb_load ${binfile}
a8223e
+
a8223e
+# We should stop in abort(3).
a8223e
+
a8223e
+gdb_run_cmd
a8223e
+
a8223e
+gdb_test_multiple {} "continue to abort()" {
a8223e
+    -re ".*Program received signal SIGABRT,.*$gdb_prompt $" {
a8223e
+       pass "continue to abort()"
a8223e
+    }
a8223e
+}
a8223e
+
a8223e
+# Check backtrace:
a8223e
+# #3  0x0804835f in func0 ()
a8223e
+# #4  0x0804836a in func1 ()
a8223e
+# #5  0x0804838c in main ()
a8223e
+# (gdb)
a8223e
+# `\\.?' prefixes are needed for ppc64 without `debug' (another bug).
a8223e
+
a8223e
+set test "matching unwind"
a8223e
+gdb_test_multiple "backtrace" $test {
a8223e
+    -re "\r\n#\[0-9\]\[^\r\n\]* in \\.?func0 \\(\[^\r\n\]*\r\n#\[0-9\]\[^\r\n\]* in \\.?func1 \\(\[^\r\n\]*\r\n#\[0-9\]\[^\r\n\]* in \\.?main \\(\[^\r\n\]*\r\n$gdb_prompt $" {
a8223e
+	pass $test
a8223e
+    }
a8223e
+}
a8223e
diff --git a/gdb/testsuite/gdb.arch/powerpc-prologue.exp b/gdb/testsuite/gdb.arch/powerpc-prologue.exp
a8223e
--- a/gdb/testsuite/gdb.arch/powerpc-prologue.exp
a8223e
+++ b/gdb/testsuite/gdb.arch/powerpc-prologue.exp
a8223e
@@ -16,8 +16,9 @@
a8223e
 # Test PowerPC prologue analyzer.
a8223e
 
a8223e
 # Do not run on AIX (where we won't be able to build the tests without
a8223e
-# some surgery) or on PowerPC64 (ditto, dot symbols).
a8223e
-if {[istarget *-*-aix*] || ![istarget "powerpc-*-*"]} then {
a8223e
+# some surgery).  PowerPC64 target would break due to dot symbols but we build
a8223e
+# there PowerPC32 inferior.
a8223e
+if {[istarget *-*-aix*] || ![istarget "powerpc*-*-*"]} then {
a8223e
     verbose "Skipping PowerPC prologue tests."
a8223e
     return
a8223e
 }