This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Reset OutputSection size prior to processing linker script commands
AbandonedPublic

Authored by jhenderson on Sep 27 2017, 9:17 AM.

Details

Reviewers
ruiu
rafael
Summary

The size of an OutputSection is calculated early, to aid handling of compressed debug sections. However, subsequent to this point, unused synthetic sections are removed. In the event that an OutputSection, from which such an InputSection is removed, is still required (e.g. because it has a symbol assignment), and no longer has any InputSections, dot assignments, or BYTE()-family directives, the size member is never updated when processing the commands. If the removed InputSection had a non-zero size (such as a .got.plt section), the section ends up with the wrong size in the output.

The fix is to reset the OutputSection size prior to processing the linker script commands relating to that OutputSection. This ensures that the size is correct even in the above situation.

Diff Detail

Event Timeline

jhenderson created this revision.Sep 27 2017, 9:17 AM
ruiu added inline comments.Sep 27 2017, 1:39 PM
ELF/LinkerScript.cpp
627–630

I think this kind of code is a sign that we compute a value too early. It seems that the real problem is that we compute output section size too early for non-compressed debug sections. We don't need to compute it at all if this function is executed, no?

grimar added a subscriber: grimar.Sep 28 2017, 1:13 AM