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 @@ -5,12 +5,8 @@ ## and that only the specified executable sections are disassembled. ## Also show that no relocation sections are dumped because none are ## specified. -## FIXME: This is different behaviour to GNU objdump, which dumps the non- -## executable sections if requested explicitly. -## See https://bugs.llvm.org/show_bug.cgi?id=41897. # RUN: llvm-objdump -d -r %t.o --section=.text --section=.rodata \ -# RUN: | FileCheck %s --check-prefixes=DISASM,RELOC --implicit-check-not=.text2 \ -# RUN: --implicit-check-not=.rodata +# RUN: | FileCheck %s --check-prefixes=DISASM,RELOC --implicit-check-not=.text2 # DISASM: Disassembly of section .text: # DISASM-EMPTY: @@ -18,6 +14,12 @@ # 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: 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();