diff options
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 537c18b..f02bd6a 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -860,7 +860,7 @@ public: std::unique_ptr<const MCSubtargetInfo> SubtargetInfo; std::shared_ptr<MCContext> Context; std::unique_ptr<MCDisassembler> DisAsm; - std::shared_ptr<const MCInstrAnalysis> InstrAnalysis; + std::shared_ptr<MCInstrAnalysis> InstrAnalysis; std::shared_ptr<MCInstPrinter> InstPrinter; PrettyPrinter *Printer; @@ -1283,14 +1283,19 @@ collectBBAddrMapLabels(const std::unordered_map<uint64_t, BBAddrMap> &AddrToBBAd } } -static void collectLocalBranchTargets( - ArrayRef<uint8_t> Bytes, const MCInstrAnalysis *MIA, MCDisassembler *DisAsm, - MCInstPrinter *IP, const MCSubtargetInfo *STI, uint64_t SectionAddr, - uint64_t Start, uint64_t End, std::unordered_map<uint64_t, std::string> &Labels) { +static void +collectLocalBranchTargets(ArrayRef<uint8_t> Bytes, MCInstrAnalysis *MIA, + MCDisassembler *DisAsm, MCInstPrinter *IP, + const MCSubtargetInfo *STI, uint64_t SectionAddr, + uint64_t Start, uint64_t End, + std::unordered_map<uint64_t, std::string> &Labels) { // So far only supports PowerPC and X86. if (!STI->getTargetTriple().isPPC() && !STI->getTargetTriple().isX86()) return; + if (MIA) + MIA->resetState(); + Labels.clear(); unsigned LabelCount = 0; Start += SectionAddr; @@ -1316,6 +1321,7 @@ static void collectLocalBranchTargets( !Labels.count(Target) && !(STI->getTargetTriple().isPPC() && Target == Index)) Labels[Target] = ("L" + Twine(LabelCount++)).str(); + MIA->updateState(Inst, Index); } Index += Size; } @@ -1967,6 +1973,9 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj, BBAddrMapLabels); } + if (DT->InstrAnalysis) + DT->InstrAnalysis->resetState(); + while (Index < End) { // ARM and AArch64 ELF binaries can interleave data and text in the // same section. We rely on the markers introduced to understand what @@ -2183,6 +2192,8 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj, if (TargetOS == &CommentStream) *TargetOS << "\n"; } + + DT->InstrAnalysis->updateState(Inst, SectionAddr + Index); } } |