This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Remove empty PT_LOAD being created for program headers.
ClosedPublic

Authored by evgeny777 on Oct 6 2016, 8:41 AM.

Details

Summary

Sometimes the very first PT_LOAD segment, created by lld, can be empty. This happens when (all conditions met):

  • Linker script is used
  • First section in ELF image is not RO
  • Not enough space for program headers.

In such case lld emits empty PT_LOAD to result ELF image. This patch fixes it

Diff Detail

Event Timeline

evgeny777 updated this revision to Diff 73801.Oct 6 2016, 8:41 AM
evgeny777 retitled this revision from to [ELF] Remove empty PT_LOAD being created for program headers..
evgeny777 updated this object.
evgeny777 added reviewers: ruiu, rafael.
evgeny777 set the repository for this revision to rL LLVM.
evgeny777 added a project: lld.
evgeny777 added subscribers: grimar, ikudrin, llvm-commits.
rafael accepted this revision.Oct 6 2016, 10:46 AM
rafael edited edge metadata.

LGTM with nits.

ELF/LinkerScript.cpp
659

Expand the comment a bit with the explanation you have on the description.

test/ELF/linkerscript/empty-load.s
10

Check the flags (rw/rx) too.

This revision is now accepted and ready to land.Oct 6 2016, 10:46 AM
evgeny777 closed this revision.Oct 10 2016, 11:07 AM