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

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