]>
Commit | Line | Data |
---|---|---|
a7de96f0 PS |
1 | diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c |
2 | index 53100c5..e7586ac 100644 | |
3 | --- a/gdb/dwarf2read.c | |
4 | +++ b/gdb/dwarf2read.c | |
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); | |
9 | + | |
10 | + /* Workaround for: | |
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) | |
15 | + { | |
16 | + struct objfile *objfile_msym; | |
17 | + struct minimal_symbol *msym; | |
18 | + | |
19 | + if (objfile->separate_debug_objfile_backlink) | |
20 | + objfile_msym = objfile->separate_debug_objfile_backlink; | |
21 | + else | |
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"; | |
26 | + } | |
27 | + | |
28 | SYMBOL_SET_NAMES (sym, linkagename, strlen (linkagename), 0, objfile); | |
29 | ||
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 | |
32 | new file mode 100644 | |
33 | index 0000000..575071f | |
34 | --- /dev/null | |
35 | +++ b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp | |
36 | @@ -0,0 +1,101 @@ | |
37 | +# Copyright (C) 2012 Free Software Foundation, Inc. | |
38 | + | |
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. | |
43 | +# | |
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. | |
48 | +# | |
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/>. | |
51 | + | |
52 | +# Workaround for: | |
53 | +# invalid IFUNC DW_AT_linkage_name: memmove strstr time | |
54 | +# http://sourceware.org/bugzilla/show_bug.cgi?id=14166 | |
55 | + | |
56 | +if {[skip_shlib_tests]} { | |
57 | + return 0 | |
58 | +} | |
59 | + | |
60 | +set testfile "gnu-ifunc-strstr-workaround" | |
61 | +set executable ${testfile} | |
62 | +set srcfile start.c | |
63 | +set binfile ${objdir}/${subdir}/${executable} | |
64 | + | |
65 | +if [prepare_for_testing ${testfile}.exp $executable $srcfile] { | |
66 | + return -1 | |
67 | +} | |
68 | + | |
69 | +if ![runto_main] { | |
70 | + return 0 | |
71 | +} | |
72 | + | |
73 | +set test "ptype atoi" | |
74 | +gdb_test_multiple $test $test { | |
75 | + -re "type = int \\(const char \\*\\)\r\n$gdb_prompt $" { | |
76 | + pass $test | |
77 | + } | |
78 | + -re "type = int \\(\\)\r\n$gdb_prompt $" { | |
79 | + untested "$test (no DWARF)" | |
80 | + return 0 | |
81 | + } | |
82 | +} | |
83 | + | |
84 | +set addr "" | |
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) | |
89 | + pass $test | |
90 | + } | |
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)" | |
94 | + } | |
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)" | |
97 | + return 0 | |
98 | + } | |
99 | +} | |
100 | + | |
101 | +set test "info sym" | |
102 | +gdb_test_multiple "info sym $addr" $test { | |
103 | + -re "strstr in section \\.text of /lib\[^/\]*/libc.so.6\r\n$gdb_prompt $" { | |
104 | + pass $test | |
105 | + } | |
106 | + -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" { | |
107 | + # unexpected | |
108 | + xfail "$test (not in libc.so.6)" | |
109 | + return 0 | |
110 | + } | |
111 | +} | |
112 | + | |
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)" | |
117 | + } | |
118 | + -re "Symbol \"strstr\" is at $addr in a file compiled without debugging\\.\r\n$gdb_prompt $" { | |
119 | + pass "$test" | |
120 | + } | |
121 | +} | |
122 | + | |
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 $" { | |
126 | + pass $test | |
127 | + } | |
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)" | |
130 | + } | |
131 | + -re " = {void \\*\\(void\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" { | |
132 | + fail $test | |
133 | + } | |
134 | +} | |
135 | + | |
136 | +gdb_test {print strstr("abc","b")} { = 0x[0-9a-f]+ "bc"} | |
137 | +gdb_test {print strstr("def","e")} { = 0x[0-9a-f]+ "ef"} |