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

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