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

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