Пример #1
0
SectionKind::Kind
ELFTargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
  SectionKind::Kind Kind = TargetAsmInfo::SectionKindForGlobal(GV);

  if (Kind != SectionKind::Data)
    return Kind;

  // Decide, whether we need data.rel stuff
  const GlobalVariable* GVar = dyn_cast<GlobalVariable>(GV);
  if (GVar->hasInitializer()) {
    Constant *C = GVar->getInitializer();
    bool isConstant = GVar->isConstant();
    unsigned Reloc = RelocBehaviour();
    if (Reloc != Reloc::None && C->ContainsRelocations(Reloc))
      return (C->ContainsRelocations(Reloc::Global) ?
              (isConstant ?
               SectionKind::DataRelRO : SectionKind::DataRel) :
              (isConstant ?
               SectionKind::DataRelROLocal : SectionKind::DataRelLocal));
  }

  return Kind;
}