diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index 82e4aa459a7..4e9e81a7b9e 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -709,8 +709,9 @@ bool ELFObjectFile::isSectionText(DataRefImpl Sec) const { template bool ELFObjectFile::isSectionData(DataRefImpl Sec) const { const Elf_Shdr *EShdr = getSection(Sec); - return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) && - EShdr->sh_type == ELF::SHT_PROGBITS; + return EShdr->sh_type == ELF::SHT_PROGBITS && + EShdr->sh_flags & ELF::SHF_ALLOC && + !(EShdr->sh_flags & ELF::SHF_EXECINSTR); } template diff --git a/test/Object/objdump-sectionheaders.test b/test/Object/objdump-sectionheaders.test index bc2478cea2f..efdd6bb5fc9 100644 --- a/test/Object/objdump-sectionheaders.test +++ b/test/Object/objdump-sectionheaders.test @@ -7,7 +7,7 @@ ; CHECK: Sections: ; CHECK: Idx Name Size Address Type ; CHECK: 0 00000000 0000000000000000 -; CHECK: 1 .text 00000026 0000000000000000 TEXT DATA +; CHECK: 1 .text 00000026 0000000000000000 TEXT ; CHECK: 2 .rodata.str1.1 0000000d 0000000000000026 DATA ; CHECK: 3 .note.GNU-stack 00000000 0000000000000033 ; CHECK: 4 .rela.text 00000048 0000000000000038