[PATCH] D49372: [llvm-objdump] - Stop reporting bogus section IDs.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 18 01:39:47 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL337361: [llvm-objdump] - Stop reporting bogus section IDs. (authored by grimar, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D49372?vs=155666&id=156024#toc
Repository:
rL LLVM
https://reviews.llvm.org/D49372
Files:
llvm/trunk/test/tools/llvm-objdump/X86/section-index.s
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Index: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
@@ -1815,7 +1815,6 @@
void llvm::PrintSectionHeaders(const ObjectFile *Obj) {
outs() << "Sections:\n"
"Idx Name Size Address Type\n";
- unsigned i = 0;
for (const SectionRef &Section : ToolSectionFilter(*Obj)) {
StringRef Name;
error(Section.getName(Name));
@@ -1826,9 +1825,9 @@
bool BSS = Section.isBSS();
std::string Type = (std::string(Text ? "TEXT " : "") +
(Data ? "DATA " : "") + (BSS ? "BSS" : ""));
- outs() << format("%3d %-13s %08" PRIx64 " %016" PRIx64 " %s\n", i,
- Name.str().c_str(), Size, Address, Type.c_str());
- ++i;
+ outs() << format("%3d %-13s %08" PRIx64 " %016" PRIx64 " %s\n",
+ Section.getIndex(), Name.str().c_str(), Size, Address,
+ Type.c_str());
}
}
Index: llvm/trunk/test/tools/llvm-objdump/X86/section-index.s
===================================================================
--- llvm/trunk/test/tools/llvm-objdump/X86/section-index.s
+++ llvm/trunk/test/tools/llvm-objdump/X86/section-index.s
@@ -0,0 +1,25 @@
+# RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t
+
+# RUN: llvm-objdump -section-headers %t | FileCheck %s
+# CHECK: Idx Name
+# CHECK: 3 .foo
+# CHECK-NEXT: 4 .bar
+# CHECK-NEXT: 5 .zed
+
+## Check we report the valid section index
+## when requesting a specific section.
+# RUN: llvm-objdump -section-headers -section=.bar %t \
+# RUN: | FileCheck %s --check-prefix=BAR
+# BAR: Idx Name
+# BAR-NEXT: 4 .bar
+# BAR-NOT: foo
+# BAR-NOT: zed
+
+.section .foo, "ax", %progbits
+nop
+
+.section .bar, "ax", %progbits
+nop
+
+.section .zed, "ax", %progbits
+nop
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49372.156024.patch
Type: text/x-patch
Size: 1928 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180718/08be3c42/attachment.bin>
More information about the llvm-commits
mailing list