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

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