コード例 #1
0
static bool isRequiredForExecution(const SectionRef &Section) {
  const ObjectFile *Obj = Section.getObject();
  if (auto *ELFObj = dyn_cast<object::ELFObjectFileBase>(Obj))
    return ELFObj->getSectionFlags(Section) & ELF::SHF_ALLOC;
  assert(isa<MachOObjectFile>(Obj));
  return true;
 }
コード例 #2
0
static bool isReadOnlyData(const SectionRef &Section) {
  const ObjectFile *Obj = Section.getObject();
  if (auto *ELFObj = dyn_cast<object::ELFObjectFileBase>(Obj))
    return !(ELFObj->getSectionFlags(Section) &
             (ELF::SHF_WRITE | ELF::SHF_EXECINSTR));
  assert(isa<MachOObjectFile>(Obj));
  return false;
}
コード例 #3
0
static bool isZeroInit(const SectionRef &Section) {
  const ObjectFile *Obj = Section.getObject();
  if (auto *ELFObj = dyn_cast<object::ELFObjectFileBase>(Obj))
    return ELFObj->getSectionType(Section) == ELF::SHT_NOBITS;

  auto *MachO = cast<MachOObjectFile>(Obj);
  unsigned SectionType = MachO->getSectionType(Section);
  return SectionType == MachO::S_ZEROFILL ||
         SectionType == MachO::S_GB_ZEROFILL;
}