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

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