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

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