Index: llvm/trunk/include/llvm/Object/COFF.h =================================================================== --- llvm/trunk/include/llvm/Object/COFF.h +++ llvm/trunk/include/llvm/Object/COFF.h @@ -1208,6 +1208,8 @@ 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); @@ -1218,6 +1220,8 @@ Expected getTableAtOffset(uint32_t Offset); Expected getTableEntryAtOffset(uint32_t Offset); + Expected + getDataEntryAtOffset(uint32_t Offset); Expected> getDirStringAtOffset(uint32_t Offset); }; Index: llvm/trunk/lib/Object/COFFObjectFile.cpp =================================================================== --- llvm/trunk/lib/Object/COFFObjectFile.cpp +++ llvm/trunk/lib/Object/COFFObjectFile.cpp @@ -1707,11 +1707,29 @@ return *Entry; } +Expected +ResourceSectionRef::getDataEntryAtOffset(uint32_t Offset) { + const coff_resource_data_entry *Entry = nullptr; + + BinaryStreamReader Reader(BBS); + Reader.setOffset(Offset); + RETURN_IF_ERROR(Reader.readObject(Entry)); + assert(Entry != nullptr); + return *Entry; +} + Expected ResourceSectionRef::getEntrySubDir(const coff_resource_dir_entry &Entry) { + assert(Entry.Offset.isSubDir()); return getTableAtOffset(Entry.Offset.value()); } +Expected +ResourceSectionRef::getEntryData(const coff_resource_dir_entry &Entry) { + assert(!Entry.Offset.isSubDir()); + return getDataEntryAtOffset(Entry.Offset.value()); +} + Expected ResourceSectionRef::getBaseTable() { return getTableAtOffset(0); } Index: llvm/trunk/test/tools/llvm-cvtres/combined.test =================================================================== --- llvm/trunk/test/tools/llvm-cvtres/combined.test +++ llvm/trunk/test/tools/llvm-cvtres/combined.test @@ -29,6 +29,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 57 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] @@ -46,6 +52,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 808 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: Name: OKAY [ @@ -58,6 +70,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 808 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] @@ -75,6 +93,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 48 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: Name: (ID 14432) [ @@ -87,6 +111,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 46 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] @@ -104,6 +134,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 108 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] @@ -121,6 +157,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 24 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: Language: (ID 2052) [ CHECK-NEXT: Entry Offset: 0x248 @@ -128,6 +170,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 24 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: Name: (ID 12) [ @@ -140,6 +188,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 24 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] @@ -157,6 +211,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 54 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: Language: (ID 2052) [ CHECK-NEXT: Entry Offset: 0x278 @@ -164,6 +224,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 67 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: Language: (ID 4103) [ CHECK-NEXT: Entry Offset: 0x288 @@ -171,6 +237,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 66 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] Index: llvm/trunk/test/tools/llvm-cvtres/object.test =================================================================== --- llvm/trunk/test/tools/llvm-cvtres/object.test +++ llvm/trunk/test/tools/llvm-cvtres/object.test @@ -28,6 +28,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 57 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] @@ -45,6 +51,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 808 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: Name: OKAY [ @@ -57,6 +69,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 808 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] @@ -74,6 +92,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 48 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: Name: (ID 14432) [ @@ -86,6 +110,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 46 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] @@ -103,6 +133,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 108 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] @@ -120,6 +156,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 24 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: Name: (ID 12) [ @@ -132,6 +174,12 @@ CHECK-NEXT: Major Version: 0 CHECK-NEXT: Minor Version: 0 CHECK-NEXT: Characteristics: 0 +CHECK-NEXT: Data [ +CHECK-NEXT: DataRVA: 0x0 +CHECK-NEXT: DataSize: 24 +CHECK-NEXT: Codepage: 0 +CHECK-NEXT: Reserved: 0 +CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] CHECK-NEXT: ] Index: llvm/trunk/test/tools/llvm-readobj/coff-resources.test =================================================================== --- llvm/trunk/test/tools/llvm-readobj/coff-resources.test +++ llvm/trunk/test/tools/llvm-readobj/coff-resources.test @@ -28,6 +28,12 @@ ZERO-NEXT: Major Version: 0 ZERO-NEXT: Minor Version: 0 ZERO-NEXT: Characteristics: 0 +ZERO-NEXT: Data [ +ZERO-NEXT: DataRVA: 0x0 +ZERO-NEXT: DataSize: 42 +ZERO-NEXT: Codepage: 0 +ZERO-NEXT: Reserved: 0 +ZERO-NEXT: ] ZERO-NEXT: ] ZERO-NEXT: ] ZERO-NEXT: ] @@ -51,6 +57,12 @@ TEST_RES-NEXT: Major Version: 0 TEST_RES-NEXT: Minor Version: 0 TEST_RES-NEXT: Characteristics: 0 +TEST_RES-NEXT: Data [ +TEST_RES-NEXT: DataRVA: 0x0 +TEST_RES-NEXT: DataSize: 808 +TEST_RES-NEXT: Codepage: 0 +TEST_RES-NEXT: Reserved: 0 +TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: Name: OKAY [ @@ -63,6 +75,12 @@ TEST_RES-NEXT: Major Version: 0 TEST_RES-NEXT: Minor Version: 0 TEST_RES-NEXT: Characteristics: 0 +TEST_RES-NEXT: Data [ +TEST_RES-NEXT: DataRVA: 0x0 +TEST_RES-NEXT: DataSize: 808 +TEST_RES-NEXT: Codepage: 0 +TEST_RES-NEXT: Reserved: 0 +TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: ] @@ -80,6 +98,12 @@ TEST_RES-NEXT: Major Version: 0 TEST_RES-NEXT: Minor Version: 0 TEST_RES-NEXT: Characteristics: 0 +TEST_RES-NEXT: Data [ +TEST_RES-NEXT: DataRVA: 0x0 +TEST_RES-NEXT: DataSize: 48 +TEST_RES-NEXT: Codepage: 0 +TEST_RES-NEXT: Reserved: 0 +TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: Name: (ID 14432) [ @@ -92,6 +116,12 @@ TEST_RES-NEXT: Major Version: 0 TEST_RES-NEXT: Minor Version: 0 TEST_RES-NEXT: Characteristics: 0 +TEST_RES-NEXT: Data [ +TEST_RES-NEXT: DataRVA: 0x0 +TEST_RES-NEXT: DataSize: 46 +TEST_RES-NEXT: Codepage: 0 +TEST_RES-NEXT: Reserved: 0 +TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: ] @@ -109,6 +139,12 @@ TEST_RES-NEXT: Major Version: 0 TEST_RES-NEXT: Minor Version: 0 TEST_RES-NEXT: Characteristics: 0 +TEST_RES-NEXT: Data [ +TEST_RES-NEXT: DataRVA: 0x0 +TEST_RES-NEXT: DataSize: 108 +TEST_RES-NEXT: Codepage: 0 +TEST_RES-NEXT: Reserved: 0 +TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: ] @@ -126,6 +162,12 @@ TEST_RES-NEXT: Major Version: 0 TEST_RES-NEXT: Minor Version: 0 TEST_RES-NEXT: Characteristics: 0 +TEST_RES-NEXT: Data [ +TEST_RES-NEXT: DataRVA: 0x0 +TEST_RES-NEXT: DataSize: 24 +TEST_RES-NEXT: Codepage: 0 +TEST_RES-NEXT: Reserved: 0 +TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: Name: (ID 12) [ @@ -138,6 +180,12 @@ TEST_RES-NEXT: Major Version: 0 TEST_RES-NEXT: Minor Version: 0 TEST_RES-NEXT: Characteristics: 0 +TEST_RES-NEXT: Data [ +TEST_RES-NEXT: DataRVA: 0x0 +TEST_RES-NEXT: DataSize: 24 +TEST_RES-NEXT: Codepage: 0 +TEST_RES-NEXT: Reserved: 0 +TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: ] TEST_RES-NEXT: ] Index: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp =================================================================== --- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp +++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp @@ -1864,6 +1864,13 @@ W.printNumber("Major Version", Table.MajorVersion); W.printNumber("Minor Version", Table.MinorVersion); W.printNumber("Characteristics", Table.Characteristics); + ListScope DataScope(W, "Data"); + auto &DataEntry = + unwrapOrError(Obj->getFileName(), RSF.getEntryData(Entry)); + W.printHex("DataRVA", DataEntry.DataRVA); + W.printNumber("DataSize", DataEntry.DataSize); + W.printNumber("Codepage", DataEntry.Codepage); + W.printNumber("Reserved", DataEntry.Reserved); } } }