From 1d5ae1026e831016fc29fd927877c86af904481f Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 23 Oct 2019 17:51:42 +0000 Subject: Vendor import of stripped llvm trunk r375505, the last commit before the upstream Subversion repository was made read-only, and the LLVM project migrated to GitHub: https://llvm.org/svn/llvm-project/llvm/trunk@375505 --- include/llvm/Object/COFF.h | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'include/llvm/Object/COFF.h') diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index c53cbc46c747..b91ee5887fec 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -314,7 +314,10 @@ public: return CS16 ? CS16->Name.Offset : CS32->Name.Offset; } - uint32_t getValue() const { return CS16 ? CS16->Value : CS32->Value; } + uint32_t getValue() const { + assert(isSet() && "COFFSymbolRef points to nothing!"); + return CS16 ? CS16->Value : CS32->Value; + } int32_t getSectionNumber() const { assert(isSet() && "COFFSymbolRef points to nothing!"); @@ -969,11 +972,14 @@ public: return nullptr; return reinterpret_cast(base()); } - std::error_code getCOFFHeader(const coff_file_header *&Res) const; - std::error_code - getCOFFBigObjHeader(const coff_bigobj_file_header *&Res) const; - std::error_code getPE32Header(const pe32_header *&Res) const; - std::error_code getPE32PlusHeader(const pe32plus_header *&Res) const; + + const coff_file_header *getCOFFHeader() const { return COFFHeader; } + const coff_bigobj_file_header *getCOFFBigObjHeader() const { + return COFFBigObjHeader; + } + const pe32_header *getPE32Header() const { return PE32Header; } + const pe32plus_header *getPE32PlusHeader() const { return PE32PlusHeader; } + std::error_code getDataDirectory(uint32_t index, const data_directory *&Res) const; std::error_code getSection(int32_t index, const coff_section *&Res) const; @@ -1201,16 +1207,34 @@ public: ResourceSectionRef() = default; explicit ResourceSectionRef(StringRef Ref) : BBS(Ref, support::little) {} + Error load(const COFFObjectFile *O); + Error load(const COFFObjectFile *O, const SectionRef &S); + Expected> getEntryNameString(const coff_resource_dir_entry &Entry); Expected getEntrySubDir(const coff_resource_dir_entry &Entry); + Expected + getEntryData(const coff_resource_dir_entry &Entry); Expected getBaseTable(); + Expected + getTableEntry(const coff_resource_dir_table &Table, uint32_t Index); + + Expected getContents(const coff_resource_data_entry &Entry); private: BinaryByteStream BBS; + SectionRef Section; + const COFFObjectFile *Obj; + + std::vector Relocs; + Expected getTableAtOffset(uint32_t Offset); + Expected + getTableEntryAtOffset(uint32_t Offset); + Expected + getDataEntryAtOffset(uint32_t Offset); Expected> getDirStringAtOffset(uint32_t Offset); }; -- cgit v1.2.3