[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 20:45:53 PDT 2018


MaskRay created this revision.
MaskRay added reviewers: jyknight, Bigcheese.
Herald added a subscriber: llvm-commits.
MaskRay edited the summary of this revision.

This affects what sections are displayed as "DATA" in llvm-objdump.
The other user llvm-size is unaffected.

Before, a section can be both TEXT and DATA which seems a bit 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.


Repository:
  rL LLVM

https://reviews.llvm.org/D48472

Files:
  include/llvm/Object/ELFObjectFile.h


Index: include/llvm/Object/ELFObjectFile.h
===================================================================
--- include/llvm/Object/ELFObjectFile.h
+++ include/llvm/Object/ELFObjectFile.h
@@ -709,8 +709,9 @@
 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>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48472.152428.patch
Type: text/x-patch
Size: 630 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180622/b42f777f/attachment.bin>


More information about the llvm-commits mailing list