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

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