This is an archive of the discontinued LLVM Phabricator instance.

[llvm-rc] Exclude padding from sizes in versioninfo resources
ClosedPublic

Authored by mstorsjo on May 6 2018, 2:38 PM.

Details

Summary

Normally when writing something that requires padding, we first measure the length of the written payload data, then write padding if necessary.

For a recursive structure like versioninfo, this means that the padding is excluded from the size of the inner element, but included in the size of the enclosing block.

Rc.exe excludes the final padding (but not the padding of earlier children) from all levels of the hierarchy.

To achieve this, don't pad after each block or value, but only before starting the next one. We still pad after completing the toplevel versioninfo resource, so this won't affect other resource types.

Diff Detail

Event Timeline

mstorsjo created this revision.May 6 2018, 2:38 PM
zturner accepted this revision.May 7 2018, 9:56 AM

Nice fix. I can also confirm that the new output is byte-identical to rc.exe's output for the new test case, and that our old output was different.

This revision is now accepted and ready to land.May 7 2018, 9:56 AM
amccarth accepted this revision.May 7 2018, 11:16 AM
This revision was automatically updated to reflect the committed changes.