From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17105 invoked by alias); 19 Mar 2014 08:31:57 -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 17076 invoked by uid 89); 19 Mar 2014 08:31:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mga09.intel.com Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Mar 2014 08:31:54 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 19 Mar 2014 01:27:18 -0700 X-ExtLoop1: 1 Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by orsmga002.jf.intel.com with ESMTP; 19 Mar 2014 01:31:34 -0700 Received: from irsmsx152.ger.corp.intel.com (163.33.192.66) by IRSMSX103.ger.corp.intel.com (163.33.3.157) with Microsoft SMTP Server (TLS) id 14.3.123.3; Wed, 19 Mar 2014 08:29:48 +0000 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.27]) by IRSMSX152.ger.corp.intel.com ([169.254.6.180]) with mapi id 14.03.0123.003; Wed, 19 Mar 2014 08:29:48 +0000 From: "Metzger, Markus T" To: Alan Modra , Pedro Alves CC: Mark Wielaard , Cary Coutant , "Doug Evans" , "gdb@sourceware.org" , "binutils@sourceware.org" Subject: RE: vdso handling Date: Wed, 19 Mar 2014 08:31:00 -0000 Message-ID: References: <20140313010147.GZ26922@bubble.grove.modra.org> <1394704336.11818.115.camel@bordewijk.wildebeest.org> <20140313130322.GA3384@bubble.grove.modra.org> <5321C7C8.6000707@redhat.com> <5321C8FA.40708@gmail.com> <5321CE1A.20509@redhat.com> <20140313235347.GD3384@bubble.grove.modra.org> <20140318230939.GA9145@bubble.grove.modra.org> In-Reply-To: <20140318230939.GA9145@bubble.grove.modra.org> 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/msg00052.txt.bz2 > -----Original Message----- > From: Alan Modra [mailto:amodra@gmail.com] > Sent: Wednesday, March 19, 2014 12:10 AM > > + /* Keep the section headers. */ > > + shdr_begin =3D i_ehdr.e_shoff; > > + shdr_end =3D shdr_begin + i_ehdr.e_shnum * i_ehdr.e_shentsize; > > + if (shdr_end > (bfd_vma) contents_size) > > + contents_size =3D shdr_end; > > + >=20 > I don't think this is a good idea. If/when bfd_from_remote_memory is > used for something other than the linux kernel vdso, we can't assume > the section headers are loaded. Shouldn't the ehdr indicate that there are no sections in this case? > The original code made the assumption > that the highest address loaded from a PT_LOAD header was rounded up > to a page, and that the page size could be inferred from p_align. > Here: > segment_end =3D (i_phdrs[i].p_offset + i_phdrs[i].p_filesz > + i_phdrs[i].p_align - 1) & -i_phdrs[i].p_align; > if (segment_end > (bfd_vma) contents_size) > contents_size =3D segment_end; >=20 > Now, p_align is generally set from the page size if using GNU ld, but > I'm wondering if your vdso somehow doesn't have that property. Can > you show us your vdso readelf -e output? If p_align isn't set to a > page, then the change in heuristic I envision is to make use of > elf_backend_data maxpagesize to figure out which parts of the image > might be loaded. If that isn't enough then perhaps we should add > another parameter to bfd_from_remote_memory to allow its caller to > specify the end of the image. I'm not sure the caller knows. GDB gets the base address from AUXV's AT_SYSINFO_EHDR. If we can't trust the image to contain everything that the ELF header describes, would it be safer to generate fake sections based on the program header? We already assume that the program header is contained in the image. Regards, 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