[llvm] r212953 - llvm-objdump: Handle BSS sections larger than the object file
David Majnemer
david.majnemer at gmail.com
Mon Jul 14 09:20:14 PDT 2014
Author: majnemer
Date: Mon Jul 14 11:20:14 2014
New Revision: 212953
URL: http://llvm.org/viewvc/llvm-project?rev=212953&view=rev
Log:
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.
Added:
llvm/trunk/test/tools/llvm-objdump/Inputs/large-bss.obj.coff-i386
llvm/trunk/test/tools/llvm-objdump/coff-large-bss.test
Modified:
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Added: llvm/trunk/test/tools/llvm-objdump/Inputs/large-bss.obj.coff-i386
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/Inputs/large-bss.obj.coff-i386?rev=212953&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/llvm-objdump/Inputs/large-bss.obj.coff-i386 (added) and llvm/trunk/test/tools/llvm-objdump/Inputs/large-bss.obj.coff-i386 Mon Jul 14 11:20:14 2014 differ
Added: llvm/trunk/test/tools/llvm-objdump/coff-large-bss.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/coff-large-bss.test?rev=212953&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/coff-large-bss.test (added)
+++ llvm/trunk/test/tools/llvm-objdump/coff-large-bss.test Mon Jul 14 11:20:14 2014
@@ -0,0 +1,6 @@
+RUN: llvm-objdump -s %p/Inputs/large-bss.obj.coff-i386 | FileCheck %s
+
+; CHECK: Contents of section .text:
+: CHECK-NEXT: Contents of section .data:
+: CHECK-NEXT: Contents of section .bss:
+: CHECK-NEXT: <skipping contents of bss section at [0000, 010f)>
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=212953&r1=212952&r2=212953&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Mon Jul 14 11:20:14 2014
@@ -628,8 +628,6 @@ static void PrintSectionContents(const O
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 O
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);
More information about the llvm-commits
mailing list