diff options
author | jasonliu <jasonliu.development@gmail.com> | 2020-04-13 15:49:36 +0000 |
---|---|---|
committer | jasonliu <jasonliu.development@gmail.com> | 2020-04-13 15:51:36 +0000 |
commit | 40f7ab507b39c183533746e00133b7ecd43c4e75 (patch) | |
tree | 9547f9319dabd3f90f826f380728b1448bd7738a /llvm/tools/llvm-objdump/llvm-objdump.cpp | |
parent | bc78baec4cc3ac95a931f4708f1534af7ff77de5 (diff) | |
download | llvm-40f7ab507b39c183533746e00133b7ecd43c4e75.zip llvm-40f7ab507b39c183533746e00133b7ecd43c4e75.tar.gz llvm-40f7ab507b39c183533746e00133b7ecd43c4e75.tar.bz2 |
[llvm-objdump] Fix incomplete relocation output for -D -r mode
This patch intends to fix incomplete relocation printing for
XCOFF (potentially for other targets).
Differential Revision: https://reviews.llvm.org/D77580
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index f407f14..dd1fec6 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -1506,18 +1506,12 @@ 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) || - MIA->isConditionalBranch(Inst))) { + // If disassembly has failed, avoid analysing invalid/incomplete + // instruction information. Otherwise, try to resolve the target of a + // call, tail call, etc. to a specific symbol. + if (Disassembled && MIA && + (MIA->isCall(Inst) || MIA->isUnconditionalBranch(Inst) || + MIA->isConditionalBranch(Inst))) { uint64_t Target; if (MIA->evaluateBranch(Inst, SectionAddr + Index, Size, Target)) { // In a relocatable object, the target's section must reside in @@ -1574,7 +1568,7 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj, // Hexagon does this in pretty printer if (Obj->getArch() != Triple::hexagon) { - // Print relocation for instruction. + // Print relocation for instruction and data. while (RelCur != RelEnd) { uint64_t Offset = RelCur->getOffset(); // If this relocation is hidden, skip it. @@ -1583,7 +1577,11 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj, continue; } - // Stop when RelCur's offset is past the current instruction. + // Stop when RelCur's offset is past the disassembled + // instruction/data. Note that it's possible the disassembled data + // is not the complete data: we might see the relocation printed in + // the middle of the data, but this matches the binutils objdump + // output. if (Offset >= Index + Size) break; |