Blame SOURCES/gdb-6.8-bz466901-backtrace-full-prelinked.patch

132741
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
132741
From: Fedora GDB patches <invalid@email.com>
132741
Date: Fri, 27 Oct 2017 21:07:50 +0200
132741
Subject: gdb-6.8-bz466901-backtrace-full-prelinked.patch
132741
132741
;; Fix resolving of variables at locations lists in prelinked libs (BZ 466901).
132741
;;=fedoratest
132741
132741
Fix resolving of variables at locations lists in prelinked libs (BZ 466901).
132741
132741
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-func.S b/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-func.S
132741
new file mode 100644
132741
--- /dev/null
132741
+++ b/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-func.S
132741
@@ -0,0 +1,328 @@
132741
+/* This testcase is part of GDB, the GNU debugger.
132741
+
132741
+   Copyright 2008 Free Software Foundation, Inc.
132741
+
132741
+   This program is free software; you can redistribute it and/or modify
132741
+   it under the terms of the GNU General Public License as published by
132741
+   the Free Software Foundation; either version 3 of the License, or
132741
+   (at your option) any later version.
132741
+
132741
+   This program is distributed in the hope that it will be useful,
132741
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
132741
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
132741
+   GNU General Public License for more details.
132741
+
132741
+   You should have received a copy of the GNU General Public License
132741
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
132741
+
132741
+/*
132741
+#include <stdlib.h>
132741
+
132741
+void
132741
+func (void)
132741
+{
132741
+  int i;
132741
+
132741
+  abort ();
132741
+}
132741
+*/
132741
+	.file	"dw2-loclist-prelinked.c"
132741
+	.section	.debug_abbrev,"",@progbits
132741
+.Ldebug_abbrev0:
132741
+	.section	.debug_info,"",@progbits
132741
+.Ldebug_info0:
132741
+	.section	.debug_line,"",@progbits
132741
+.Ldebug_line0:
132741
+	.text
132741
+.Ltext0:
132741
+.globl func
132741
+	.type	func, @function
132741
+func:
132741
+.LFB2:
132741
+	.file 1 "dw2-loclist-prelinked.c"
132741
+	.loc 1 5 0
132741
+	pushl	%ebp
132741
+.LCFI0:
132741
+	movl	%esp, %ebp
132741
+.LCFI1:
132741
+	subl	$24, %esp
132741
+.LCFI2:
132741
+	.loc 1 8 0
132741
+	call	abort
132741
+.LFE2:
132741
+	.size	func, .-func
132741
+	.section	.debug_frame,"",@progbits
132741
+.Lframe0:
132741
+	.long	.LECIE0-.LSCIE0
132741
+.LSCIE0:
132741
+	.long	0xffffffff
132741
+	.byte	0x1
132741
+	.string	""
132741
+	.uleb128 0x1
132741
+	.sleb128 -4
132741
+	.byte	0x8
132741
+	.byte	0xc
132741
+	.uleb128 0x4
132741
+	.uleb128 0x4
132741
+	.byte	0x88
132741
+	.uleb128 0x1
132741
+	.align 4
132741
+.LECIE0:
132741
+.LSFDE0:
132741
+	.long	.LEFDE0-.LASFDE0
132741
+.LASFDE0:
132741
+	.long	.Lframe0
132741
+	.long	.LFB2
132741
+	.long	.LFE2-.LFB2
132741
+	.byte	0x4
132741
+	.long	.LCFI0-.LFB2
132741
+	.byte	0xe
132741
+	.uleb128 0x8
132741
+	.byte	0x85
132741
+	.uleb128 0x2
132741
+	.byte	0x4
132741
+	.long	.LCFI1-.LCFI0
132741
+	.byte	0xd
132741
+	.uleb128 0x5
132741
+	.align 4
132741
+.LEFDE0:
132741
+	.text
132741
+.Letext0:
132741
+	.section	.debug_loc,"",@progbits
132741
+.Ldebug_loc0:
132741
+.LLST0:
132741
+	.long	.LFB2-.Ltext0
132741
+	.long	.LCFI0-.Ltext0
132741
+	.value	0x2
132741
+	.byte	0x74
132741
+	.sleb128 4
132741
+	.long	.LCFI0-.Ltext0
132741
+	.long	.LCFI1-.Ltext0
132741
+	.value	0x2
132741
+	.byte	0x74
132741
+	.sleb128 8
132741
+	.long	.LCFI1-.Ltext0
132741
+	.long	.LFE2-.Ltext0
132741
+	.value	0x2
132741
+	.byte	0x75
132741
+	.sleb128 8
132741
+	.long	0x0
132741
+	.long	0x0
132741
+	.section	.debug_info
132741
+	.long	0x94
132741
+	.value	0x2
132741
+	.long	.Ldebug_abbrev0
132741
+	.byte	0x4
132741
+	.uleb128 0x1
132741
+	.long	.LASF10
132741
+	.byte	0x1
132741
+	.long	.LASF11
132741
+	.long	.LASF12
132741
+	.long	.Ltext0
132741
+	.long	.Letext0
132741
+	.long	.Ldebug_line0
132741
+	.uleb128 0x2
132741
+	.byte	0x4
132741
+	.byte	0x7
132741
+	.long	.LASF0
132741
+	.uleb128 0x3
132741
+	.byte	0x4
132741
+	.byte	0x5
132741
+	.string	"int"
132741
+	.uleb128 0x2
132741
+	.byte	0x4
132741
+	.byte	0x5
132741
+	.long	.LASF1
132741
+	.uleb128 0x2
132741
+	.byte	0x1
132741
+	.byte	0x8
132741
+	.long	.LASF2
132741
+	.uleb128 0x2
132741
+	.byte	0x2
132741
+	.byte	0x7
132741
+	.long	.LASF3
132741
+	.uleb128 0x2
132741
+	.byte	0x4
132741
+	.byte	0x7
132741
+	.long	.LASF4
132741
+	.uleb128 0x2
132741
+	.byte	0x1
132741
+	.byte	0x6
132741
+	.long	.LASF5
132741
+	.uleb128 0x2
132741
+	.byte	0x2
132741
+	.byte	0x5
132741
+	.long	.LASF6
132741
+	.uleb128 0x2
132741
+	.byte	0x8
132741
+	.byte	0x5
132741
+	.long	.LASF7
132741
+	.uleb128 0x2
132741
+	.byte	0x8
132741
+	.byte	0x7
132741
+	.long	.LASF8
132741
+	.uleb128 0x4
132741
+	.byte	0x4
132741
+	.byte	0x7
132741
+	.uleb128 0x2
132741
+	.byte	0x1
132741
+	.byte	0x6
132741
+	.long	.LASF9
132741
+	.uleb128 0x5
132741
+	.byte	0x1
132741
+	.long	.LASF13
132741
+	.byte	0x1
132741
+	.byte	0x5
132741
+	.byte	0x1
132741
+	.long	.LFB2
132741
+	.long	.LFE2
132741
+	.long	.LLST0
132741
+	.uleb128 0x6
132741
+	.string	"i"
132741
+	.byte	0x1
132741
+	.byte	0x6
132741
+	.long	0x2c
132741
+	.byte	0x2
132741
+	.byte	0x91
132741
+	.sleb128 -12
132741
+	.byte	0x0
132741
+	.byte	0x0
132741
+	.section	.debug_abbrev
132741
+	.uleb128 0x1
132741
+	.uleb128 0x11
132741
+	.byte	0x1
132741
+	.uleb128 0x25
132741
+	.uleb128 0xe
132741
+	.uleb128 0x13
132741
+	.uleb128 0xb
132741
+	.uleb128 0x3
132741
+	.uleb128 0xe
132741
+	.uleb128 0x1b
132741
+	.uleb128 0xe
132741
+	.uleb128 0x11
132741
+	.uleb128 0x1
132741
+	.uleb128 0x12
132741
+	.uleb128 0x1
132741
+	.uleb128 0x10
132741
+	.uleb128 0x6
132741
+	.byte	0x0
132741
+	.byte	0x0
132741
+	.uleb128 0x2
132741
+	.uleb128 0x24
132741
+	.byte	0x0
132741
+	.uleb128 0xb
132741
+	.uleb128 0xb
132741
+	.uleb128 0x3e
132741
+	.uleb128 0xb
132741
+	.uleb128 0x3
132741
+	.uleb128 0xe
132741
+	.byte	0x0
132741
+	.byte	0x0
132741
+	.uleb128 0x3
132741
+	.uleb128 0x24
132741
+	.byte	0x0
132741
+	.uleb128 0xb
132741
+	.uleb128 0xb
132741
+	.uleb128 0x3e
132741
+	.uleb128 0xb
132741
+	.uleb128 0x3
132741
+	.uleb128 0x8
132741
+	.byte	0x0
132741
+	.byte	0x0
132741
+	.uleb128 0x4
132741
+	.uleb128 0x24
132741
+	.byte	0x0
132741
+	.uleb128 0xb
132741
+	.uleb128 0xb
132741
+	.uleb128 0x3e
132741
+	.uleb128 0xb
132741
+	.byte	0x0
132741
+	.byte	0x0
132741
+	.uleb128 0x5
132741
+	.uleb128 0x2e
132741
+	.byte	0x1
132741
+	.uleb128 0x3f
132741
+	.uleb128 0xc
132741
+	.uleb128 0x3
132741
+	.uleb128 0xe
132741
+	.uleb128 0x3a
132741
+	.uleb128 0xb
132741
+	.uleb128 0x3b
132741
+	.uleb128 0xb
132741
+	.uleb128 0x27
132741
+	.uleb128 0xc
132741
+	.uleb128 0x11
132741
+	.uleb128 0x1
132741
+	.uleb128 0x12
132741
+	.uleb128 0x1
132741
+	.uleb128 0x40
132741
+	.uleb128 0x6
132741
+	.byte	0x0
132741
+	.byte	0x0
132741
+	.uleb128 0x6
132741
+	.uleb128 0x34
132741
+	.byte	0x0
132741
+	.uleb128 0x3
132741
+	.uleb128 0x8
132741
+	.uleb128 0x3a
132741
+	.uleb128 0xb
132741
+	.uleb128 0x3b
132741
+	.uleb128 0xb
132741
+	.uleb128 0x49
132741
+	.uleb128 0x13
132741
+	.uleb128 0x2
132741
+	.uleb128 0xa
132741
+	.byte	0x0
132741
+	.byte	0x0
132741
+	.byte	0x0
132741
+	.section	.debug_pubnames,"",@progbits
132741
+	.long	0x17
132741
+	.value	0x2
132741
+	.long	.Ldebug_info0
132741
+	.long	0x98
132741
+	.long	0x75
132741
+	.string	"func"
132741
+	.long	0x0
132741
+	.section	.debug_aranges,"",@progbits
132741
+	.long	0x1c
132741
+	.value	0x2
132741
+	.long	.Ldebug_info0
132741
+	.byte	0x4
132741
+	.byte	0x0
132741
+	.value	0x0
132741
+	.value	0x0
132741
+	.long	.Ltext0
132741
+	.long	.Letext0-.Ltext0
132741
+	.long	0x0
132741
+	.long	0x0
132741
+	.section	.debug_str,"MS",@progbits,1
132741
+.LASF7:
132741
+	.string	"long long int"
132741
+.LASF0:
132741
+	.string	"unsigned int"
132741
+.LASF11:
132741
+	.string	"dw2-loclist-prelinked.c"
132741
+.LASF12:
132741
+	.string	"gdb-6.8/gdb/testsuite/gdb.dwarf2"
132741
+.LASF4:
132741
+	.string	"long unsigned int"
132741
+.LASF8:
132741
+	.string	"long long unsigned int"
132741
+.LASF2:
132741
+	.string	"unsigned char"
132741
+.LASF9:
132741
+	.string	"char"
132741
+.LASF1:
132741
+	.string	"long int"
132741
+.LASF3:
132741
+	.string	"short unsigned int"
132741
+.LASF5:
132741
+	.string	"signed char"
132741
+.LASF10:
132741
+	.string	"GNU C 4.3.2 20081007 (Red Hat 4.3.2-6)"
132741
+.LASF13:
132741
+	.string	"func"
132741
+.LASF6:
132741
+	.string	"short int"
132741
+	.ident	"GCC: (GNU) 4.3.2 20081007 (Red Hat 4.3.2-6)"
132741
+	.section	.note.GNU-stack,"",@progbits
132741
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c b/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c
132741
new file mode 100644
132741
--- /dev/null
132741
+++ b/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c
132741
@@ -0,0 +1,26 @@
132741
+/* This testcase is part of GDB, the GNU debugger.
132741
+
132741
+   Copyright 2008 Free Software Foundation, Inc.
132741
+
132741
+   This program is free software; you can redistribute it and/or modify
132741
+   it under the terms of the GNU General Public License as published by
132741
+   the Free Software Foundation; either version 3 of the License, or
132741
+   (at your option) any later version.
132741
+
132741
+   This program is distributed in the hope that it will be useful,
132741
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
132741
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
132741
+   GNU General Public License for more details.
132741
+
132741
+   You should have received a copy of the GNU General Public License
132741
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
132741
+
132741
+/* dw2-loclist-prelinked-func.S */
132741
+extern void func (void);
132741
+
132741
+int
132741
+main (void)
132741
+{
132741
+  func ();
132741
+  return 0;
132741
+}
132741
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked.exp b/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked.exp
132741
new file mode 100644
132741
--- /dev/null
132741
+++ b/gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked.exp
132741
@@ -0,0 +1,102 @@
132741
+# Copyright 2008 Free Software Foundation, Inc.
132741
+
132741
+# This program is free software; you can redistribute it and/or modify
132741
+# it under the terms of the GNU General Public License as published by
132741
+# the Free Software Foundation; either version 2 of the License, or
132741
+# (at your option) any later version.
132741
+#
132741
+# This program is distributed in the hope that it will be useful,
132741
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
132741
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
132741
+# GNU General Public License for more details.
132741
+#
132741
+# You should have received a copy of the GNU General Public License
132741
+# along with this program; if not, write to the Free Software
132741
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
132741
+
132741
+# Minimal DWARF-2 unit test
132741
+
132741
+# This test can only be run on i386/x86_64 targets which support DWARF-2.
132741
+# For now pick a sampling of likely targets.
132741
+if {(![istarget *-*-linux*]
132741
+     && ![istarget *-*-gnu*]
132741
+     && ![istarget *-*-elf*]
132741
+     && ![istarget *-*-openbsd*])
132741
+    || (![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"])} {
132741
+    return 0
132741
+}
132741
+
132741
+set testfile "dw2-loclist-prelinked"
132741
+set srcfuncfile ${testfile}-func.S
132741
+set binsharedfuncfile [standard_output_file ${testfile}.so]
132741
+set srcmainfile ${testfile}-main.c
132741
+set binfile [standard_output_file ${testfile}]
132741
+
132741
+remote_exec build "rm -f ${binfile}"
132741
+
132741
+# get the value of gcc_compiled
132741
+if [get_compiler_info ${binfile}] {
132741
+    return -1
132741
+}
132741
+
132741
+# This test can only be run on gcc as we use additional_flags=FIXME
132741
+if {$gcc_compiled == 0} {
132741
+    return 0
132741
+}
132741
+
132741
+if  { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfuncfile}" "${binsharedfuncfile}" {debug additional_flags=-m32}] != "" } {
132741
+    untested "Couldn't compile test library"
132741
+    return -1
132741
+}
132741
+
132741
+# The new separate debug info file will be stored in the .debug subdirectory.
132741
+
132741
+if [gdb_gnu_strip_debug ${binsharedfuncfile}] {
132741
+    # check that you have a recent version of strip and objcopy installed
132741
+    unsupported "cannot produce separate debug info files"
132741
+    return -1
132741
+}
132741
+
132741
+if {[catch "system \"/usr/sbin/prelink -qNR --no-exec-shield ${binsharedfuncfile}\""] != 0} {
132741
+    # Maybe we don't have prelink.
132741
+    return -1
132741
+}
132741
+
132741
+if  { [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" \
132741
+		   "${binfile}" executable [list debug additional_flags=-m32 shlib=${binsharedfuncfile}]] != "" } {
132741
+    return -1
132741
+}
132741
+
132741
+gdb_exit
132741
+gdb_start
132741
+gdb_reinitialize_dir $srcdir/$subdir
132741
+gdb_load ${binfile}
132741
+
132741
+gdb_run_cmd
132741
+
132741
+gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
132741
+
132741
+# Incorrect:
132741
+# #0  0x00110430 in __kernel_vsyscall ()
132741
+# No symbol table info available.
132741
+# #1  0x003d44c0 in raise () from /lib/libc.so.6
132741
+# No symbol table info available.
132741
+# #2  0x003d5e88 in abort () from /lib/libc.so.6
132741
+# No symbol table info available.
132741
+# #3  0x44f10437 in func () at dw2-loclist-prelinked.c:8
132741
+# 	i = Could not find the frame base for "func".
132741
+
132741
+# Correct:
132741
+# #0  0x00110430 in __kernel_vsyscall ()
132741
+# No symbol table info available.
132741
+# #1  0x003d44c0 in raise () from /lib/libc.so.6
132741
+# No symbol table info available.
132741
+# #2  0x003d5e88 in abort () from /lib/libc.so.6
132741
+# No symbol table info available.
132741
+# #3  0x4ae36437 in func () at dw2-loclist-prelinked.c:8
132741
+# 	i = 3827288
132741
+# #4  0x0804851a in main () at ../../../gdb/testsuite/gdb.dwarf2/dw2-loclist-prelinked-main.c:24
132741
+# No locals.
132741
+
132741
+# `abort' can get expressed as `*__GI_abort'.
132741
+gdb_test "bt full" "in \[^ \]*abort \\(.*in func \\(.*\r\n\[\t \]+i = -?\[0-9\].*in main \\(.*" "Backtrace after abort()"