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

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