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

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