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

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