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

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