Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: "H.J. Lu" <hjl.tools@gmail.com>, gdb-patches@sourceware.org
Subject: Re: [patch+7.5.1] Work around PR libc/13097 "linux-vdso.so.1" #3
Date: Sun, 25 Nov 2012 18:15:00 -0000	[thread overview]
Message-ID: <20121125181505.GA26194@host2.jankratochvil.net> (raw)
In-Reply-To: <20121123184322.GA30659@host2.jankratochvil.net>

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  <jan.kratochvil@redhat.com>

	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  <jan.kratochvil@redhat.com>

	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 <http://www.gnu.org/licenses/>.  */
+
+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 <http://www.gnu.org/licenses/>.
+
+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
+    }
+}


      reply	other threads:[~2012-11-25 18:15 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-22 20:17 Jan Kratochvil
2012-11-23 11:30 ` Luis Gustavo
2012-11-23 11:41   ` Jan Kratochvil
2012-11-23 11:59     ` Luis Machado
2012-11-23 12:03 ` Pedro Alves
2012-11-23 12:40   ` Jan Kratochvil
2012-11-23 14:05     ` Luis Machado
2012-11-23 14:07       ` Jan Kratochvil
2012-11-23 16:01     ` Pedro Alves
2012-11-23 16:12       ` Mark Kettenis
2012-11-23 16:17         ` Jan Kratochvil
2012-11-23 16:23         ` Pedro Alves
2012-11-23 17:28       ` Joel Brobecker
2012-11-23 18:17         ` Jan Kratochvil
2012-11-23 18:22           ` Pedro Alves
2012-11-27 21:58       ` Mike Frysinger
2012-11-27 23:00         ` Matt Rice
2012-11-28  1:12         ` Pedro Alves
2012-11-28 20:39           ` Mike Frysinger
2012-11-28 22:44           ` Jan Kratochvil
2012-11-29  1:07             ` Mike Frysinger
2012-11-23 12:43   ` Mark Kettenis
2012-11-23 16:30 ` H.J. Lu
2012-11-23 18:19   ` Pedro Alves
2012-11-23 18:43     ` Jan Kratochvil
2012-11-25 18:15       ` Jan Kratochvil [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121125181505.GA26194@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=hjl.tools@gmail.com \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox