From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 471 invoked by alias); 10 Mar 2014 13:05:04 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 437 invoked by uid 89); 10 Mar 2014 13:05:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_20,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mga14.intel.com Received: from mga14.intel.com (HELO mga14.intel.com) (143.182.124.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Mar 2014 13:05:01 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by azsmga102.ch.intel.com with ESMTP; 10 Mar 2014 06:04:58 -0700 X-ExtLoop1: 1 Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by fmsmga001.fm.intel.com with ESMTP; 10 Mar 2014 06:04:35 -0700 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.174]) by IRSMSX101.ger.corp.intel.com ([169.254.1.67]) with mapi id 14.03.0123.003; Mon, 10 Mar 2014 13:04:33 +0000 From: "Metzger, Markus T" To: "gdb@sourceware.org" , "binutils@sourceware.org" Subject: vdso handling Date: Mon, 10 Mar 2014 13:05:00 -0000 Message-ID: Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00012.txt.bz2 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 =3D target_section_by_addr (ops, offset); if (section !=3D 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) !=3D 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) !=3D 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_A= DDR 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 =3D NULL; + sections_end =3D 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 =3D sections; tsec !=3D sections_end; ++tsec) + { + tsec->addr +=3D loadbase; + tsec->endaddr +=3D loadbase; + } + + add_target_sections (&nbfd, sections, sections_end); + xfree (sections); + sai =3D alloc_section_addr_info (bfd_count_sections (nbfd)); make_cleanup (xfree, sai); i =3D 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