llvm-vtabledump: Handle Itanium VTables

Add support in the vtable dumper for the Itanium ABI.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221133 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer 2014-11-03 07:23:25 +00:00
parent 9808f11b09
commit 5dc81d5a76
2 changed files with 222 additions and 95 deletions

View File

@ -1,50 +1,58 @@
RUN: llvm-vtabledump %p/Inputs/trivial.obj.coff-i386 \ RUN: llvm-vtabledump %p/Inputs/trivial.obj.coff-i386 \
RUN: | FileCheck %s RUN: | FileCheck %s --check-prefix=COFF-I386
CHECK: ??_7S@@6B@[0]: ??_R4S@@6B@ RUN: llvm-vtabledump %p/Inputs/trivial.obj.elf-i386 \
CHECK-NEXT: ??_7S@@6B@[4]: ??_GS@@UAEPAXI@Z RUN: | FileCheck %s --check-prefix=ELF-I386
CHECK-NEXT: ??_8S@@7B@[0]: -4
CHECK-NEXT: ??_8S@@7B@[4]: 4 COFF-I386: ??_7S@@6B@[0]: ??_R4S@@6B@
CHECK-NEXT: ??_R4S@@6B@[IsImageRelative]: 0 COFF-I386-NEXT: ??_7S@@6B@[4]: ??_GS@@UAEPAXI@Z
CHECK-NEXT: ??_R4S@@6B@[OffsetToTop]: 0 COFF-I386-NEXT: ??_8S@@7B@[0]: -4
CHECK-NEXT: ??_R4S@@6B@[VFPtrOffset]: 0 COFF-I386-NEXT: ??_8S@@7B@[4]: 4
CHECK-NEXT: ??_R4S@@6B@[TypeDescriptor]: ??_R0?AUS@@@8 COFF-I386-NEXT: ??_R4S@@6B@[IsImageRelative]: 0
CHECK-NEXT: ??_R4S@@6B@[ClassHierarchyDescriptor]: ??_R3S@@8 COFF-I386-NEXT: ??_R4S@@6B@[OffsetToTop]: 0
CHECK-NEXT: ??_R3A@@8[AlwaysZero]: 0 COFF-I386-NEXT: ??_R4S@@6B@[VFPtrOffset]: 0
CHECK-NEXT: ??_R3A@@8[Flags]: 0 COFF-I386-NEXT: ??_R4S@@6B@[TypeDescriptor]: ??_R0?AUS@@@8
CHECK-NEXT: ??_R3A@@8[NumClasses]: 1 COFF-I386-NEXT: ??_R4S@@6B@[ClassHierarchyDescriptor]: ??_R3S@@8
CHECK-NEXT: ??_R3A@@8[BaseClassArray]: ??_R2A@@8 COFF-I386-NEXT: ??_R3A@@8[AlwaysZero]: 0
CHECK-NEXT: ??_R3S@@8[AlwaysZero]: 0 COFF-I386-NEXT: ??_R3A@@8[Flags]: 0
CHECK-NEXT: ??_R3S@@8[Flags]: 0 COFF-I386-NEXT: ??_R3A@@8[NumClasses]: 1
CHECK-NEXT: ??_R3S@@8[NumClasses]: 2 COFF-I386-NEXT: ??_R3A@@8[BaseClassArray]: ??_R2A@@8
CHECK-NEXT: ??_R3S@@8[BaseClassArray]: ??_R2S@@8 COFF-I386-NEXT: ??_R3S@@8[AlwaysZero]: 0
CHECK-NEXT: ??_R2A@@8[0]: ??_R1A@?0A@EA@A@@8 COFF-I386-NEXT: ??_R3S@@8[Flags]: 0
CHECK-NEXT: ??_R2S@@8[0]: ??_R1A@?0A@EA@S@@8 COFF-I386-NEXT: ??_R3S@@8[NumClasses]: 2
CHECK-NEXT: ??_R2S@@8[4]: ??_R1A@33FA@A@@8 COFF-I386-NEXT: ??_R3S@@8[BaseClassArray]: ??_R2S@@8
CHECK-NEXT: ??_R1A@33FA@A@@8[TypeDescriptor]: ??_R0?AUA@@@8 COFF-I386-NEXT: ??_R2A@@8[0]: ??_R1A@?0A@EA@A@@8
CHECK-NEXT: ??_R1A@33FA@A@@8[NumBases]: 0 COFF-I386-NEXT: ??_R2S@@8[0]: ??_R1A@?0A@EA@S@@8
CHECK-NEXT: ??_R1A@33FA@A@@8[OffsetInVBase]: 0 COFF-I386-NEXT: ??_R2S@@8[4]: ??_R1A@33FA@A@@8
CHECK-NEXT: ??_R1A@33FA@A@@8[VBPtrOffset]: 4 COFF-I386-NEXT: ??_R1A@33FA@A@@8[TypeDescriptor]: ??_R0?AUA@@@8
CHECK-NEXT: ??_R1A@33FA@A@@8[OffsetInVBTable]: 4 COFF-I386-NEXT: ??_R1A@33FA@A@@8[NumBases]: 0
CHECK-NEXT: ??_R1A@33FA@A@@8[Flags]: 80 COFF-I386-NEXT: ??_R1A@33FA@A@@8[OffsetInVBase]: 0
CHECK-NEXT: ??_R1A@33FA@A@@8[ClassHierarchyDescriptor]: ??_R3A@@8 COFF-I386-NEXT: ??_R1A@33FA@A@@8[VBPtrOffset]: 4
CHECK-NEXT: ??_R1A@?0A@EA@A@@8[TypeDescriptor]: ??_R0?AUA@@@8 COFF-I386-NEXT: ??_R1A@33FA@A@@8[OffsetInVBTable]: 4
CHECK-NEXT: ??_R1A@?0A@EA@A@@8[NumBases]: 0 COFF-I386-NEXT: ??_R1A@33FA@A@@8[Flags]: 80
CHECK-NEXT: ??_R1A@?0A@EA@A@@8[OffsetInVBase]: 0 COFF-I386-NEXT: ??_R1A@33FA@A@@8[ClassHierarchyDescriptor]: ??_R3A@@8
CHECK-NEXT: ??_R1A@?0A@EA@A@@8[VBPtrOffset]: -1 COFF-I386-NEXT: ??_R1A@?0A@EA@A@@8[TypeDescriptor]: ??_R0?AUA@@@8
CHECK-NEXT: ??_R1A@?0A@EA@A@@8[OffsetInVBTable]: 0 COFF-I386-NEXT: ??_R1A@?0A@EA@A@@8[NumBases]: 0
CHECK-NEXT: ??_R1A@?0A@EA@A@@8[Flags]: 64 COFF-I386-NEXT: ??_R1A@?0A@EA@A@@8[OffsetInVBase]: 0
CHECK-NEXT: ??_R1A@?0A@EA@A@@8[ClassHierarchyDescriptor]: ??_R3A@@8 COFF-I386-NEXT: ??_R1A@?0A@EA@A@@8[VBPtrOffset]: -1
CHECK-NEXT: ??_R1A@?0A@EA@S@@8[TypeDescriptor]: ??_R0?AUS@@@8 COFF-I386-NEXT: ??_R1A@?0A@EA@A@@8[OffsetInVBTable]: 0
CHECK-NEXT: ??_R1A@?0A@EA@S@@8[NumBases]: 1 COFF-I386-NEXT: ??_R1A@?0A@EA@A@@8[Flags]: 64
CHECK-NEXT: ??_R1A@?0A@EA@S@@8[OffsetInVBase]: 0 COFF-I386-NEXT: ??_R1A@?0A@EA@A@@8[ClassHierarchyDescriptor]: ??_R3A@@8
CHECK-NEXT: ??_R1A@?0A@EA@S@@8[VBPtrOffset]: -1 COFF-I386-NEXT: ??_R1A@?0A@EA@S@@8[TypeDescriptor]: ??_R0?AUS@@@8
CHECK-NEXT: ??_R1A@?0A@EA@S@@8[OffsetInVBTable]: 0 COFF-I386-NEXT: ??_R1A@?0A@EA@S@@8[NumBases]: 1
CHECK-NEXT: ??_R1A@?0A@EA@S@@8[Flags]: 64 COFF-I386-NEXT: ??_R1A@?0A@EA@S@@8[OffsetInVBase]: 0
CHECK-NEXT: ??_R1A@?0A@EA@S@@8[ClassHierarchyDescriptor]: ??_R3S@@8 COFF-I386-NEXT: ??_R1A@?0A@EA@S@@8[VBPtrOffset]: -1
CHECK-NEXT: ??_R0?AUA@@@8[VFPtr]: ??_7type_info@@6B@ COFF-I386-NEXT: ??_R1A@?0A@EA@S@@8[OffsetInVBTable]: 0
CHECK-NEXT: ??_R0?AUA@@@8[AlwaysZero]: 0 COFF-I386-NEXT: ??_R1A@?0A@EA@S@@8[Flags]: 64
CHECK-NEXT: ??_R0?AUA@@@8[MangledName]: .?AUA@@ COFF-I386-NEXT: ??_R1A@?0A@EA@S@@8[ClassHierarchyDescriptor]: ??_R3S@@8
CHECK-NEXT: ??_R0?AUS@@@8[VFPtr]: ??_7type_info@@6B@ COFF-I386-NEXT: ??_R0?AUA@@@8[VFPtr]: ??_7type_info@@6B@
CHECK-NEXT: ??_R0?AUS@@@8[AlwaysZero]: 0 COFF-I386-NEXT: ??_R0?AUA@@@8[AlwaysZero]: 0
CHECK-NEXT: ??_R0?AUS@@@8[MangledName]: .?AUS@@ COFF-I386-NEXT: ??_R0?AUA@@@8[MangledName]: .?AUA@@
COFF-I386-NEXT: ??_R0?AUS@@@8[VFPtr]: ??_7type_info@@6B@
COFF-I386-NEXT: ??_R0?AUS@@@8[AlwaysZero]: 0
COFF-I386-NEXT: ??_R0?AUS@@@8[MangledName]: .?AUS@@
ELF-I386: _ZTS1A: 1A
ELF-I386-NEXT: _ZTV1A[0]: 0
ELF-I386-NEXT: _ZTV1A[4]: _ZTI1A
ELF-I386-NEXT: _ZTV1A[8]: _ZN1A1fEv

