[llvm] r305322 - Fix a bug introduced in r305092 on big-endian systems.
Eric Beckmann via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 13 13:53:31 PDT 2017
Author: ecbeckmann
Date: Tue Jun 13 15:53:31 2017
New Revision: 305322
URL: http://llvm.org/viewvc/llvm-project?rev=305322&view=rev
Log:
Fix a bug introduced in r305092 on big-endian systems.
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
Modified:
llvm/trunk/lib/Object/WindowsResource.cpp
Modified: llvm/trunk/lib/Object/WindowsResource.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/WindowsResource.cpp?rev=305322&r1=305321&r2=305322&view=diff
==============================================================================
--- llvm/trunk/lib/Object/WindowsResource.cpp (original)
+++ llvm/trunk/lib/Object/WindowsResource.cpp Tue Jun 13 15:53:31 2017
@@ -691,10 +691,8 @@ void WindowsResourceCOFFWriter::writeDir
// 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);
More information about the llvm-commits
mailing list