llvm.org GIT mirror llvm / fffb713
Hopefully one last commit to fix this patch, addresses string reference issues. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302395 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Beckmann 3 years ago
3 changed file(s) with 14 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
2121 #include "llvm/Object/ObjectFile.h"
2222 #include "llvm/Support/BinaryByteStream.h"
2323 #include "llvm/Support/COFF.h"
24 #include "llvm/Support/ConvertUTF.h"
2425 #include "llvm/Support/Endian.h"
2526 #include "llvm/Support/ErrorHandling.h"
2627 #include "llvm/Support/ErrorOr.h"
10731074 ResourceSectionRef() = default;
10741075 explicit ResourceSectionRef(StringRef Ref) : BBS(Ref, support::little) {}
10751076
1076 ErrorOr<StringRef> getEntryNameString(const coff_resource_dir_entry &Entry);
1077 ErrorOr<ArrayRef> getEntryNameString(const coff_resource_dir_entry &Entry);
10771078 ErrorOr
10781079 getEntrySubDir(const coff_resource_dir_entry &Entry);
10791080 ErrorOr getBaseTable();
10821083 BinaryByteStream BBS;
10831084
10841085 ErrorOr getTableAtOffset(uint32_t Offset);
1085 ErrorOr<StringRef> getDirStringAtOffset(uint32_t Offset);
1086 ErrorOr<ArrayRef> getDirStringAtOffset(uint32_t Offset);
10861087 };
10871088
10881089 // Corresponds to `_FPO_DATA` structure in the PE/COFF spec.
2020 #include "llvm/Object/ObjectFile.h"
2121 #include "llvm/Support/BinaryStreamReader.h"
2222 #include "llvm/Support/COFF.h"
23 #include "llvm/Support/ConvertUTF.h"
2423 #include "llvm/Support/Endian.h"
2524 #include "llvm/Support/Error.h"
2625 #include "llvm/Support/ErrorHandling.h"
15961595 if (auto EC = errorToErrorCode(X)) \
15971596 return EC;
15981597
1599 ErrorOr<StringRef> ResourceSectionRef::getDirStringAtOffset(uint32_t Offset) {
1598 ErrorOr<ArrayRef> ResourceSectionRef::getDirStringAtOffset(uint32_t Offset) {
16001599 BinaryStreamReader Reader = BinaryStreamReader(BBS);
16011600 Reader.setOffset(Offset);
16021601 uint16_t Length;
16051604 // Strings are stored as 2-byte aligned unicode characters but readFixedString
16061605 // assumes byte string, so we double length.
16071606 RETURN_IF_ERROR(Reader.readArray(RawDirString, Length));
1608 std::string DirString;
1609 if (!llvm::convertUTF16ToUTF8String(RawDirString, DirString))
1610 return object_error::parse_failed;
1611 return DirString;
1612 }
1613
1614 ErrorOr
1607 return RawDirString;
1608 }
1609
1610 ErrorOr>
16151611 ResourceSectionRef::getEntryNameString(const coff_resource_dir_entry &Entry) {
16161612 return getDirStringAtOffset(Entry.Identifier.getNameOffset());
16171613 }
4343 #include "llvm/Support/BinaryByteStream.h"
4444 #include "llvm/Support/BinaryStreamReader.h"
4545 #include "llvm/Support/COFF.h"
46 #include "llvm/Support/ConvertUTF.h"
4647 #include "llvm/Support/Casting.h"
4748 #include "llvm/Support/Compiler.h"
4849 #include "llvm/Support/DataExtractor.h"
15591560 SmallString<20> IDStr;
15601561 raw_svector_ostream OS(IDStr);
15611562 if (i < Table.NumberOfNameEntries) {
1562 StringRef EntryNameString = unwrapOrError(RSF.getEntryNameString(Entry));
1563 ArrayRef RawEntryNameString = unwrapOrError(RSF.getEntryNameString(Entry));
1564 std::string EntryNameString;
1565 if (!llvm::convertUTF16ToUTF8String(RawEntryNameString, EntryNameString))
1566 error(object_error::parse_failed);
15631567 OS << ": ";
1564 OS << EntryNameString.str();
1568 OS << EntryNameString;
15651569 } else {
15661570 if (Level == "Type") {
15671571 ScopedPrinter Printer(OS);