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

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