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

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