This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] elf: Try not pointing empty PT_LOAD segment's offset past EOF
Hi Alan,
Bálint Réczey <balint@balintreczey.hu> ezt írta (időpont: 2019. dec.
8., V, 13:27):
>
> Hi Alan,
>
> Alan Modra <amodra@gmail.com> ezt írta (időpont: 2019. dec. 8., V, 3:12):
> >
> > On Sat, Dec 07, 2019 at 05:22:13PM +0100, Bálint Réczey wrote:
> > > diff --git a/bfd/elf.c b/bfd/elf.c
> > > index 1aa2603ee8..e1a9a02eec 100644
> > > --- a/bfd/elf.c
> > > +++ b/bfd/elf.c
> > > @@ -5752,7 +5752,12 @@ assign_file_positions_for_load_sections (bfd *abfd,
> > > || (p->p_type == PT_NOTE && bfd_get_format (abfd) == bfd_core))
> > > {
> > > if (!m->includes_filehdr && !m->includes_phdrs)
> > > - p->p_offset = off;
> > > + if (no_contents)
> > > + /* Try avoiding pointing past the EOF with this empty segment's
> > > + p_offset. */
> > > + p->p_offset = p->p_offset % maxpagesize;
> > > + else
> > > + p->p_offset = off;
> > > else
> > > {
> > > file_ptr adjust;
> >
> > How did you test this patch? I suspect you are just leaving p_offset
> > at zero and therefore will cause failures on glibc systems.
>
> I've recompiled gzip in a PPA [1] with the modified binutils and also
> a few other packages since then and they seem to work.
>
> Observing the generalted binary I indeed found that the offset is
> zero, but it did not cause any problem and the first PT_LOAD's file
> offset is also zero.
Is there anything else that should be tested?
Cheers,
Balint