[llvm] r315128 - [llvm-rc] Fix some endianness errors.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 6 16:21:43 PDT 2017
Author: zturner
Date: Fri Oct 6 16:21:43 2017
New Revision: 315128
URL: http://llvm.org/viewvc/llvm-project?rev=315128&view=rev
Log:
[llvm-rc] Fix some endianness errors.
Modified:
llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp
Modified: llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp?rev=315128&r1=315127&r2=315128&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp (original)
+++ llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp Fri Oct 6 16:21:43 2017
@@ -166,7 +166,9 @@ static Error processString(StringRef Str
}
}
- Result.push_back(Char);
+ // Make sure to write little-endian strings, regardless of the host
+ // byte-order.
+ Result.push_back(endian::byte_swap(Char, little));
return Error::success();
};
@@ -347,9 +349,9 @@ Error ResourceFileWriter::writeIntOrStri
void ResourceFileWriter::writeRCInt(RCInt Value) {
if (Value.isLong())
- writeObject((uint32_t)Value);
+ writeInt<uint32_t>(Value);
else
- writeObject((uint16_t)Value);
+ writeInt<uint16_t>(Value);
}
Error ResourceFileWriter::appendFile(StringRef Filename) {
@@ -776,7 +778,7 @@ Error ResourceFileWriter::writeIconOrCur
writeObject(Res->Header);
for (auto Item : Res->ItemEntries) {
writeObject(Item);
- writeObject(ulittle16_t(IconCursorID++));
+ writeInt(IconCursorID++);
}
return Error::success();
}
@@ -1179,9 +1181,9 @@ Error ResourceFileWriter::writeStringTab
Data.push_back('\0');
RETURN_IF_ERROR(
checkNumberFits<uint16_t>(Data.size(), "STRINGTABLE string size"));
- writeObject(ulittle16_t(Data.size()));
+ writeInt<uint16_t>(Data.size());
for (auto Char : Data)
- writeObject(ulittle16_t(Char));
+ writeInt(Char);
}
return Error::success();
}
@@ -1227,13 +1229,13 @@ Error ResourceFileWriter::writeUserDefin
for (auto Ch : ProcessedString) {
if (IsLongString) {
- writeObject(ulittle16_t(Ch));
+ writeInt(Ch);
continue;
}
RETURN_IF_ERROR(checkNumberFits<uint8_t>(
Ch, "Character in narrow string in user-defined resoutce"));
- writeObject(uint8_t(Ch));
+ writeInt<uint8_t>(Ch);
}
}
@@ -1369,9 +1371,9 @@ Error ResourceFileWriter::writeVersionIn
} FixedInfo;
// First, VS_VERSIONINFO.
- auto LengthLoc = writeObject<uint16_t>(0);
- writeObject(ulittle16_t(sizeof(FixedInfo)));
- writeObject(ulittle16_t(0));
+ auto LengthLoc = writeInt<uint16_t>(0);
+ writeInt<uint16_t>(sizeof(FixedInfo));
+ writeInt<uint16_t>(0);
cantFail(writeCString("VS_VERSION_INFO"));
padStream(sizeof(uint32_t));
More information about the llvm-commits
mailing list