public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* vdso handling
@ 2014-03-10 13:05 Metzger, Markus T
  2014-03-12  7:17 ` Alan Modra
  0 siblings, 1 reply; 41+ messages in thread
From: Metzger, Markus T @ 2014-03-10 13:05 UTC (permalink / raw)
  To: gdb, binutils

Hello,

My name is Markus.  I work for Intel on GDB in the area of
hardware-supported execution recording.

I noticed that the BFD created for the VDSO (system-provided in-memory
DSO) does not contain any BFD sections.  Is this intentional?  Or has
there just been no need for them?

If it just hasn't been done, yet, how would I best approach this?


Here's the problem I am trying to solve with this.  May as well be
that I'm on the wrong track...

When using the btrace record target, GDB only allows access to
read-only memory during replay.  The btrace record target does not
trace data so read-write memory corresponds to the end of the trace,
not the current replay position.

The implementation uses the same check that is also used for
'trust-readonly-sections", i.e.

	    section = target_section_by_addr (ops, offset);
	    if (section != NULL)
	      {
		/* Check if the section we found is readonly.  */
		if ((bfd_get_section_flags (section->the_bfd_section->owner,
					    section->the_bfd_section)
		     & SEC_READONLY) != 0)

For the vdso, there is no target section, so the check fails.  This
prevents GDB from disassembling vdso instructions during replay.


The vdso is processed in symbol_file_add_from_memory at
gdb/symfile-mem.c:84.  It calls bfd_from_remote_memory to create a BFD
for the vdso and then processes it.  If there were BFD sections, the
following small patch should add the respective target sections to GDB.

diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c
index e3230de..cf4da38 100644
--- a/gdb/symfile-mem.c
+++ b/gdb/symfile-mem.c
@@ -91,6 +91,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name,
   struct section_addr_info *sai;
   unsigned int i;
   struct cleanup *cleanup;
+  struct target_section *sections, *sections_end, *tsec;

   if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
     error (_("add-symbol-file-from-memory not supported for this target"));
@@ -113,6 +114,22 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name,
     error (_("Got object file from memory but can't read symbols: %s."),
	   bfd_errmsg (bfd_get_error ()));

+  /* Add target sections for this bfd.  */
+  sections = NULL;
+  sections_end = NULL;
+  if (build_section_table (nbfd, &sections, &sections_end))
+    error (_("Failed to build section table"));
+
+  /* Adjust the target section addresses by the load address.  */
+  for (tsec = sections; tsec != sections_end; ++tsec)
+    {
+      tsec->addr += loadbase;
+      tsec->endaddr += loadbase;
+    }
+
+  add_target_sections (&nbfd, sections, sections_end);
+  xfree (sections);
+
   sai = alloc_section_addr_info (bfd_count_sections (nbfd));
   make_cleanup (xfree, sai);
   i = 0;


This should allow me to pass the above read-only section check and
allow GDB to disassemble vdso instructions.

thanks,
markus.


Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2014-06-06 12:45 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-10 13:05 vdso handling Metzger, Markus T
2014-03-12  7:17 ` Alan Modra
2014-03-12 11:31   ` Mike Frysinger
2014-03-12 17:34   ` Doug Evans
2014-03-12 20:23     ` Cary Coutant
2014-03-13  1:01       ` Alan Modra
2014-03-13  8:25         ` Metzger, Markus T
2014-03-13  9:48           ` Metzger, Markus T
2014-03-13 10:07           ` Pedro Alves
2014-03-13 10:46             ` Pedro Alves
2014-06-01 23:45               ` Samuel Bronson
2014-06-06 12:45                 ` Pedro Alves
2014-03-13 13:13             ` Alan Modra
2014-03-13  9:52         ` Mark Wielaard
2014-03-13 13:03           ` Alan Modra
2014-03-13 14:38             ` Mark Wielaard
2014-03-13 14:59             ` Pedro Alves
2014-03-13 15:04               ` Pedro Alves
2014-03-13 15:26                 ` Pedro Alves
2014-03-13 23:53                   ` Alan Modra
2014-03-18 15:14                     ` Metzger, Markus T
2014-03-18 23:10                       ` Alan Modra
2014-03-19  8:11                         ` Metzger, Markus T
2014-03-19  8:31                         ` Metzger, Markus T
2014-03-19 12:04                           ` Pedro Alves
2014-03-20  2:00                           ` Alan Modra
2014-03-21 15:55                             ` Pedro Alves
2014-03-26  9:32                               ` Metzger, Markus T
2014-03-19 12:03                         ` Pedro Alves
2014-03-20  1:33                           ` Alan Modra
2014-03-21  8:10                             ` Metzger, Markus T
2014-03-21 15:48                             ` Pedro Alves
2014-03-28  6:13                               ` Alan Modra
2014-03-28 13:38                                 ` Pedro Alves
2014-03-28 23:00                                   ` Alan Modra
2014-04-01 13:46                                     ` Pedro Alves
2014-04-02  1:50                                       ` Alan Modra
2014-04-02  8:05                                         ` Metzger, Markus T
2014-04-02  8:04                                 ` Hans-Peter Nilsson
2014-04-03  1:06                                   ` Alan Modra
2014-04-03  1:46                                     ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).