llvm.org GIT mirror llvm / e3aafcc
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212953 91177308-0d34-0410-b5e6-96231b3b80d8 David Majnemer 6 years ago
3 changed file(s) with 16 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
0 RUN: llvm-objdump -s %p/Inputs/large-bss.obj.coff-i386 | FileCheck %s
1
2 ; CHECK: Contents of section .text:
3 : CHECK-NEXT: Contents of section .data:
4 : CHECK-NEXT: Contents of section .bss:
5 : CHECK-NEXT:
627627 bool BSS;
628628 if (error(Section.getName(Name)))
629629 continue;
630 if (error(Section.getContents(Contents)))
631 continue;
632630 if (error(Section.getAddress(BaseAddr)))
633631 continue;
634632 if (error(Section.isBSS(BSS)))
636634
637635 outs() << "Contents of section " << Name << ":\n";
638636 if (BSS) {
637 uint64_t Size;
638 if (error(Section.getSize(Size)))
639 continue;
639640 outs() << format("
640 ", %04" PRIx64 ")>\n", BaseAddr,
641 BaseAddr + Contents.size());
642 continue;
643 }
641 ", %04" PRIx64 ")>\n",
642 BaseAddr, BaseAddr + Size);
643 continue;
644 }
645
646 if (error(Section.getContents(Contents)))
647 continue;
644648
645649 // Dump out the content as hex and printable ascii characters.
646650 for (std::size_t addr = 0, end = Contents.size(); addr < end; addr += 16) {