This is an archive of the discontinued LLVM Phabricator instance.

Fix corner cases of setting the section address
ClosedPublic

Authored by rafael on Dec 19 2016, 10:18 AM.

Details

Summary

This is based on and an alternative to D27613.

It handles all the corner cases if setting a section address:

  • If the address is too low, we cannot allocate the program headers.
  • If the load address is lowered, we have to do that before finalize

This also shares some code with the linker script since it was already hitting similar cases.

This is used by the freebsd boot loader. It is not clear if we need to support this with a non binary output, but it is not as bad as I was expecting.

Diff Detail

Event Timeline

rafael retitled this revision from to Fix corner cases of setting the section address.
rafael updated this object.
rafael added reviewers: ruiu, georgerim.
rafael added a subscriber: llvm-commits.
grimar accepted this revision.Dec 19 2016, 10:51 AM
grimar added a reviewer: grimar.
grimar added a subscriber: grimar.

I am happy, looks this just works. (with nit)

lld/ELF/Writer.cpp
1729

Please remove argument names here and below:

elf::allocateHeaders<ELF32LE>(MutableArrayRef<PhdrEntry>,
                              ArrayRef<OutputSectionBase *>);
This revision is now accepted and ready to land.Dec 19 2016, 10:51 AM
grimar closed this revision.Dec 21 2016, 1:59 AM

That was already landed in r290136, thanks for doing this patch, Rafael !