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