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

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