diff options
author | Fangrui Song <maskray@google.com> | 2019-06-17 09:59:55 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-06-17 09:59:55 +0000 |
commit | 46f9cbe28d4f5b56c5e0c65a4fb02571a57fc8ae (patch) | |
tree | 8006729f13931c3358eb1d3c7603d93383841317 /llvm/tools/llvm-objdump | |
parent | ac14f7b10cffe2be548607269e036244cd16acc3 (diff) | |
download | bcm5719-llvm-46f9cbe28d4f5b56c5e0c65a4fb02571a57fc8ae.tar.gz bcm5719-llvm-46f9cbe28d4f5b56c5e0c65a4fb02571a57fc8ae.zip |
[llvm-objdump] Use %08 instead of %016 to print leading addresses for 32-bit binaries
Reviewed By: grimar
Differential Revision: https://reviews.llvm.org/D63398
llvm-svn: 363539
Diffstat (limited to 'llvm/tools/llvm-objdump')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 1d211d61611..7305f2bf634 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -612,9 +612,8 @@ static bool isArmElf(const ObjectFile *Obj) { } static void printRelocation(const RelocationRef &Rel, uint64_t Address, - uint8_t AddrSize) { - StringRef Fmt = - AddrSize > 4 ? "\t\t%016" PRIx64 ": " : "\t\t\t%08" PRIx64 ": "; + bool Is64Bits) { + StringRef Fmt = Is64Bits ? "\t\t%016" PRIx64 ": " : "\t\t\t%08" PRIx64 ": "; SmallString<16> Name; SmallString<32> Val; Rel.getTypeName(Name); @@ -704,7 +703,7 @@ public: auto PrintReloc = [&]() -> void { while ((RelCur != RelEnd) && (RelCur->getOffset() <= Address.Address)) { if (RelCur->getOffset() == Address.Address) { - printRelocation(*RelCur, Address.Address, 4); + printRelocation(*RelCur, Address.Address, false); return; } ++RelCur; @@ -1032,6 +1031,7 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj, std::map<SectionRef, std::vector<RelocationRef>> RelocMap; if (InlineRelocs) RelocMap = getRelocsMap(*Obj); + bool Is64Bits = Obj->getBytesInAddress() > 4; // Create a mapping from virtual address to symbol name. This is used to // pretty print the symbols while disassembling. @@ -1229,7 +1229,7 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj, outs() << '\n'; if (!NoLeadingAddr) - outs() << format("%016" PRIx64 " ", + outs() << format(Is64Bits ? "%016" PRIx64 " " : "%08" PRIx64 " ", SectionAddr + Start + VMAAdjustment); StringRef SymbolName = std::get<1>(Symbols[SI]); @@ -1401,8 +1401,7 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj, Offset += AdjustVMA; } - printRelocation(*RelCur, SectionAddr + Offset, - Obj->getBytesInAddress()); + printRelocation(*RelCur, SectionAddr + Offset, Is64Bits); ++RelCur; } } |