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

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