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

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