This is an archive of the discontinued LLVM Phabricator instance.

[COFF] Simplify Chunk::writeTo and remove OutputSectionOff, NFC
ClosedPublic

Authored by rnk on May 8 2019, 1:50 PM.

Details

Summary

Prior to this change, every implementation of writeTo would add
OutputSectionOff to the output section buffer start before writing data.
Instead, do this math in the caller, so that it can be written once
instead of many times.

The output section offset is always equivalent to the difference between
the chunk RVA and the output section RVA, so we can replace the one
remaining usage of OutputSectionOff with that subtraction.

This doesn't change the size of SectionChunk because of alignment
requirements, but I will rearrange the fields in a follow-up change to
accomplish that.

Diff Detail

Repository
rL LLVM

Event Timeline

rnk created this revision.May 8 2019, 1:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 8 2019, 1:50 PM
ruiu accepted this revision.May 8 2019, 7:17 PM

LGTM

Nice!

This revision is now accepted and ready to land.May 8 2019, 7:17 PM
aganea added inline comments.May 9 2019, 1:58 PM
lld/COFF/Chunks.h
126 ↗(On Diff #198719)

Unrelated to this patch, but do you plan on converting 'Out' to an index as well?

This revision was automatically updated to reflect the committed changes.
rnk marked an inline comment as done.May 9 2019, 2:58 PM
rnk added inline comments.
lld/COFF/Chunks.h
126 ↗(On Diff #198719)

Yes, I think it's necessary. It's tricky though because we create many OutputSections, and then throw away the empty ones, so using indices will necessary mean changing that or coming up with a new concept of "output section instance index". It's an index, but it goes into an Instances array, not the actual final image section index.