[llvm] r302573 - Fix the Endianness bug by adding the little endian UTF marker.
Eric Beckmann via llvm-commits
llvm-commits at lists.llvm.org
Tue May 9 12:35:45 PDT 2017
Author: ecbeckmann
Date: Tue May 9 14:35:45 2017
New Revision: 302573
URL: http://llvm.org/viewvc/llvm-project?rev=302573&view=rev
Log:
Fix the Endianness bug by adding the little endian UTF marker.
Summary: Quick fix
Reviewers: zturner, uweigand
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D33014
Modified:
llvm/trunk/lib/Object/COFFObjectFile.cpp
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=302573&r1=302572&r2=302573&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Tue May 9 14:35:45 2017
@@ -1602,8 +1602,6 @@ ErrorOr<ArrayRef<UTF16>> ResourceSection
uint16_t Length;
RETURN_IF_ERROR(Reader.readInteger(Length));
ArrayRef<UTF16> RawDirString;
- // Strings are stored as 2-byte aligned unicode characters but readFixedString
- // assumes byte string, so we double length.
RETURN_IF_ERROR(Reader.readArray(RawDirString, Length));
return RawDirString;
}
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=302573&r1=302572&r2=302573&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Tue May 9 14:35:45 2017
@@ -1562,6 +1562,14 @@ void COFFDumper::printResourceDirectoryT
raw_svector_ostream OS(IDStr);
if (i < Table.NumberOfNameEntries) {
ArrayRef<UTF16> RawEntryNameString = unwrapOrError(RSF.getEntryNameString(Entry));
+ std::vector<UTF16> EndianCorrectedNameString;
+ if (llvm::sys::IsBigEndianHost) {
+ EndianCorrectedNameString.resize(RawEntryNameString.size() + 1);
+ std::copy(RawEntryNameString.begin(), RawEntryNameString.end(),
+ EndianCorrectedNameString.begin() + 1);
+ EndianCorrectedNameString[0] = UNI_UTF16_BYTE_ORDER_MARK_SWAPPED;
+ RawEntryNameString = makeArrayRef(EndianCorrectedNameString);
+ }
std::string EntryNameString;
if (!llvm::convertUTF16ToUTF8String(RawEntryNameString, EntryNameString))
error(object_error::parse_failed);
More information about the llvm-commits
mailing list