This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [binutils-gdb] Fix the linker so that it will not silently generate ELF binaries with invalid program headers. Fix
- From: Nick Clifton <nickc at redhat dot com>
- To: Alan Modra <amodra at gmail dot com>, "Maciej W. Rozycki" <macro at imgtec dot com>
- Cc: Nick Clifton <nickc at sourceware dot org>, binutils at sourceware dot org
- Date: Thu, 8 Dec 2016 12:14:49 +0000
- Subject: Re: [binutils-gdb] Fix the linker so that it will not silently generate ELF binaries with invalid program headers. Fix
- Authentication-results: sourceware.org; auth=none
- References: <20161123111226.62132.qmail@sourceware.org> <alpine.DEB.2.00.1612080849380.6743@tp.orcam.me.uk> <20161208113238.GF10584@bubble.grove.modra.org>
Hi Alan,
> I think an equally valid and somewhat better fix would have been to not
> emit PT_PHDR when no PT_LOAD header covers the program headers. The
> reason I say that is because PT_PHDR is optional. A loader can read
> the program headers itself from file using info in the ELF header.
That would be nicer, but there is explicit code in _bfd_elf_map_sections_to_segments()
to create a PHDR segment whenever we create an INTERP segment. I assumed
that this was a requirement and hence could not be dropped. (I did not
explore why this was needed, I just assumed that I would break something,
probably the kernel, if I dropped the requirement).
Cheers
Nick