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

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