From 3071876327c5a177f46762b6f932e3ad69cdaa11 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Mon, 28 May 2012 17:16:39 +0200 Subject: [PATCH] Workaround PR libc/14166 for inferior calls of strstr. --- gdb-glibc-strstr-workaround.patch | 137 ++++++++++++++++++++++++++++++ gdb.spec | 9 +- 2 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 gdb-glibc-strstr-workaround.patch diff --git a/gdb-glibc-strstr-workaround.patch b/gdb-glibc-strstr-workaround.patch new file mode 100644 index 0000000..308b359 --- /dev/null +++ b/gdb-glibc-strstr-workaround.patch @@ -0,0 +1,137 @@ +diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c +index 53100c5..e7586ac 100644 +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -13306,6 +13306,25 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu, + /* Cache this symbol's name and the name's demangled form (if any). */ + SYMBOL_SET_LANGUAGE (sym, cu->language); + linkagename = dwarf2_physname (name, die, cu); ++ ++ /* Workaround for: ++ * invalid IFUNC DW_AT_linkage_name: memmove strstr time ++ * http://sourceware.org/bugzilla/show_bug.cgi?id=14166 */ ++ if (strcmp (linkagename, "strstr") == 0 ++ && strstr (objfile->name, "/libc") != NULL) ++ { ++ struct objfile *objfile_msym; ++ struct minimal_symbol *msym; ++ ++ if (objfile->separate_debug_objfile_backlink) ++ objfile_msym = objfile->separate_debug_objfile_backlink; ++ else ++ objfile_msym = objfile; ++ msym = lookup_minimal_symbol ("strstr", NULL, objfile_msym); ++ if (msym && MSYMBOL_TYPE (msym) == mst_text_gnu_ifunc) ++ linkagename = "__strstr"; ++ } ++ + SYMBOL_SET_NAMES (sym, linkagename, strlen (linkagename), 0, objfile); + + /* Fortran does not have mangling standard and the mangling does differ +diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp +new file mode 100644 +index 0000000..575071f +--- /dev/null ++++ b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp +@@ -0,0 +1,101 @@ ++# Copyright (C) 2012 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# Workaround for: ++# invalid IFUNC DW_AT_linkage_name: memmove strstr time ++# http://sourceware.org/bugzilla/show_bug.cgi?id=14166 ++ ++if {[skip_shlib_tests]} { ++ return 0 ++} ++ ++set testfile "gnu-ifunc-strstr-workaround" ++set executable ${testfile} ++set srcfile start.c ++set binfile ${objdir}/${subdir}/${executable} ++ ++if [prepare_for_testing ${testfile}.exp $executable $srcfile] { ++ return -1 ++} ++ ++if ![runto_main] { ++ return 0 ++} ++ ++set test "ptype atoi" ++gdb_test_multiple $test $test { ++ -re "type = int \\(const char \\*\\)\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "type = int \\(\\)\r\n$gdb_prompt $" { ++ untested "$test (no DWARF)" ++ return 0 ++ } ++} ++ ++set addr "" ++set test "print strstr" ++gdb_test_multiple $test $test { ++ -re " = {} (0x\[0-9a-f\]+) \r\n$gdb_prompt $" { ++ set addr $expect_out(1,string) ++ pass $test ++ } ++ -re " = {} (0x\[0-9a-f\]+) <__strstr>\r\n$gdb_prompt $" { ++ set addr $expect_out(1,string) ++ pass "$test (GDB workaround or future fixed glibc)" ++ } ++ -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ \r\n$gdb_prompt $" { ++ untested "$test (gnu-ifunc not in use by glibc)" ++ return 0 ++ } ++} ++ ++set test "info sym" ++gdb_test_multiple "info sym $addr" $test { ++ -re "strstr in section \\.text of /lib\[^/\]*/libc.so.6\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ \r\n$gdb_prompt $" { ++ # unexpected ++ xfail "$test (not in libc.so.6)" ++ return 0 ++ } ++} ++ ++set test "info addr strstr" ++gdb_test_multiple $test $test { ++ -re "Symbol \"strstr\" is a function at address $addr\\.\r\n$gdb_prompt $" { ++ fail "$test (DWARF for strstr)" ++ } ++ -re "Symbol \"strstr\" is at $addr in a file compiled without debugging\\.\r\n$gdb_prompt $" { ++ pass "$test" ++ } ++} ++ ++set test "print strstr second time" ++gdb_test_multiple "print strstr" $test { ++ -re " = {} $addr \r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re " = {} $addr <__strstr>\r\n$gdb_prompt $" { ++ pass "$test (GDB workaround or future fixed glibc)" ++ } ++ -re " = {void \\*\\(void\\)} 0x\[0-9a-f\]+ \r\n$gdb_prompt $" { ++ fail $test ++ } ++} ++ ++gdb_test {print strstr("abc","b")} { = 0x[0-9a-f]+ "bc"} ++gdb_test {print strstr("def","e")} { = 0x[0-9a-f]+ "ef"} diff --git a/gdb.spec b/gdb.spec index 2e1b1a1..02cd575 100644 --- a/gdb.spec +++ b/gdb.spec @@ -35,7 +35,7 @@ Version: 7.4.50.%{snap} # The release always contains a leading reserved number, start it at 1. # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing. -Release: 46%{?dist} +Release: 47%{?dist} License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain Group: Development/Debuggers @@ -619,6 +619,9 @@ Patch687: gdb-autoload-26of28.patch Patch688: gdb-autoload-27of28.patch Patch689: gdb-autoload-28of28.patch +# Workaround PR libc/14166 for inferior calls of strstr. +Patch690: gdb-glibc-strstr-workaround.patch + %if 0%{!?rhel:1} || 0%{?rhel} > 6 # RL_STATE_FEDORA_GDB would not be found for: # Patch642: gdb-readline62-ask-more-rh.patch @@ -937,6 +940,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch687 -p1 %patch688 -p1 %patch689 -p1 +%patch690 -p1 %patch393 -p1 %if 0%{!?el5:1} || 0%{?scl:1} @@ -1429,6 +1433,9 @@ fi %endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch" %changelog +* Mon May 28 2012 Jan Kratochvil - 7.4.50.20120120-47.fc17 +- Workaround PR libc/14166 for inferior calls of strstr. + * Mon May 14 2012 Jan Kratochvil - 7.4.50.20120120-46.fc17 - [RHEL5] Workaround doc build race.