[PATCH] D48472: [ELF] Change isSectionData to exclude SHF_EXECINSTR
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 21 23:28:10 PDT 2018
MaskRay updated this revision to Diff 152431.
MaskRay added a comment.
Update isSectionBSS as well (no impact)
Repository:
rL LLVM
https://reviews.llvm.org/D48472
Files:
include/llvm/Object/ELFObjectFile.h
test/Object/objdump-sectionheaders.test
Index: test/Object/objdump-sectionheaders.test
===================================================================
--- test/Object/objdump-sectionheaders.test
+++ 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
Index: include/llvm/Object/ELFObjectFile.h
===================================================================
--- include/llvm/Object/ELFObjectFile.h
+++ include/llvm/Object/ELFObjectFile.h
@@ -709,15 +709,16 @@
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>
bool ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec) const {
const Elf_Shdr *EShdr = getSection(Sec);
- return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
- EShdr->sh_type == ELF::SHT_NOBITS;
+ return EShdr->sh_type == ELF::SHT_NOBITS &&
+ EShdr->sh_flags & ELF::SHF_ALLOC;
}
template <class ELFT>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48472.152431.patch
Type: text/x-patch
Size: 1616 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180622/dc6dc79d/attachment.bin>
More information about the llvm-commits
mailing list