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

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