View File

@ -68,28 +68,31 @@ static void reportError(StringRef Input, std::error_code EC) {
reportError(Input, EC.message()); reportError(Input, EC.message());
} }
static bool collectRelocatedSymbols(const ObjectFile *Obj, static SmallVectorImpl<SectionRef> &getRelocSections(const ObjectFile *Obj,
object::section_iterator SecI, StringRef *I, const SectionRef &Sec) {
StringRef *E) { static bool MappingDone = false;
for (const object::RelocationRef &Reloc : SecI->relocations()) { static std::map<SectionRef, SmallVector<SectionRef, 1>> SectionRelocMap;
if (I == E) if (!MappingDone) {
break; for (const SectionRef &Section : Obj->sections()) {
const object::symbol_iterator RelocSymI = Reloc.getSymbol(); section_iterator Sec2 = Section.getRelocatedSection();
if (RelocSymI == Obj->symbol_end()) if (Sec2 != Obj->section_end())
continue; SectionRelocMap[*Sec2].push_back(Section);
StringRef RelocSymName;
if (error(RelocSymI->getName(RelocSymName)))
return true;
*I = RelocSymName;
++I;
} }
return false; MappingDone = true;
}
return SectionRelocMap[Sec];
} }
static bool collectRelocationOffsets( static bool collectRelocatedSymbols(const ObjectFile *Obj,
const ObjectFile *Obj, object::section_iterator SecI, StringRef SymName, const SectionRef &Sec, uint64_t SecAddress,
std::map<std::pair<StringRef, uint64_t>, StringRef> &Collection) { uint64_t SymAddress, uint64_t SymSize,
for (const object::RelocationRef &Reloc : SecI->relocations()) { StringRef *I, StringRef *E) {
uint64_t SymOffset = SymAddress - SecAddress;
uint64_t SymEnd = SymOffset + SymSize;
for (const SectionRef &SR : getRelocSections(Obj, Sec)) {
for (const object::RelocationRef &Reloc : SR.relocations()) {
if (I == E)
break;
const object::symbol_iterator RelocSymI = Reloc.getSymbol(); const object::symbol_iterator RelocSymI = Reloc.getSymbol();
if (RelocSymI == Obj->symbol_end()) if (RelocSymI == Obj->symbol_end())
continue; continue;
@ -99,7 +102,35 @@ static bool collectRelocationOffsets(
uint64_t Offset; uint64_t Offset;
if (error(Reloc.getOffset(Offset))) if (error(Reloc.getOffset(Offset)))
return true; return true;
Collection[std::make_pair(SymName, Offset)] = RelocSymName; if (Offset >= SymOffset && Offset < SymEnd) {
*I = RelocSymName;
++I;
}
}
}
return false;
}
static bool collectRelocationOffsets(
const ObjectFile *Obj, const SectionRef &Sec, uint64_t SecAddress,
uint64_t SymAddress, uint64_t SymSize, StringRef SymName,
std::map<std::pair<StringRef, uint64_t>, StringRef> &Collection) {
uint64_t SymOffset = SymAddress - SecAddress;
uint64_t SymEnd = SymOffset + SymSize;
for (const SectionRef &SR : getRelocSections(Obj, Sec)) {
for (const object::RelocationRef &Reloc : SR.relocations()) {
const object::symbol_iterator RelocSymI = Reloc.getSymbol();
if (RelocSymI == Obj->symbol_end())
continue;
StringRef RelocSymName;
if (error(RelocSymI->getName(RelocSymName)))
return true;
uint64_t Offset;
if (error(Reloc.getOffset(Offset)))
return true;
if (Offset >= SymOffset && Offset < SymEnd)
Collection[std::make_pair(SymName, Offset - SymOffset)] = RelocSymName;
}
} }
return false; return false;
} }
@ -129,6 +160,14 @@ static void dumpVTables(const ObjectFile *Obj) {
std::map<std::pair<StringRef, uint64_t>, StringRef> BCAEntries; std::map<std::pair<StringRef, uint64_t>, StringRef> BCAEntries;
std::map<StringRef, BaseClassDescriptor> BCDs; std::map<StringRef, BaseClassDescriptor> BCDs;
std::map<StringRef, TypeDescriptor> TDs; std::map<StringRef, TypeDescriptor> TDs;
std::map<std::pair<StringRef, uint64_t>, StringRef> VTableSymEntries;
std::map<std::pair<StringRef, uint64_t>, int64_t> VTableDataEntries;
std::map<std::pair<StringRef, uint64_t>, StringRef> VTTEntries;
std::map<StringRef, StringRef> TINames;
uint8_t BytesInAddress = Obj->getBytesInAddress();
for (const object::SymbolRef &Sym : Obj->symbols()) { for (const object::SymbolRef &Sym : Obj->symbols()) {
StringRef SymName; StringRef SymName;
if (error(Sym.getName(SymName))) if (error(Sym.getName(SymName)))
@ -139,37 +178,46 @@ static void dumpVTables(const ObjectFile *Obj) {
// Skip external symbols. // Skip external symbols.
if (SecI == Obj->section_end()) if (SecI == Obj->section_end())
continue; continue;
bool IsBSS = SecI->isBSS(); const SectionRef &Sec = *SecI;
bool IsVirtual = SecI->isVirtual();
// Skip virtual or BSS sections. // Skip virtual or BSS sections.
if (IsBSS || IsVirtual) if (Sec.isBSS() || Sec.isVirtual())
continue; continue;
StringRef SecContents; StringRef SecContents;
if (error(SecI->getContents(SecContents))) if (error(Sec.getContents(SecContents)))
return; return;
uint64_t SymAddress, SymSize;
if (error(Sym.getAddress(SymAddress)) || error(Sym.getSize(SymSize)))
return;
uint64_t SecAddress = Sec.getAddress();
uint64_t SecSize = Sec.getSize();
uint64_t SymOffset = SymAddress - SecAddress;
StringRef SymContents = SecContents.substr(SymOffset, SymSize);
// VFTables in the MS-ABI start with '??_7' and are contained within their // VFTables in the MS-ABI start with '??_7' and are contained within their
// own COMDAT section. We then determine the contents of the VFTable by // own COMDAT section. We then determine the contents of the VFTable by
// looking at each relocation in the section. // looking at each relocation in the section.
if (SymName.startswith("??_7")) { if (SymName.startswith("??_7")) {
// Each relocation either names a virtual method or a thunk. We note the // Each relocation either names a virtual method or a thunk. We note the
// offset into the section and the symbol used for the relocation. // offset into the section and the symbol used for the relocation.
collectRelocationOffsets(Obj, SecI, SymName, VFTableEntries); collectRelocationOffsets(Obj, Sec, SecAddress, SecAddress, SecSize,
SymName, VFTableEntries);
} }
// VBTables in the MS-ABI start with '??_8' and are filled with 32-bit // VBTables in the MS-ABI start with '??_8' and are filled with 32-bit
// offsets of virtual bases. // offsets of virtual bases.
else if (SymName.startswith("??_8")) { else if (SymName.startswith("??_8")) {
ArrayRef<little32_t> VBTableData( ArrayRef<little32_t> VBTableData(
reinterpret_cast<const little32_t *>(SecContents.data()), reinterpret_cast<const little32_t *>(SymContents.data()),
SecContents.size() / sizeof(little32_t)); SymContents.size() / sizeof(little32_t));
VBTables[SymName] = VBTableData; VBTables[SymName] = VBTableData;
} }
// Complete object locators in the MS-ABI start with '??_R4' // Complete object locators in the MS-ABI start with '??_R4'
else if (SymName.startswith("??_R4")) { else if (SymName.startswith("??_R4")) {
CompleteObjectLocator COL; CompleteObjectLocator COL;
COL.Data = ArrayRef<little32_t>( COL.Data = ArrayRef<little32_t>(
reinterpret_cast<const little32_t *>(SecContents.data()), 3); reinterpret_cast<const little32_t *>(SymContents.data()), 3);
StringRef *I = std::begin(COL.Symbols), *E = std::end(COL.Symbols); StringRef *I = std::begin(COL.Symbols), *E = std::end(COL.Symbols);
if (collectRelocatedSymbols(Obj, SecI, I, E)) if (collectRelocatedSymbols(Obj, Sec, SecAddress, SymAddress, SymSize, I,
E))
return; return;
COLs[SymName] = COL; COLs[SymName] = COL;
} }
@ -177,9 +225,10 @@ static void dumpVTables(const ObjectFile *Obj) {
else if (SymName.startswith("??_R3")) { else if (SymName.startswith("??_R3")) {
ClassHierarchyDescriptor CHD; ClassHierarchyDescriptor CHD;
CHD.Data = ArrayRef<little32_t>( CHD.Data = ArrayRef<little32_t>(
reinterpret_cast<const little32_t *>(SecContents.data()), 3); reinterpret_cast<const little32_t *>(SymContents.data()), 3);
StringRef *I = std::begin(CHD.Symbols), *E = std::end(CHD.Symbols); StringRef *I = std::begin(CHD.Symbols), *E = std::end(CHD.Symbols);
if (collectRelocatedSymbols(Obj, SecI, I, E)) if (collectRelocatedSymbols(Obj, Sec, SecAddress, SymAddress, SymSize, I,
E))
return; return;
CHDs[SymName] = CHD; CHDs[SymName] = CHD;
} }
@ -187,35 +236,65 @@ static void dumpVTables(const ObjectFile *Obj) {
else if (SymName.startswith("??_R2")) { else if (SymName.startswith("??_R2")) {
// Each relocation names a base class descriptor. We note the offset into // Each relocation names a base class descriptor. We note the offset into
// the section and the symbol used for the relocation. // the section and the symbol used for the relocation.
collectRelocationOffsets(Obj, SecI, SymName, BCAEntries); collectRelocationOffsets(Obj, Sec, SecAddress, SymAddress, SymSize,
SymName, BCAEntries);
} }
// Base class descriptors in the MS-ABI start with '??_R1' // Base class descriptors in the MS-ABI start with '??_R1'
else if (SymName.startswith("??_R1")) { else if (SymName.startswith("??_R1")) {
BaseClassDescriptor BCD; BaseClassDescriptor BCD;
BCD.Data = ArrayRef<little32_t>( BCD.Data = ArrayRef<little32_t>(
reinterpret_cast<const little32_t *>(SecContents.data()) + 1, reinterpret_cast<const little32_t *>(SymContents.data()) + 1, 5);
5);
StringRef *I = std::begin(BCD.Symbols), *E = std::end(BCD.Symbols); StringRef *I = std::begin(BCD.Symbols), *E = std::end(BCD.Symbols);
if (collectRelocatedSymbols(Obj, SecI, I, E)) if (collectRelocatedSymbols(Obj, Sec, SecAddress, SymAddress, SymSize, I,
E))
return; return;
BCDs[SymName] = BCD; BCDs[SymName] = BCD;
} }
// Type descriptors in the MS-ABI start with '??_R0' // Type descriptors in the MS-ABI start with '??_R0'
else if (SymName.startswith("??_R0")) { else if (SymName.startswith("??_R0")) {
uint8_t BytesInAddress = Obj->getBytesInAddress(); const char *DataPtr = SymContents.drop_front(BytesInAddress).data();
const char *DataPtr =
SecContents.drop_front(Obj->getBytesInAddress()).data();
TypeDescriptor TD; TypeDescriptor TD;
if (BytesInAddress == 8) if (BytesInAddress == 8)
TD.AlwaysZero = *reinterpret_cast<const little64_t *>(DataPtr); TD.AlwaysZero = *reinterpret_cast<const little64_t *>(DataPtr);
else else
TD.AlwaysZero = *reinterpret_cast<const little32_t *>(DataPtr); TD.AlwaysZero = *reinterpret_cast<const little32_t *>(DataPtr);
TD.MangledName = SecContents.drop_front(Obj->getBytesInAddress() * 2); TD.MangledName = SymContents.drop_front(BytesInAddress * 2);
StringRef *I = std::begin(TD.Symbols), *E = std::end(TD.Symbols); StringRef *I = std::begin(TD.Symbols), *E = std::end(TD.Symbols);
if (collectRelocatedSymbols(Obj, SecI, I, E)) if (collectRelocatedSymbols(Obj, Sec, SecAddress, SymAddress, SymSize, I,
E))
return; return;
TDs[SymName] = TD; TDs[SymName] = TD;
} }
// Construction vtables in the Itanium ABI start with '_ZTT' or '__ZTT'.
else if (SymName.startswith("_ZTT") || SymName.startswith("__ZTT")) {
collectRelocationOffsets(Obj, Sec, SecAddress, SymAddress, SymSize,
SymName, VTTEntries);
}
// Typeinfo names in the Itanium ABI start with '_ZTS' or '__ZTS'.
else if (SymName.startswith("_ZTS") || SymName.startswith("__ZTS")) {
TINames[SymName] = SymContents.slice(0, SymContents.find('\0'));
}
// Vtables in the Itanium ABI start with '_ZTV' or '__ZTV'.
else if (SymName.startswith("_ZTV") || SymName.startswith("__ZTV")) {
collectRelocationOffsets(Obj, Sec, SecAddress, SymAddress, SymSize,
SymName, VTableSymEntries);
for (uint64_t SymOffI = 0; SymOffI < SymSize; SymOffI += BytesInAddress) {
auto Key = std::make_pair(SymName, SymOffI);
if (VTableSymEntries.count(Key))
continue;
const char *DataPtr = SymContents.substr(SymOffI, BytesInAddress).data();
int64_t VData;
if (BytesInAddress == 8)
VData = *reinterpret_cast<const little64_t *>(DataPtr);
else
VData = *reinterpret_cast<const little32_t *>(DataPtr);
VTableDataEntries[Key] = VData;
}
}
// Typeinfo structures in the Itanium ABI start with '_ZTI' or '__ZTI'.
else if (SymName.startswith("_ZTI") || SymName.startswith("__ZTI")) {
// FIXME: Do something with these!
}
} }
for (const std::pair<std::pair<StringRef, uint64_t>, StringRef> &VFTableEntry : for (const std::pair<std::pair<StringRef, uint64_t>, StringRef> &VFTableEntry :
VFTableEntries) { VFTableEntries) {
@ -224,8 +303,7 @@ static void dumpVTables(const ObjectFile *Obj) {
StringRef SymName = VFTableEntry.second; StringRef SymName = VFTableEntry.second;
outs() << VFTableName << '[' << Offset << "]: " << SymName << '\n'; outs() << VFTableName << '[' << Offset << "]: " << SymName << '\n';
} }
for (const std::pair<StringRef, ArrayRef<little32_t>> &VBTable : for (const std::pair<StringRef, ArrayRef<little32_t>> &VBTable : VBTables) {
VBTables) {
StringRef VBTableName = VBTable.first; StringRef VBTableName = VBTable.first;
uint32_t Idx = 0; uint32_t Idx = 0;
for (little32_t Offset : VBTable.second) { for (little32_t Offset : VBTable.second) {
@ -278,6 +356,47 @@ static void dumpVTables(const ObjectFile *Obj) {
/*UseHexEscapes=*/true) /*UseHexEscapes=*/true)
<< '\n'; << '\n';
} }
for (const std::pair<std::pair<StringRef, uint64_t>, StringRef> &VTTPair :
VTTEntries) {
StringRef VTTName = VTTPair.first.first;
uint64_t VTTOffset = VTTPair.first.second;
StringRef VTTEntry = VTTPair.second;
outs() << VTTName << '[' << VTTOffset << "]: " << VTTEntry << '\n';
}
for (const std::pair<StringRef, StringRef> &TIPair : TINames) {
StringRef TIName = TIPair.first;
outs() << TIName << ": " << TIPair.second << '\n';
}
auto VTableSymI = VTableSymEntries.begin();
auto VTableSymE = VTableSymEntries.end();
auto VTableDataI = VTableDataEntries.begin();
auto VTableDataE = VTableDataEntries.end();
for (;;) {
bool SymDone = VTableSymI == VTableSymE;
bool DataDone = VTableDataI == VTableDataE;
if (SymDone && DataDone)
break;
if (!SymDone && (DataDone || VTableSymI->first < VTableDataI->first)) {
StringRef VTableName = VTableSymI->first.first;
uint64_t Offset = VTableSymI->first.second;
StringRef VTableEntry = VTableSymI->second;
outs() << VTableName << '[' << Offset << "]: ";
outs() << VTableEntry;
outs() << '\n';
++VTableSymI;
continue;
}
if (!DataDone && (SymDone || VTableDataI->first < VTableSymI->first)) {
StringRef VTableName = VTableDataI->first.first;
uint64_t Offset = VTableDataI->first.second;
int64_t VTableEntry = VTableDataI->second;
outs() << VTableName << '[' << Offset << "]: ";
outs() << VTableEntry;
outs() << '\n';
++VTableDataI;
continue;
}
}
} }
static void dumpArchive(const Archive *Arc) { static void dumpArchive(const Archive *Arc) {