1 diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
2 index 53100c5..e7586ac 100644
5 @@ -13306,6 +13306,25 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
6 /* Cache this symbol's name and the name's demangled form (if any). */
7 SYMBOL_SET_LANGUAGE (sym, cu->language);
8 linkagename = dwarf2_physname (name, die, cu);
11 + * invalid IFUNC DW_AT_linkage_name: memmove strstr time
12 + * http://sourceware.org/bugzilla/show_bug.cgi?id=14166 */
13 + if (strcmp (linkagename, "strstr") == 0
14 + && strstr (objfile->name, "/libc") != NULL)
16 + struct objfile *objfile_msym;
17 + struct minimal_symbol *msym;
19 + if (objfile->separate_debug_objfile_backlink)
20 + objfile_msym = objfile->separate_debug_objfile_backlink;
22 + objfile_msym = objfile;
23 + msym = lookup_minimal_symbol ("strstr", NULL, objfile_msym);
24 + if (msym && MSYMBOL_TYPE (msym) == mst_text_gnu_ifunc)
25 + linkagename = "__strstr";
28 SYMBOL_SET_NAMES (sym, linkagename, strlen (linkagename), 0, objfile);
30 /* Fortran does not have mangling standard and the mangling does differ
31 diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp
33 index 0000000..575071f
35 +++ b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp
37 +# Copyright (C) 2012 Free Software Foundation, Inc.
39 +# This program is free software; you can redistribute it and/or modify
40 +# it under the terms of the GNU General Public License as published by
41 +# the Free Software Foundation; either version 3 of the License, or
42 +# (at your option) any later version.
44 +# This program is distributed in the hope that it will be useful,
45 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
46 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47 +# GNU General Public License for more details.
49 +# You should have received a copy of the GNU General Public License
50 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
53 +# invalid IFUNC DW_AT_linkage_name: memmove strstr time
54 +# http://sourceware.org/bugzilla/show_bug.cgi?id=14166
56 +if {[skip_shlib_tests]} {
60 +set testfile "gnu-ifunc-strstr-workaround"
61 +set executable ${testfile}
63 +set binfile ${objdir}/${subdir}/${executable}
65 +if [prepare_for_testing ${testfile}.exp $executable $srcfile] {
73 +set test "ptype atoi"
74 +gdb_test_multiple $test $test {
75 + -re "type = int \\(const char \\*\\)\r\n$gdb_prompt $" {
78 + -re "type = int \\(\\)\r\n$gdb_prompt $" {
79 + untested "$test (no DWARF)"
85 +set test "print strstr"
86 +gdb_test_multiple $test $test {
87 + -re " = {<text gnu-indirect-function variable, no debug info>} (0x\[0-9a-f\]+) <strstr>\r\n$gdb_prompt $" {
88 + set addr $expect_out(1,string)
91 + -re " = {<text gnu-indirect-function variable, no debug info>} (0x\[0-9a-f\]+) <__strstr>\r\n$gdb_prompt $" {
92 + set addr $expect_out(1,string)
93 + pass "$test (GDB workaround or future fixed glibc)"
95 + -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" {
96 + untested "$test (gnu-ifunc not in use by glibc)"
102 +gdb_test_multiple "info sym $addr" $test {
103 + -re "strstr in section \\.text of /lib\[^/\]*/libc.so.6\r\n$gdb_prompt $" {
106 + -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" {
108 + xfail "$test (not in libc.so.6)"
113 +set test "info addr strstr"
114 +gdb_test_multiple $test $test {
115 + -re "Symbol \"strstr\" is a function at address $addr\\.\r\n$gdb_prompt $" {
116 + fail "$test (DWARF for strstr)"
118 + -re "Symbol \"strstr\" is at $addr in a file compiled without debugging\\.\r\n$gdb_prompt $" {
123 +set test "print strstr second time"
124 +gdb_test_multiple "print strstr" $test {
125 + -re " = {<text gnu-indirect-function variable, no debug info>} $addr <strstr>\r\n$gdb_prompt $" {
128 + -re " = {<text gnu-indirect-function variable, no debug info>} $addr <__strstr>\r\n$gdb_prompt $" {
129 + pass "$test (GDB workaround or future fixed glibc)"
131 + -re " = {void \\*\\(void\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" {
136 +gdb_test {print strstr("abc","b")} { = 0x[0-9a-f]+ "bc"}
137 +gdb_test {print strstr("def","e")} { = 0x[0-9a-f]+ "ef"}