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

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