mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-29 15:17:14 +00:00
[StackMaps] Add a lightweight parser for stackmap version 1 sections.
The parser provides a convenient interface for reading llvm stackmap v1 sections in object files. This patch also includes a new option for llvm-readobj, '-stackmap', which uses the parser to pretty-print stackmap sections for debugging/testing purposes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240860 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "llvm-readobj.h"
|
||||
#include "Error.h"
|
||||
#include "ObjDumper.h"
|
||||
#include "StackMapPrinter.h"
|
||||
#include "StreamWriter.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
@@ -37,6 +38,7 @@ public:
|
||||
void printSymbols() override;
|
||||
void printDynamicSymbols() override;
|
||||
void printUnwindInfo() override;
|
||||
void printStackMap() const override;
|
||||
|
||||
private:
|
||||
template<class MachHeader>
|
||||
@@ -573,3 +575,32 @@ void MachODumper::printSymbol(const SymbolRef &Symbol) {
|
||||
void MachODumper::printUnwindInfo() {
|
||||
W.startLine() << "UnwindInfo not implemented.\n";
|
||||
}
|
||||
|
||||
void MachODumper::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));
|
||||
}
|
||||
|
Reference in New Issue
Block a user