This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Change default output section type to SHT_NOBITS
ClosedPublic

Authored by jakehehrlich on Dec 11 2017, 11:36 AM.

Details

Summary

When an output section has no byte commands and has no input sections then it would be ideal if the type of the section is SHT_NOBITS so that the file can take up less space. This change sets the default type of of output sections to SHT_NOBITS instead of SHT_PROGBITS to allow this. This required some minor test changes (which double as tests for this new behavior) but extend-pt-load.s had be changed in a non-trivial way. Since it seems to me that the point of the test is to point out the consequences of how flags are assigned to output sections that don't have input sections I changed the test to work and still show how the memsize of the executable segment was changed.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

jakehehrlich created this revision.Dec 11 2017, 11:36 AM
ruiu accepted this revision.Dec 11 2017, 1:23 PM

LGTM. Nice!

ELF/OutputSections.cpp
315–318

You are not using Data so it should be

if (isa<ByteCommand>(Base) && Type == SHT_NOBITS)
  Type = SHT_PROGBITS;
This revision is now accepted and ready to land.Dec 11 2017, 1:23 PM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.