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

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