Changeset View
Changeset View
Standalone View
Standalone View
llvm/tools/llvm-readobj/XCOFFDumper.cpp
Show All 36 Lines | |||||
private: | private: | ||||
template <typename T> void printSectionHeaders(ArrayRef<T> Sections); | template <typename T> void printSectionHeaders(ArrayRef<T> Sections); | ||||
template <typename T> void printGenericSectionHeader(T &Sec) const; | template <typename T> void printGenericSectionHeader(T &Sec) const; | ||||
template <typename T> void printOverflowSectionHeader(T &Sec) const; | template <typename T> void printOverflowSectionHeader(T &Sec) const; | ||||
void printFileAuxEnt(const XCOFFFileAuxEnt *AuxEntPtr); | void printFileAuxEnt(const XCOFFFileAuxEnt *AuxEntPtr); | ||||
void printCsectAuxEnt32(const XCOFFCsectAuxEnt32 *AuxEntPtr); | void printCsectAuxEnt32(const XCOFFCsectAuxEnt32 *AuxEntPtr); | ||||
void printSectAuxEntForStat(const XCOFFSectAuxEntForStat *AuxEntPtr); | void printSectAuxEntForStat(const XCOFFSectAuxEntForStat *AuxEntPtr); | ||||
void printSectAuxEntForDwarf32(const XCOFFSectAuxEntForDwarf32 *AuxEntPtr); | |||||
void printBlockAuxEnt32(const XCOFFBlockAuxEnt32 *AuxEntPtr); | |||||
void printSymbol(const SymbolRef &); | void printSymbol(const SymbolRef &); | ||||
void printRelocations(ArrayRef<XCOFFSectionHeader32> Sections); | void printRelocations(ArrayRef<XCOFFSectionHeader32> Sections); | ||||
const XCOFFObjectFile &Obj; | const XCOFFObjectFile &Obj; | ||||
}; | }; | ||||
} // anonymous namespace | } // anonymous namespace | ||||
void XCOFFDumper::printFileHeaders() { | void XCOFFDumper::printFileHeaders() { | ||||
DictScope DS(W, "FileHeader"); | DictScope DS(W, "FileHeader"); | ||||
▲ Show 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | void XCOFFDumper::printSectAuxEntForStat( | ||||
W.printNumber("SectionLength", AuxEntPtr->SectionLength); | W.printNumber("SectionLength", AuxEntPtr->SectionLength); | ||||
// Unlike the corresponding fields in the section header, NumberOfRelocEnt | // Unlike the corresponding fields in the section header, NumberOfRelocEnt | ||||
// and NumberOfLineNum do not handle values greater than 65535. | // and NumberOfLineNum do not handle values greater than 65535. | ||||
W.printNumber("NumberOfRelocEnt", AuxEntPtr->NumberOfRelocEnt); | W.printNumber("NumberOfRelocEnt", AuxEntPtr->NumberOfRelocEnt); | ||||
W.printNumber("NumberOfLineNum", AuxEntPtr->NumberOfLineNum); | W.printNumber("NumberOfLineNum", AuxEntPtr->NumberOfLineNum); | ||||
} | } | ||||
void XCOFFDumper::printSectAuxEntForDwarf32( | |||||
const XCOFFSectAuxEntForDwarf32 *AuxEntPtr) { | |||||
assert(!Obj.is64Bit() && "32-bit interface called on 64-bit object file."); | |||||
DictScope SymDs(W, "Sect Auxiliary Entry For Dwarf"); | |||||
W.printNumber("PortionLength", AuxEntPtr->PortionLength); | |||||
W.printNumber("NumberOfRelocEnt", AuxEntPtr->NumberOfRelocEnt); | |||||
} | |||||
void XCOFFDumper::printBlockAuxEnt32(const XCOFFBlockAuxEnt32 *AuxEntPtr) { | |||||
assert(!Obj.is64Bit() && "32-bit interface called on 64-bit object file."); | |||||
DictScope SymDs(W, "Block Auxiliary Entry"); | |||||
W.printNumber("LineNumber_High16", AuxEntPtr->LineNum_Hi); | |||||
W.printNumber("LineNumber_Low16", AuxEntPtr->LineNum_Lo); | |||||
} | |||||
static const EnumEntry<XCOFF::StorageClass> SymStorageClass[] = { | static const EnumEntry<XCOFF::StorageClass> SymStorageClass[] = { | ||||
#define ECase(X) \ | #define ECase(X) \ | ||||
{ #X, XCOFF::X } | { #X, XCOFF::X } | ||||
ECase(C_NULL), ECase(C_AUTO), ECase(C_EXT), ECase(C_STAT), | ECase(C_NULL), ECase(C_AUTO), ECase(C_EXT), ECase(C_STAT), | ||||
ECase(C_REG), ECase(C_EXTDEF), ECase(C_LABEL), ECase(C_ULABEL), | ECase(C_REG), ECase(C_EXTDEF), ECase(C_LABEL), ECase(C_ULABEL), | ||||
ECase(C_MOS), ECase(C_ARG), ECase(C_STRTAG), ECase(C_MOU), | ECase(C_MOS), ECase(C_ARG), ECase(C_STRTAG), ECase(C_MOU), | ||||
ECase(C_UNTAG), ECase(C_TPDEF), ECase(C_USTATIC), ECase(C_ENTAG), | ECase(C_UNTAG), ECase(C_TPDEF), ECase(C_USTATIC), ECase(C_ENTAG), | ||||
ECase(C_MOE), ECase(C_REGPARM), ECase(C_FIELD), ECase(C_BLOCK), | ECase(C_MOE), ECase(C_REGPARM), ECase(C_FIELD), ECase(C_BLOCK), | ||||
Show All 9 Lines | |||||
}; | }; | ||||
static StringRef GetSymbolValueName(XCOFF::StorageClass SC) { | static StringRef GetSymbolValueName(XCOFF::StorageClass SC) { | ||||
switch (SC) { | switch (SC) { | ||||
case XCOFF::C_EXT: | case XCOFF::C_EXT: | ||||
case XCOFF::C_WEAKEXT: | case XCOFF::C_WEAKEXT: | ||||
case XCOFF::C_HIDEXT: | case XCOFF::C_HIDEXT: | ||||
case XCOFF::C_STAT: | case XCOFF::C_STAT: | ||||
case XCOFF::C_FCN: | |||||
case XCOFF::C_BLOCK: | |||||
return "Value (RelocatableAddress)"; | return "Value (RelocatableAddress)"; | ||||
case XCOFF::C_FILE: | case XCOFF::C_FILE: | ||||
return "Value (SymbolTableIndex)"; | return "Value (SymbolTableIndex)"; | ||||
case XCOFF::C_FCN: | case XCOFF::C_DWARF: | ||||
case XCOFF::C_BLOCK: | return "Value (OffsetInDWARF)"; | ||||
case XCOFF::C_FUN: | case XCOFF::C_FUN: | ||||
case XCOFF::C_STSYM: | case XCOFF::C_STSYM: | ||||
case XCOFF::C_BINCL: | case XCOFF::C_BINCL: | ||||
case XCOFF::C_EINCL: | case XCOFF::C_EINCL: | ||||
case XCOFF::C_INFO: | case XCOFF::C_INFO: | ||||
case XCOFF::C_BSTAT: | case XCOFF::C_BSTAT: | ||||
case XCOFF::C_LSYM: | case XCOFF::C_LSYM: | ||||
case XCOFF::C_PSYM: | case XCOFF::C_PSYM: | ||||
case XCOFF::C_RPSYM: | case XCOFF::C_RPSYM: | ||||
case XCOFF::C_RSYM: | case XCOFF::C_RSYM: | ||||
case XCOFF::C_ECOML: | case XCOFF::C_ECOML: | ||||
case XCOFF::C_DWARF: | |||||
assert(false && "This StorageClass for the symbol is not yet implemented."); | assert(false && "This StorageClass for the symbol is not yet implemented."); | ||||
return ""; | return ""; | ||||
default: | default: | ||||
return "Value"; | return "Value"; | ||||
} | } | ||||
} | } | ||||
static const EnumEntry<XCOFF::CFileLangId> CFileLangIdClass[] = { | static const EnumEntry<XCOFF::CFileLangId> CFileLangIdClass[] = { | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | case XCOFF::C_STAT: | ||||
StatAuxEntPtr = | StatAuxEntPtr = | ||||
reinterpret_cast<const XCOFFSectAuxEntForStat *>(SymbolEntPtr + 1); | reinterpret_cast<const XCOFFSectAuxEntForStat *>(SymbolEntPtr + 1); | ||||
#ifndef NDEBUG | #ifndef NDEBUG | ||||
Obj.checkSymbolEntryPointer(reinterpret_cast<uintptr_t>(StatAuxEntPtr)); | Obj.checkSymbolEntryPointer(reinterpret_cast<uintptr_t>(StatAuxEntPtr)); | ||||
#endif | #endif | ||||
printSectAuxEntForStat(StatAuxEntPtr); | printSectAuxEntForStat(StatAuxEntPtr); | ||||
break; | break; | ||||
case XCOFF::C_DWARF: | case XCOFF::C_DWARF: | ||||
if (NumberOfAuxEntries > 1) | |||||
report_fatal_error( | |||||
"C_DWARF symbol should not have more than 1 auxiliary entry."); | |||||
const XCOFFSectAuxEntForDwarf32 *DwarfAuxEntPtr; | |||||
DwarfAuxEntPtr = | |||||
reinterpret_cast<const XCOFFSectAuxEntForDwarf32 *>(SymbolEntPtr + 1); | |||||
#ifndef NDEBUG | |||||
Obj.checkSymbolEntryPointer(reinterpret_cast<uintptr_t>(DwarfAuxEntPtr)); | |||||
#endif | |||||
printSectAuxEntForDwarf32(DwarfAuxEntPtr); | |||||
break; | |||||
case XCOFF::C_BLOCK: | case XCOFF::C_BLOCK: | ||||
case XCOFF::C_FCN: | case XCOFF::C_FCN: | ||||
report_fatal_error("Symbol table entry printing for this storage class " | // The Block Auxiliary Entry provides information associated with the begin | ||||
"type is unimplemented."); | // and end blocks of functions. | ||||
for (int i = 1; i <= NumberOfAuxEntries; ++i) { | |||||
const XCOFFBlockAuxEnt32 *BlockAuxEntPtr = | |||||
reinterpret_cast<const XCOFFBlockAuxEnt32 *>(SymbolEntPtr + i); | |||||
#ifndef NDEBUG | |||||
Obj.checkSymbolEntryPointer(reinterpret_cast<uintptr_t>(BlockAuxEntPtr)); | |||||
#endif | |||||
printBlockAuxEnt32(BlockAuxEntPtr); | |||||
} | |||||
break; | break; | ||||
default: | default: | ||||
for (int i = 1; i <= NumberOfAuxEntries; i++) { | for (int i = 1; i <= NumberOfAuxEntries; i++) { | ||||
W.startLine() << "!Unexpected raw auxiliary entry data:\n"; | W.startLine() << "!Unexpected raw auxiliary entry data:\n"; | ||||
W.startLine() << format_bytes( | W.startLine() << format_bytes( | ||||
ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(SymbolEntPtr + i), | ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(SymbolEntPtr + i), | ||||
XCOFF::SymbolTableEntrySize)); | XCOFF::SymbolTableEntrySize)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |