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

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