[llvm] r335405 - [ELF] Change isSectionData to exclude SHF_EXECINSTR
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 22 17:15:33 PDT 2018
Author: maskray
Date: Fri Jun 22 17:15:33 2018
New Revision: 335405
URL: http://llvm.org/viewvc/llvm-project?rev=335405&view=rev
Log:
[ELF] Change isSectionData to exclude SHF_EXECINSTR
Summary:
This affects what sections are displayed as "DATA" in llvm-objdump.
The other user llvm-size is unaffected.
Before, a "TEXT" section is also "DATA", which seems weird.
The sh_flags condition matches that of bfd's SEC_DATA but the sh_type
condition uses (== SHF_PROGBITS) instead of bfd's (!= SHT_NOBITS).
bfd's SEC_DATA is not appealing as so many sections will be shown as DATA.
Reviewers: jyknight, Bigcheese
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D48472
Modified:
llvm/trunk/include/llvm/Object/ELFObjectFile.h
llvm/trunk/test/Object/objdump-sectionheaders.test
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=335405&r1=335404&r2=335405&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Fri Jun 22 17:15:33 2018
@@ -709,8 +709,9 @@ bool ELFObjectFile<ELFT>::isSectionText(
template <class ELFT>
bool ELFObjectFile<ELFT>::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 <class ELFT>
Modified: llvm/trunk/test/Object/objdump-sectionheaders.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/objdump-sectionheaders.test?rev=335405&r1=335404&r2=335405&view=diff
==============================================================================
--- llvm/trunk/test/Object/objdump-sectionheaders.test (original)
+++ llvm/trunk/test/Object/objdump-sectionheaders.test Fri Jun 22 17:15:33 2018
@@ -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
More information about the llvm-commits
mailing list