llvm-objdump: Don't print contents of BSS sections: it makes no sense and crashes llvm-objdump on relocated objects with large bss

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179589 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alexey Samsonov 2013-04-16 10:53:11 +00:00
parent 6334e1351f
commit 0eaa6f675c
2 changed files with 13 additions and 0 deletions

View File

@ -1,6 +1,8 @@
RUN: yaml2obj %p/Inputs/COFF/i386.yaml | llvm-objdump -s - | FileCheck %s -check-prefix COFF-i386
RUN: llvm-objdump -s %p/Inputs/trivial-object-test.elf-i386 \
RUN: | FileCheck %s -check-prefix ELF-i386
RUN: llvm-objdump -s %p/Inputs/shared-object-test.elf-i386 \
RUN: | FileCheck %s -check-prefix BSS
COFF-i386: file format
COFF-i386: Contents of section .text:
@ -17,3 +19,6 @@ ELF-i386: 0010 0000e8fc ffffffe8 fcffffff 8b442408 .............D$.
ELF-i386: 0020 83c40cc3 ....
ELF-i386: Contents of section .rodata.str1.1:
ELF-i386: 0024 48656c6c 6f20576f 726c6421 00 Hello World!.
BSS: Contents of section .bss:
BSS-NEXT: <skipping contents of bss section at [12c8, 12cc)>

View File

@ -468,11 +468,19 @@ static void PrintSectionContents(const ObjectFile *o) {
StringRef Name;
StringRef Contents;
uint64_t BaseAddr;
bool BSS;
if (error(si->getName(Name))) continue;
if (error(si->getContents(Contents))) continue;
if (error(si->getAddress(BaseAddr))) continue;
if (error(si->isBSS(BSS))) continue;
outs() << "Contents of section " << Name << ":\n";
if (BSS) {
outs() << format("<skipping contents of bss section at [%04" PRIx64
", %04" PRIx64 ")>\n", BaseAddr,
BaseAddr + Contents.size());
continue;
}
// Dump out the content as hex and printable ascii characters.
for (std::size_t addr = 0, end = Contents.size(); addr < end; addr += 16) {