aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorSjoerd Meijer <sjoerd.meijer@arm.com>2020-01-31 11:49:20 +0000
committerSjoerd Meijer <sjoerd.meijer@arm.com>2020-01-31 12:41:31 +0000
commit24f0b6b6d8e798f76621af9ea6ccda0568d28703 (patch)
tree108b32cf964509c2815aa03ff0ec475683422c32 /llvm/tools/llvm-objdump/llvm-objdump.cpp
parent09217b60fcf1301e0333a69c37c6408d81c46ca5 (diff)
downloadllvm-24f0b6b6d8e798f76621af9ea6ccda0568d28703.zip
llvm-24f0b6b6d8e798f76621af9ea6ccda0568d28703.tar.gz
llvm-24f0b6b6d8e798f76621af9ea6ccda0568d28703.tar.bz2
[llvm-objdump] avoid crash disassembling unknown instruction
Disassembly of instructions can fail when llvm-objdump is not given the right set of architecture features, for example when the source is compiled with: clang -march=..+ext1+ext2 and disassembly is attempted with: llvm-objdump -mattr=+ext1 This patch avoids further analysing unknown instructions (as was happening before) when disassembly has failed. Differential Revision: https://reviews.llvm.org/D73531
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 984b3f5..6c95d36 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1431,6 +1431,14 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
outs() << CommentStream.str();
Comments.clear();
+ // If disassembly has failed, continue with the next instruction, to
+ // avoid analysing invalid/incomplete instruction information.
+ if (!Disassembled) {
+ outs() << "\n";
+ Index += Size;
+ continue;
+ }
+
// Try to resolve the target of a call, tail call, etc. to a specific
// symbol.
if (MIA && (MIA->isCall(Inst) || MIA->isUnconditionalBranch(Inst) ||