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

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