diff options
author | Petar Jovanovic <petar.jovanovic@mips.com> | 2018-10-19 22:16:49 +0000 |
---|---|---|
committer | Petar Jovanovic <petar.jovanovic@mips.com> | 2018-10-19 22:16:49 +0000 |
commit | 8d947bad093b0920aec2b7cea31da7f723612367 (patch) | |
tree | 0519e9301cb13a9c72d182d5d4d1d1b319e31fd0 /llvm/tools/llvm-objdump/llvm-objdump.cpp | |
parent | 8a91cf1cc511d9f7a9a46b807982615cf548f911 (diff) | |
download | llvm-8d947bad093b0920aec2b7cea31da7f723612367.zip llvm-8d947bad093b0920aec2b7cea31da7f723612367.tar.gz llvm-8d947bad093b0920aec2b7cea31da7f723612367.tar.bz2 |
[llvm-objdump] Fix --file-headers (-f) option
Changed the format call to match the surrounding code. Previously it was
printing an unsigned int while the return type being printed was
long unsigned int or wider. This caused problems for big-endian systems
which were discovered on mips64.
Also, the printed address had less characters than it should because the
character count was directly obtained from the number of bytes in the
address.
The tests were adapted to fit this fix and now use longer addresses.
Patch by Milos Stojanovic.
Differential Revision: https://reviews.llvm.org/D53403
llvm-svn: 344818
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 64c3823..7107966 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -2220,8 +2220,11 @@ static void printFileHeaders(const ObjectFile *o) { Expected<uint64_t> StartAddrOrErr = o->getStartAddress(); if (!StartAddrOrErr) report_error(o->getFileName(), StartAddrOrErr.takeError()); + + StringRef Fmt = o->getBytesInAddress() > 4 ? "%016" PRIx64 : "%08" PRIx64; + uint64_t Address = StartAddrOrErr.get(); outs() << "start address: " - << format("0x%0*x", o->getBytesInAddress(), StartAddrOrErr.get()) + << "0x" << format(Fmt.data(), Address) << "\n"; } |