]> granicus.if.org Git - llvm/commitdiff
Fix a bug introduced in r305092 on big-endian systems.
authorEric Beckmann <ecbeckmann@google.com>
Tue, 13 Jun 2017 20:53:31 +0000 (20:53 +0000)
committerEric Beckmann <ecbeckmann@google.com>
Tue, 13 Jun 2017 20:53:31 +0000 (20:53 +0000)
Summary:
We were writing the length of the string based on system-endianness, and
not universally little-endian.  This fixes that.

Reviewers: zturner

Subscribers: hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D34159

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305322 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Object/WindowsResource.cpp

index fdf4690e60422c7821faafdd800fccc754e0d36c..a1a0d96acbc0f5ca30dcf313b4217105d5852c91 100644 (file)
@@ -691,10 +691,8 @@ void WindowsResourceCOFFWriter::writeDirectoryStringTable() {
   // Now write the directory string table for .rsrc$01
   uint32_t TotalStringTableSize = 0;
   for (auto String : StringTable) {
-    auto *LengthField =
-        reinterpret_cast<uint16_t *>(BufferStart + CurrentOffset);
     uint16_t Length = String.size();
-    *LengthField = Length;
+    support::endian::write16le(BufferStart + CurrentOffset, Length);
     CurrentOffset += sizeof(uint16_t);
     auto *Start = reinterpret_cast<UTF16 *>(BufferStart + CurrentOffset);
     std::copy(String.begin(), String.end(), Start);