[binutils-gdb] Fix the linker so that it will not silently generate ELF binaries with invalid program headers. Fix
Alan Modra
amodra@gmail.com
Thu Dec 8 13:27:00 GMT 2016
On Thu, Dec 08, 2016 at 12:14:49PM +0000, Nick Clifton wrote:
> 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).
OK, so I experimented with a patch that omits PHDR when a script
doesn't leave enough room, and "hello world" no longer runs on Ubuntu
16.04. Segfault in dl_main. So it seems INTERP really does need
PHDR, at least with current glibc ld.so.
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list