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

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