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

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