This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch+7.5.1] Work around PR libc/13097 "linux-vdso.so.1" #3


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
+    }
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]