#include "ARMWinEHPrinter.h"
#include "Error.h"
#include "ObjDumper.h"
+#include "StackMapPrinter.h"
#include "StreamWriter.h"
#include "Win64EHDumper.h"
#include "llvm/ADT/DenseMap.h"
void printCOFFExports() override;
void printCOFFDirectives() override;
void printCOFFBaseReloc() override;
-
+ void printStackMap() const override;
private:
void printSymbol(const SymbolRef &Sym);
void printRelocation(const SectionRef &Section, const RelocationRef &Reloc);
uint64_t Offset, SymbolRef &Sym) {
const auto &Relocations = RelocMap[Section];
for (const auto &Relocation : Relocations) {
- uint64_t RelocationOffset;
- if (std::error_code EC = Relocation.getOffset(RelocationOffset))
- return EC;
+ uint64_t RelocationOffset = Relocation.getOffset();
if (RelocationOffset == Offset) {
Sym = *Relocation.getSymbol();
return EC;
if (std::error_code EC = Symbol.getName(Name))
return EC;
- return object_error::success;
+ return std::error_code();
}
static const EnumEntry<COFF::MachineTypes> ImageFileMachineType[] = {
void COFFDumper::printRelocation(const SectionRef &Section,
const RelocationRef &Reloc) {
- uint64_t Offset;
- uint64_t RelocType;
+ uint64_t Offset = Reloc.getOffset();
+ uint64_t RelocType = Reloc.getType();
SmallString<32> RelocName;
StringRef SymbolName;
- if (error(Reloc.getOffset(Offset)))
- return;
- if (error(Reloc.getType(RelocType)))
- return;
- if (error(Reloc.getTypeName(RelocName)))
- return;
+ Reloc.getTypeName(RelocName);
symbol_iterator Symbol = Reloc.getSymbol();
if (Symbol != Obj->symbol_end() && error(Symbol->getName(SymbolName)))
return;
W.printHex("Address", RVA);
}
}
+
+void COFFDumper::printStackMap() const {
+ object::SectionRef StackMapSection;
+ for (auto Sec : Obj->sections()) {
+ StringRef Name;
+ Sec.getName(Name);
+ if (Name == ".llvm_stackmaps") {
+ StackMapSection = Sec;
+ break;
+ }
+ }
+
+ if (StackMapSection == object::SectionRef())
+ return;
+
+ StringRef StackMapContents;
+ StackMapSection.getContents(StackMapContents);
+ ArrayRef<uint8_t> StackMapContentsArray(
+ reinterpret_cast<const uint8_t*>(StackMapContents.data()),
+ StackMapContents.size());
+
+ if (Obj->isLittleEndian())
+ prettyPrintStackMap(
+ llvm::outs(),
+ StackMapV1Parser<support::little>(StackMapContentsArray));
+ else
+ prettyPrintStackMap(llvm::outs(),
+ StackMapV1Parser<support::big>(StackMapContentsArray));
+}