[PATCH] D33014: Fix the Endianness bug by adding the little endian UTF marker.
Ulrich Weigand via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 9 12:14:58 PDT 2017
uweigand added inline comments.
================
Comment at: llvm/tools/llvm-readobj/COFFDumper.cpp:1565-1572
+ std::vector<UTF16> EndianCorrectedNameString(RawEntryNameString.size() +
+ 1);
+ std::copy(RawEntryNameString.begin(), RawEntryNameString.end(),
+ EndianCorrectedNameString.begin() + 1);
+ EndianCorrectedNameString[0] = 0xFEFF;
std::string EntryNameString;
+ if (!llvm::convertUTF16ToUTF8String(EndianCorrectedNameString,
----------------
zturner wrote:
> How about this:
>
> ```
> ArrayRef<UTF16> RawEntryNameString = unwrapOrError(RSF.getEntryNameString(Entry));
> std::vector<UTF16> EndianCorrectedString;
> if (llvm::sys::IsBigEndianHost) {
> EndianCorrectedString.resize(RawEntryNameString.size() + 1);
> std::copy(RawEntryNameString.begin(), RawEntryNameString.end(), EndianCorrectedString.begin() + 1);
> EndianCorrectedString[0] = UNI_UTF16_BYTE_ORDER_MARK_SWAPPED;
> RawEntryNameString = makeArrayRef(EndianCorrectedString);
> }
> ```
This does fix the problem for me.
https://reviews.llvm.org/D33014
More information about the llvm-commits
mailing list