summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rc/ResourceFileWriter.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-05-07 20:27:23 +0000
committerMartin Storsjo <martin@martin.st>2018-05-07 20:27:23 +0000
commit28ae894a1d542a246179aab82c5b6bf2a0cee424 (patch)
treed1e78514ad8dbe5736345b1bd63b3dd0d8a41862 /llvm/tools/llvm-rc/ResourceFileWriter.cpp
parent827ddb240bf52e3b53d837537445f95e613ed583 (diff)
downloadbcm5719-llvm-28ae894a1d542a246179aab82c5b6bf2a0cee424.tar.gz
bcm5719-llvm-28ae894a1d542a246179aab82c5b6bf2a0cee424.zip
[llvm-rc] Exclude padding from sizes in versioninfo resources
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. Differential Revision: https://reviews.llvm.org/D46510 llvm-svn: 331668
Diffstat (limited to 'llvm/tools/llvm-rc/ResourceFileWriter.cpp')
-rw-r--r--llvm/tools/llvm-rc/ResourceFileWriter.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.cpp b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
index dadb7d691f7..93471db200e 100644
--- a/llvm/tools/llvm-rc/ResourceFileWriter.cpp
+++ b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
@@ -1285,6 +1285,7 @@ Error ResourceFileWriter::writeVersionInfoBlock(const VersionInfoBlock &Blk) {
bool OutputHeader = Blk.Name != "";
uint64_t LengthLoc;
+ padStream(sizeof(uint32_t));
if (OutputHeader) {
LengthLoc = writeInt<uint16_t>(0);
writeInt<uint16_t>(0);
@@ -1310,7 +1311,6 @@ Error ResourceFileWriter::writeVersionInfoBlock(const VersionInfoBlock &Blk) {
writeObjectAt(ulittle16_t(CurLoc - LengthLoc), LengthLoc);
}
- padStream(sizeof(uint32_t));
return Error::success();
}
@@ -1340,6 +1340,7 @@ Error ResourceFileWriter::writeVersionInfoValue(const VersionInfoValue &Val) {
return createError(Twine("VALUE ") + Val.Key +
" cannot contain both strings and integers");
+ padStream(sizeof(uint32_t));
auto LengthLoc = writeInt<uint16_t>(0);
auto ValLengthLoc = writeInt<uint16_t>(0);
writeInt<uint16_t>(HasStrings);
@@ -1369,7 +1370,6 @@ Error ResourceFileWriter::writeVersionInfoValue(const VersionInfoValue &Val) {
}
writeObjectAt(ulittle16_t(CurLoc - LengthLoc), LengthLoc);
writeObjectAt(ulittle16_t(ValueLength), ValLengthLoc);
- padStream(sizeof(uint32_t));
return Error::success();
}
OpenPOWER on IntegriCloud