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

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