Blame SOURCES/gdb-glibc-strstr-workaround.patch

4416f5
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
4416f5
From: Fedora GDB patches <invalid@email.com>
4416f5
Date: Fri, 27 Oct 2017 21:07:50 +0200
4416f5
Subject: gdb-glibc-strstr-workaround.patch
4416f5
4416f5
;; Workaround PR libc/14166 for inferior calls of strstr.
4416f5
;;=fedoratest: Compatibility with RHELs (unchecked which ones).
4416f5
4416f5
diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp
4416f5
new file mode 100644
4416f5
--- /dev/null
4416f5
+++ b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp
4416f5
@@ -0,0 +1,119 @@
4416f5
+# Copyright (C) 2012 Free Software Foundation, Inc.
4416f5
+
4416f5
+# This program is free software; you can redistribute it and/or modify
4416f5
+# it under the terms of the GNU General Public License as published by
4416f5
+# the Free Software Foundation; either version 3 of the License, or
4416f5
+# (at your option) any later version.
4416f5
+#
4416f5
+# This program is distributed in the hope that it will be useful,
4416f5
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4416f5
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4416f5
+# GNU General Public License for more details.
4416f5
+#
4416f5
+# You should have received a copy of the GNU General Public License
4416f5
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4416f5
+
4416f5
+# Workaround for:
4416f5
+# invalid IFUNC DW_AT_linkage_name: memmove strstr time
4416f5
+# http://sourceware.org/bugzilla/show_bug.cgi?id=14166
4416f5
+
4416f5
+if {[skip_shlib_tests]} {
4416f5
+    return 0
4416f5
+}
4416f5
+
4416f5
+set testfile "gnu-ifunc-strstr-workaround"
4416f5
+set executable ${testfile}
4416f5
+set srcfile start.c
4416f5
+set binfile [standard_output_file ${executable}]
4416f5
+
4416f5
+if [prepare_for_testing ${testfile}.exp $executable $srcfile] {
4416f5
+    return -1
4416f5
+}
4416f5
+
4416f5
+if ![runto_main] {
4416f5
+    return 0
4416f5
+}
4416f5
+
4416f5
+set test "ptype atoi"
4416f5
+gdb_test_multiple $test $test {
4416f5
+    -re "type = int \\(const char \\*\\)\r\n$gdb_prompt $" {
4416f5
+	pass $test
4416f5
+    }
4416f5
+    -re "type = int \\(\\)\r\n$gdb_prompt $" {
4416f5
+	untested "$test (no DWARF)"
4416f5
+	return 0
4416f5
+    }
4416f5
+    -re "type = <unknown return type> \\(\\)\r\n$gdb_prompt $" {
4416f5
+	untested "$test (no DWARF)"
4416f5
+	return 0
4416f5
+    }
4416f5
+}
4416f5
+
4416f5
+set addr ""
4416f5
+set test "print strstr"
4416f5
+gdb_test_multiple $test $test {
4416f5
+    -re " = {<text gnu-indirect-function variable, no debug info>} (0x\[0-9a-f\]+) <strstr>\r\n$gdb_prompt $" {
4416f5
+	set addr $expect_out(1,string)
4416f5
+	pass $test
4416f5
+    }
4416f5
+    -re " = {<text gnu-indirect-function variable, no debug info>} (0x\[0-9a-f\]+) <__strstr>\r\n$gdb_prompt $" {
4416f5
+	set addr $expect_out(1,string)
4416f5
+	pass "$test (GDB workaround)"
4416f5
+    }
4416f5
+    -re " = {<text gnu-indirect-function variable, no debug info>} (0x\[0-9a-f\]+) <__libc_strstr>\r\n$gdb_prompt $" {
4416f5
+	set addr $expect_out(1,string)
4416f5
+	pass "$test (fixed glibc)"
4416f5
+    }
4416f5
+    -re " = {<text gnu-indirect-function variable, no debug info>} (0x\[0-9a-f\]+) <__libc_strstr_ifunc>\r\n$gdb_prompt $" {
4416f5
+	set addr $expect_out(1,string)
4416f5
+	pass "$test (fixed glibc)"
4416f5
+    }
4416f5
+    -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" {
4416f5
+	untested "$test (gnu-ifunc not in use by glibc)"
4416f5
+	return 0
4416f5
+    }
4416f5
+}
4416f5
+
4416f5
+set test "info sym"
4416f5
+gdb_test_multiple "info sym $addr" $test {
4416f5
+    -re "strstr in section \\.text of /lib\[^/\]*/libc.so.6\r\n$gdb_prompt $" {
4416f5
+	pass $test
4416f5
+    }
4416f5
+    -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" {
4416f5
+	# unexpected
4416f5
+	xfail "$test (not in libc.so.6)"
4416f5
+	return 0
4416f5
+    }
4416f5
+}
4416f5
+
4416f5
+set test "info addr strstr"
4416f5
+gdb_test_multiple $test $test {
4416f5
+    -re "Symbol \"strstr\" is a function at address $addr\\.\r\n$gdb_prompt $" {
4416f5
+	fail "$test (DWARF for strstr)"
4416f5
+    }
4416f5
+    -re "Symbol \"strstr\" is at $addr in a file compiled without debugging\\.\r\n$gdb_prompt $" {
4416f5
+	pass "$test"
4416f5
+    }
4416f5
+}
4416f5
+
4416f5
+set test "print strstr second time"
4416f5
+gdb_test_multiple "print strstr" $test {
4416f5
+    -re " = {<text gnu-indirect-function variable, no debug info>} $addr <strstr>\r\n$gdb_prompt $" {
4416f5
+	pass $test
4416f5
+    }
4416f5
+    -re " = {<text gnu-indirect-function variable, no debug info>} $addr <__strstr>\r\n$gdb_prompt $" {
4416f5
+	pass "$test (GDB workaround)"
4416f5
+    }
4416f5
+    -re " = {<text gnu-indirect-function variable, no debug info>} $addr <__libc_strstr>\r\n$gdb_prompt $" {
4416f5
+	pass "$test (fixed glibc)"
4416f5
+    }
4416f5
+    -re " = {<text gnu-indirect-function variable, no debug info>} $addr <__libc_strstr_ifunc>\r\n$gdb_prompt $" {
4416f5
+	pass "$test (fixed glibc)"
4416f5
+    }
4416f5
+    -re " = {void \\*\\(void\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" {
4416f5
+	fail $test
4416f5
+    }
4416f5
+}
4416f5
+
4416f5
+gdb_test {print (char *)strstr("abc","b")} { = 0x[0-9a-f]+ "bc"}
4416f5
+gdb_test {print (char *)strstr("def","e")} { = 0x[0-9a-f]+ "ef"}