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

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