[PATCH] D62848: [llvm-objdump] - Disassemble non-executable sections if specifically requested.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 4 03:28:41 PDT 2019


grimar created this revision.
grimar added reviewers: jhenderson, jakehehrlich, rupprecht, MaskRay.

This is https://bugs.llvm.org/show_bug.cgi?id=41897.

Previously `-d` + `-j .data` had no effect, that wasn't consistent with GNU,
which proccesses `.data` in that case. With this patch we follow this behavior.


https://reviews.llvm.org/D62848

Files:
  test/tools/llvm-objdump/X86/section-filter-relocs.test
  tools/llvm-objdump/llvm-objdump.cpp


Index: tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- tools/llvm-objdump/llvm-objdump.cpp
+++ tools/llvm-objdump/llvm-objdump.cpp
@@ -1095,7 +1095,8 @@
   array_pod_sort(AbsoluteSymbols.begin(), AbsoluteSymbols.end());
 
   for (const SectionRef &Section : ToolSectionFilter(*Obj)) {
-    if (!DisassembleAll && (!Section.isText() || Section.isVirtual()))
+    if (FilterSections.empty() && !DisassembleAll &&
+        (!Section.isText() || Section.isVirtual()))
       continue;
 
     uint64_t SectionAddr = Section.getAddress();
Index: test/tools/llvm-objdump/X86/section-filter-relocs.test
===================================================================
--- test/tools/llvm-objdump/X86/section-filter-relocs.test
+++ test/tools/llvm-objdump/X86/section-filter-relocs.test
@@ -18,7 +18,13 @@
 # DISASM-NEXT:  400: e8 00 00 00 00                callq   0 <.text+0x5>
 # RELOC-NEXT:                      00000401:  R_X86_64_PC32        foo+1
 # RELOC-NEXT:                      00000401:  R_X86_64_GOT32       foo
-
+# DISASM:       Disassembly of section .rodata:
+# DISASM-EMPTY:
+# DISASM-NEXT:  0000000000000000 .rodata:
+# DISASM-NEXT:  0: 00 00                           addb    %al, (%rax)
+# RELOC-NEXT:              0000000000000000:  R_X86_64_NONE        foo
+# DISASM-NEXT:  2: 00 00                           addb    %al, (%rax)
+  
 --- !ELF
 FileHeader:
   Class:   ELFCLASS64


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62848.202891.patch
Type: text/x-patch
Size: 1457 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190604/bf901b0e/attachment.bin>


More information about the llvm-commits mailing list