From: "Metzger, Markus T" <markus.t.metzger@intel.com>
To: "gdb@sourceware.org" <gdb@sourceware.org>,
"binutils@sourceware.org" <binutils@sourceware.org>
Subject: vdso handling
Date: Mon, 10 Mar 2014 13:05:00 -0000 [thread overview]
Message-ID: <A78C989F6D9628469189715575E55B230AA884EB@IRSMSX104.ger.corp.intel.com> (raw)
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, §ions, §ions_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
next reply other threads:[~2014-03-10 13:05 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-10 13:05 Metzger, Markus T [this message]
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 20:32 ` 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
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=A78C989F6D9628469189715575E55B230AA884EB@IRSMSX104.ger.corp.intel.com \
--to=markus.t.metzger@intel.com \
--cc=binutils@sourceware.org \
--cc=gdb@sourceware.org \
/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