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

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