aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-07-14 16:20:14 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-07-14 16:20:14 +0000
commit8f6b04cb57c5fa127c1d50cb87078852f25ae5c2 (patch)
treeb9ad7cd586a9f16c57406d3c85a4e5d94208efaa /llvm/tools/llvm-objdump/llvm-objdump.cpp
parent6cdb0b8051a082b32cea1130f7204ccddda65c10 (diff)
downloadllvm-8f6b04cb57c5fa127c1d50cb87078852f25ae5c2.zip
llvm-8f6b04cb57c5fa127c1d50cb87078852f25ae5c2.tar.gz
llvm-8f6b04cb57c5fa127c1d50cb87078852f25ae5c2.tar.bz2
llvm-objdump: Handle BSS sections larger than the object file
The size of the uninitialized sections, like BSS, can exceed the size of the object file. Do not attempt to grab the contents of such sections. llvm-svn: 212953
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 309bf23..3cd48e7 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -628,8 +628,6 @@ static void PrintSectionContents(const ObjectFile *Obj) {
bool BSS;
if (error(Section.getName(Name)))
continue;
- if (error(Section.getContents(Contents)))
- continue;
if (error(Section.getAddress(BaseAddr)))
continue;
if (error(Section.isBSS(BSS)))
@@ -637,12 +635,18 @@ static void PrintSectionContents(const ObjectFile *Obj) {
outs() << "Contents of section " << Name << ":\n";
if (BSS) {
+ uint64_t Size;
+ if (error(Section.getSize(Size)))
+ continue;
outs() << format("<skipping contents of bss section at [%04" PRIx64
- ", %04" PRIx64 ")>\n", BaseAddr,
- BaseAddr + Contents.size());
+ ", %04" PRIx64 ")>\n",
+ BaseAddr, BaseAddr + Size);
continue;
}
+ if (error(Section.getContents(Contents)))
+ continue;
+
// Dump out the content as hex and printable ascii characters.
for (std::size_t addr = 0, end = Contents.size(); addr < end; addr += 16) {
outs() << format(" %04" PRIx64 " ", BaseAddr + addr);