This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Align SHT_LLVM_PART_EHDR to a maximum page size boundary
ClosedPublic

Authored by MaskRay on Aug 30 2019, 10:09 PM.

Details

Summary

Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=998712

SHT_LLVM_PART_EHDR marks the start of a partition. The partition
sections will be extracted to a separate file. Align to the next maximum
page size boundary so that we can find the ELF header at the start. We
cannot benefit from overlapping p_offset ranges with the previous
segment anyway.

It seems we lack some llvm-objcopy --extract-main-partition and
--extract-partition sanity checks. It may place EHDR at the start
even if p_offset if non zero. Anyway, the lld change is justified for
the reasons above.

Event Timeline

MaskRay created this revision.Aug 30 2019, 10:09 PM
MaskRay updated this revision to Diff 218204.Aug 30 2019, 10:10 PM

Delete a stray line from the test

Harbormaster completed remote builds in B37593: Diff 218204.
ruiu accepted this revision.Sep 2 2019, 12:53 AM

LGTM

This revision is now accepted and ready to land.Sep 2 2019, 12:53 AM
MaskRay updated this revision to Diff 218307.Sep 2 2019, 1:46 AM
MaskRay edited the summary of this revision. (Show Details)

Update description

This revision was automatically updated to reflect the committed changes.
pcc added a comment.Sep 23 2019, 1:24 PM

Alternatively it looks like we could increase the alignment of the partition ELF header section here: http://llvm-cs.pcc.me.uk/tools/lld/ELF/SyntheticSections.cpp#3581

In D67032#1679680, @pcc wrote:

Alternatively it looks like we could increase the alignment of the partition ELF header section here: http://llvm-cs.pcc.me.uk/tools/lld/ELF/SyntheticSections.cpp#3581

This approach will need a bit more work not to overadvance dot (we advance to the addrExpr() aligned address, then alignment aligned address):

[17] .data             PROGBITS        0000000000003178 002178 000008 00  WA  0   0  1                        
[18] .got.plt          PROGBITS        0000000000003180 002180 000028 00  WA  0   0  8                        
[19] part1             LOOS+0xfff4c06  0000000000005000 003000 000040 00   A  0   0 4096 <------- 0x5000 can be 0x4000

But I'll check if this can be implemented.