mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-04 10:04:33 +00:00
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302573 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d35f86ef8f
commit
ddb4f9c38b
@ -1602,8 +1602,6 @@ ErrorOr<ArrayRef<UTF16>> ResourceSectionRef::getDirStringAtOffset(uint32_t Offse
|
|||||||
uint16_t Length;
|
uint16_t Length;
|
||||||
RETURN_IF_ERROR(Reader.readInteger(Length));
|
RETURN_IF_ERROR(Reader.readInteger(Length));
|
||||||
ArrayRef<UTF16> RawDirString;
|
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_IF_ERROR(Reader.readArray(RawDirString, Length));
|
||||||
return RawDirString;
|
return RawDirString;
|
||||||
}
|
}
|
||||||
|
@ -1562,6 +1562,14 @@ void COFFDumper::printResourceDirectoryTable(
|
|||||||
raw_svector_ostream OS(IDStr);
|
raw_svector_ostream OS(IDStr);
|
||||||
if (i < Table.NumberOfNameEntries) {
|
if (i < Table.NumberOfNameEntries) {
|
||||||
ArrayRef<UTF16> RawEntryNameString = unwrapOrError(RSF.getEntryNameString(Entry));
|
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;
|
std::string EntryNameString;
|
||||||
if (!llvm::convertUTF16ToUTF8String(RawEntryNameString, EntryNameString))
|
if (!llvm::convertUTF16ToUTF8String(RawEntryNameString, EntryNameString))
|
||||||
error(object_error::parse_failed);
|
error(object_error::parse_failed);
|
||||||
|
Loading…
Reference in New Issue
Block a user