This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] elf: Try not pointing empty PT_LOAD segment's offset past EOF
* Alan Modra:
> 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;
>> 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 think glibc requires ordering by increasing virtual address, per the
specification. That does not seem to change here.
Testing on glibc is of course recommended, though. It also needs to be
tested with various kernel versions.