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

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