[LinkerScript] Don't create unnecessarily large segments
authorRafael Auler <rafaelauler@gmail.com>
Tue, 14 Jul 2015 00:34:43 +0000 (00:34 +0000)
committerRafael Auler <rafaelauler@gmail.com>
Tue, 14 Jul 2015 00:34:43 +0000 (00:34 +0000)
commit2c4af3ead7cd3ee383bb0e0b1d38844963b23478
tree0cbed4c36bc2522532ebc8d8e6d7894521045604
parent418f3ec17db24bcfc5737131dde5de556111bc32
[LinkerScript] Don't create unnecessarily large segments

When using a linker script expression to change the address of a section, even
if the new address is more than a page of distance from the old address, lld
may put everything in the same segment, forcing it to be unnecessarily large.
This patch changes the logic in Segment::assignVirtualAddress() and
Segment::assignFileOffsets() to allow the segment to be sliced into two or more
if it detects a linker script expression that changes a section address.

Differential Revision: http://reviews.llvm.org/D10952

llvm-svn: 242096
lld/lib/ReaderWriter/ELF/SegmentChunks.cpp
lld/test/elf/linkerscript/sections-order.test