This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: vdso handling
- From: "Metzger, Markus T" <markus dot t dot metzger at intel dot com>
- To: Alan Modra <amodra at gmail dot com>, Pedro Alves <palves at redhat dot com>
- Cc: Mark Wielaard <mjw at redhat dot com>, Cary Coutant <ccoutant at google dot com>, "Doug Evans" <dje at google dot com>, "gdb at sourceware dot org" <gdb at sourceware dot org>, "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Wed, 19 Mar 2014 08:29:47 +0000
- Subject: RE: vdso handling
- Authentication-results: sourceware.org; auth=none
- References: <CADPb22SAmK5JB3muW_nCvuHN5L-aOcdyzYNR+OtnM3bA1x_OJg at mail dot gmail dot com> <CAHACq4o=HmdCo1FPFL-96raf2UN805jvM=VZM-9dbKrmzJFJTw at mail dot gmail dot com> <20140313010147 dot GZ26922 at bubble dot grove dot modra dot org> <1394704336 dot 11818 dot 115 dot camel at bordewijk dot wildebeest dot org> <20140313130322 dot GA3384 at bubble dot grove dot modra dot org> <5321C7C8 dot 6000707 at redhat dot com> <5321C8FA dot 40708 at gmail dot com> <5321CE1A dot 20509 at redhat dot com> <20140313235347 dot GD3384 at bubble dot grove dot modra dot org> <A78C989F6D9628469189715575E55B230AAB6B17 at IRSMSX103 dot ger dot corp dot intel dot com> <20140318230939 dot GA9145 at bubble dot grove dot modra dot org>
> -----Original Message-----
> From: Alan Modra [mailto:amodra@gmail.com]
> Sent: Wednesday, March 19, 2014 12:10 AM
> > + /* Keep the section headers. */
> > + shdr_begin = i_ehdr.e_shoff;
> > + shdr_end = shdr_begin + i_ehdr.e_shnum * i_ehdr.e_shentsize;
> > + if (shdr_end > (bfd_vma) contents_size)
> > + contents_size = shdr_end;
> > +
>
> 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 = (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 = segment_end;
>
> 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