This is an archive of the discontinued LLVM Phabricator instance.

[LinkerScript] Fix bug in Segment::assignVirtualAddress()
ClosedPublic

Authored by rafaelauler on Jul 5 2015, 10:35 PM.

Details

Summary

When calculating the start address and size of a segment, lld mistakenly
attributes the start address of the last segment slice to the whole segment
when it should consider the start address of the first slice. In this case, in a
multi-slice segment, Segment::assignVirtualAddress() will return a wrong
segment start address to TargetLayout::assignVirtualAddress(). The effect of
this miscalculation is to allocate some program headers in unnecessarily far
away addresses.

This will be tested in my next patch.

Diff Detail

Repository
rL LLVM

Event Timeline

rafaelauler retitled this revision from to [LinkerScript] Fix bug in Segment::assignVirtualAddress().
rafaelauler updated this object.
rafaelauler added a subscriber: llvm-commits.

This is tested in D10952, which is a patch that takes advantage of segments with multiple slices and frequently triggers the bug handled here. Without this patch, D10952 will break an existing test.

This revision was automatically updated to reflect the committed changes.