[llvm] r221680 - llvm-objdump: Skip empty sections when dumping contents
David Majnemer
david.majnemer at gmail.com
Tue Nov 11 01:58:26 PST 2014
Author: majnemer
Date: Tue Nov 11 03:58:25 2014
New Revision: 221680
URL: http://llvm.org/viewvc/llvm-project?rev=221680&view=rev
Log:
llvm-objdump: Skip empty sections when dumping contents
Empty sections are just noise when using objdump.
This is similar to what binutils does.
Removed:
llvm/trunk/test/MC/Mips/elf-objdump.s
Modified:
llvm/trunk/test/MC/Mips/cpload.s
llvm/trunk/test/tools/llvm-objdump/coff-large-bss.test
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Modified: llvm/trunk/test/MC/Mips/cpload.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/cpload.s?rev=221680&r1=221679&r2=221680&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/cpload.s (original)
+++ llvm/trunk/test/MC/Mips/cpload.s Tue Nov 11 03:58:25 2014
@@ -25,12 +25,12 @@
# OBJ-O32: R_MIPS_LO16 _gp_disp
# OBJ-O32: addu $gp, $gp, $25
-# OBJ-N32: .text
+# OBJ-N32-NOT: .text
# OBJ-N32-NOT: lui $gp, 0
# OBJ-N32-NOT: addiu $gp, $gp, 0
# OBJ-N32-NOT: addu $gp, $gp, $25
-# OBJ-N64: .text
+# OBJ-N64-NOT: .text
# OBJ-N64-NOT: lui $gp, 0
# OBJ-N64-NOT: addiu $gp, $gp, 0
# OBJ-N64-NOT: addu $gp, $gp, $25
Removed: llvm/trunk/test/MC/Mips/elf-objdump.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/elf-objdump.s?rev=221679&view=auto
==============================================================================
--- llvm/trunk/test/MC/Mips/elf-objdump.s (original)
+++ llvm/trunk/test/MC/Mips/elf-objdump.s (removed)
@@ -1,11 +0,0 @@
-// 32 bit big endian
-// RUN: llvm-mc -filetype=obj -triple mips-unknown-linux %s -o - | llvm-objdump -d -triple mips-unknown-linux - | FileCheck %s
-// 32 bit little endian
-// RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux %s -o - | llvm-objdump -d -triple mips-unknown-linux - | FileCheck %s
-// 64 bit big endian
-// RUN: llvm-mc -filetype=obj -arch=mips64 -triple mips64-unknown-linux %s -o - | llvm-objdump -d -triple mips-unknown-linux - | FileCheck %s
-// 64 bit little endian
-// RUN: llvm-mc -filetype=obj -arch=mips64el -triple mips64el-unknown-linux %s -o - | llvm-objdump -d -triple mips-unknown-linux - | FileCheck %s
-
-// We just want to see if llvm-objdump works at all.
-// CHECK: .text
Modified: 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=221680&r1=221679&r2=221680&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/coff-large-bss.test (original)
+++ llvm/trunk/test/tools/llvm-objdump/coff-large-bss.test Tue Nov 11 03:58:25 2014
@@ -1,6 +1,3 @@
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)>
+: CHECK: <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=221680&r1=221679&r2=221680&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Tue Nov 11 03:58:25 2014
@@ -313,6 +313,8 @@ static void DisassembleObject(const Obje
uint64_t SectionAddr = Section.getAddress();
uint64_t SectSize = Section.getSize();
+ if (!SectSize)
+ continue;
// Make a list of all the symbols in this section.
std::vector<std::pair<uint64_t, StringRef>> Symbols;
@@ -514,11 +516,12 @@ static void PrintSectionContents(const O
if (error(Section.getName(Name)))
continue;
uint64_t BaseAddr = Section.getAddress();
- bool BSS = Section.isBSS();
+ uint64_t Size = Section.getSize();
+ if (!Size)
+ continue;
outs() << "Contents of section " << Name << ":\n";
- if (BSS) {
- uint64_t Size = Section.getSize();
+ if (Section.isBSS()) {
outs() << format("<skipping contents of bss section at [%04" PRIx64
", %04" PRIx64 ")>\n",
BaseAddr, BaseAddr + Size);
More information about the llvm-commits
mailing list