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

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