From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31167 invoked by alias); 25 Nov 2012 18:15:32 -0000 Received: (qmail 31152 invoked by uid 22791); 25 Nov 2012 18:15:30 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ,TW_YM X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 25 Nov 2012 18:15:18 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qAPIFHJj003483 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 25 Nov 2012 13:15:17 -0500 Received: from host2.jankratochvil.net (ovpn-116-39.ams2.redhat.com [10.36.116.39]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qAPIF6Qk028971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Sun, 25 Nov 2012 13:15:12 -0500 Date: Sun, 25 Nov 2012 18:15:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: "H.J. Lu" , gdb-patches@sourceware.org Subject: Re: [patch+7.5.1] Work around PR libc/13097 "linux-vdso.so.1" #3 Message-ID: <20121125181505.GA26194@host2.jankratochvil.net> References: <20121122201737.GA32172@host2.jankratochvil.net> <50AFBE11.2050908@redhat.com> <20121123184322.GA30659@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121123184322.GA30659@host2.jankratochvil.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-11/txt/msg00636.txt.bz2 On Fri, 23 Nov 2012 19:43:22 +0100, Jan Kratochvil wrote: > On Fri, 23 Nov 2012 19:18:57 +0100, Pedro Alves wrote: > > It's found in AT_SYSINFO_EHDR too. > > > > Alternatively to hard coding the names, maybe we could match the vdso address > > found through that with the addresses found iterating the dynamic linker list, to > > know which dynamic linker entry is the vdso. > > THis is how elfutils does it. Implemented below. But now it discards any shared libraries which match a symbol file loaded via add-symbol-file-from-memory. Which may be OK but it is more widespread change than before. Otherwise there are some configuration/interface difficulties, symfile-mem.c is not present in every configuration so duplicating its check of target_auxv_search (AT_SYSINFO_EHDR) in solib-svr4.c may not be correct. But otherwise the symbol file added via add_vsyscall_page cannot be differentiated later from those added by add-symbol-file-from-memory. To reduce the change impact some new field / method / interface would have to be added to communicate with symfile-mem.c with solib-svr4.c As is I do not recommend it for 7.5.x. > But there can be multiple vDSOs I think while > AT_SYSINFO_EHDR is only one so I have to check that. There is [vdso] which is listed in _r_debug.r_map and handled above. There is also [vsyscall] but this page does not have ELF format (and therefore obviously it is also not listed in _r_debug.r_map). 0: 48 c7 c0 60 00 00 00 mov $0x60,%rax 7: 0f 05 syscall 9: c3 retq a: cc int3 [...] 400: 48 c7 c0 c9 00 00 00 mov $0xc9,%rax 407: 0f 05 syscall 409: c3 retq 40a: cc int3 [...] 800: 48 c7 c0 35 01 00 00 mov $0x135,%rax 807: 0f 05 syscall 809: c3 retq 80a: cc int3 [...] fff: cc int3 Jan gdb/ 2012-11-25 Jan Kratochvil PR 14466 * solib-svr4.c (svr4_read_so_list): Rename to ... (svr4_current_sos_1): ... here and change the function comment. (svr4_current_sos): New function. gdb/testsuite/ 2012-11-25 Jan Kratochvil PR 14466 * gdb.base/vdso-warning.c: New file. * gdb.base/vdso-warning.exp: New file. diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 37cc654..77f4adc 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1248,10 +1248,10 @@ svr4_read_so_list (CORE_ADDR lm, struct so_list ***link_ptr_ptr, } } -/* Implement the "current_sos" target_so_ops method. */ +/* Implement the main part of the "current_sos" target_so_ops method. */ static struct so_list * -svr4_current_sos (void) +svr4_current_sos_1 (void) { CORE_ADDR lm; struct so_list *head = NULL; @@ -1322,6 +1322,52 @@ svr4_current_sos (void) return head; } +/* Filter out vDSO module, if present. Its symbol file would not be + found on disk. Such OBJFILE would come from add_vsyscall_page. */ + +static struct so_list * +svr4_current_sos (void) +{ + struct so_list *so_head = svr4_current_sos_1 (); + struct objfile *objfile; + struct obj_section *osect; + + ALL_OBJSECTIONS (objfile, osect) + { + const bfd *abfd = objfile->obfd; + const struct bfd_section *sect; + const char *name; + CORE_ADDR sect_vma; + struct so_list **sop; + + if ((bfd_get_file_flags (abfd) & BFD_IN_MEMORY) == 0) + continue; + + sect = osect->the_bfd_section; + name = bfd_get_section_name (abfd, sect); + if (name == NULL || strcmp (name, ".dynamic") != 0) + continue; + + sect_vma = (bfd_get_section_vma (abfd, sect) + + ANOFFSET (objfile->section_offsets, sect->index)); + sop = &so_head; + while (*sop) + { + struct so_list *so = *sop; + + if (so->lm_info->l_ld == sect_vma) + { + *sop = so->next; + free_so (so); + } + else + sop = &so->next; + } + } + + return so_head; +} + /* Get the address of the link_map for a given OBJFILE. */ CORE_ADDR diff --git a/gdb/testsuite/gdb.base/vdso-warning.c b/gdb/testsuite/gdb.base/vdso-warning.c new file mode 100644 index 0000000..ef89fef --- /dev/null +++ b/gdb/testsuite/gdb.base/vdso-warning.c @@ -0,0 +1,22 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 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 . */ + +int +main (void) +{ + return 0; +} diff --git a/gdb/testsuite/gdb.base/vdso-warning.exp b/gdb/testsuite/gdb.base/vdso-warning.exp new file mode 100644 index 0000000..506b376 --- /dev/null +++ b/gdb/testsuite/gdb.base/vdso-warning.exp @@ -0,0 +1,43 @@ +# Copyright 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 . + +standard_testfile + +# There's no support for passing environment variables in the remote protocol. +if { [is_remote target] } { + return 0 +} + +if { [prepare_for_testing ${testfile}.exp ${testfile} $srcfile] } { + return -1 +} + +gdb_breakpoint "main" + +# Fedora/RHEL glibc does not have this problem reproducible without this line. +# See PR libc/13097 Comment 2. +gdb_test_no_output "set environment LD_DEBUG=unused" + +gdb_run_cmd + +set test "stopped" +gdb_test_multiple "" $test { + -re "Could not load shared library symbols .*\r\n$gdb_prompt $" { + fail $test + } + -re "\r\nBreakpoint \[0-9\]+, main .*\r\n$gdb_prompt $" { + pass $test + } +}