aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2019-02-19 12:38:36 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2019-02-19 12:38:36 +0000
commitc5f2920038d98982788aa2cbe8c1610f7b180b1f (patch)
tree4d39f5998b86f21e25b819ad3de3611d6dd14491 /llvm/tools/llvm-objdump/llvm-objdump.cpp
parent6947acd9da6c38d3a1826d0c446caba545456085 (diff)
downloadllvm-c5f2920038d98982788aa2cbe8c1610f7b180b1f.zip
llvm-c5f2920038d98982788aa2cbe8c1610f7b180b1f.tar.gz
llvm-c5f2920038d98982788aa2cbe8c1610f7b180b1f.tar.bz2
[yaml2obj] - Do not skip zeroes blocks if there are relocations against them.
This is for -D -reloc combination. With this patch, we do not skip the zero bytes that have a relocation against them when -reloc is used. If -reloc is not used, then the behavior will be the same. Differential revision: https://reviews.llvm.org/D58174 llvm-svn: 354319
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 735025b..283a1f9 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -863,10 +863,6 @@ static void addPltEntries(const ObjectFile *Obj,
// returns the number of zero bytes that can be skipped when dumping the
// disassembly of the instructions in Buf.
static size_t countSkippableZeroBytes(ArrayRef<uint8_t> Buf) {
- // When -z or --disassemble-zeroes are given we always dissasemble them.
- if (DisassembleZeroes)
- return 0;
-
// Find the number of leading zeroes.
size_t N = 0;
while (N < Buf.size() && !Buf[N])
@@ -1284,12 +1280,22 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
if (Index >= End)
break;
- if (size_t N =
- countSkippableZeroBytes(Bytes.slice(Index, End - Index))) {
- outs() << "\t\t..." << '\n';
- Index += N;
- if (Index >= End)
- break;
+ // When -z or --disassemble-zeroes are given we always dissasemble them.
+ // Otherwise we might want to skip zero bytes we see.
+ if (!DisassembleZeroes) {
+ uint64_t MaxOffset = End - Index;
+ // For -reloc: print zero blocks patched by relocations, so that
+ // relocations can be shown in the dump.
+ if (RelCur != RelEnd)
+ MaxOffset = RelCur->getOffset() - Index;
+
+ if (size_t N =
+ countSkippableZeroBytes(Bytes.slice(Index, MaxOffset))) {
+ outs() << "\t\t..." << '\n';
+ Index += N;
+ if (Index >= End)
+ break;
+ }
}
// Disassemble a real instruction or a data when disassemble all is