Lines Matching refs:Sec
53 using SectionPred = std::function<bool(const SectionBase &Sec)>;
55 static bool isDebugSection(const SectionBase &Sec) { in isDebugSection() argument
56 return StringRef(Sec.Name).startswith(".debug") || Sec.Name == ".gdb_index"; in isDebugSection()
59 static bool isDWOSection(const SectionBase &Sec) { in isDWOSection() argument
60 return StringRef(Sec.Name).endswith(".dwo"); in isDWOSection()
63 static bool onlyKeepDWOPred(const Object &Obj, const SectionBase &Sec) { in onlyKeepDWOPred() argument
65 if (&Sec == Obj.SectionNames) in onlyKeepDWOPred()
69 return !isDWOSection(Sec); in onlyKeepDWOPred()
101 static void setSectionFlagsAndType(SectionBase &Sec, SectionFlag Flags) { in setSectionFlagsAndType() argument
102 Sec.Flags = getSectionFlagsPreserveMask(Sec.Flags, getNewShfFlags(Flags)); in setSectionFlagsAndType()
107 if (Sec.Type == SHT_NOBITS && in setSectionFlagsAndType()
108 (!(Sec.Flags & ELF::SHF_ALLOC) || in setSectionFlagsAndType()
110 Sec.Type = SHT_PROGBITS; in setSectionFlagsAndType()
177 for (auto &Sec : Obj.sections()) { in dumpSectionToFile() local
178 if (Sec.Name == SecName) { in dumpSectionToFile()
179 if (Sec.Type == SHT_NOBITS) in dumpSectionToFile()
184 FileOutputBuffer::create(Filename, Sec.OriginalData.size()); in dumpSectionToFile()
188 std::copy(Sec.OriginalData.begin(), Sec.OriginalData.end(), in dumpSectionToFile()
199 static bool isCompressable(const SectionBase &Sec) { in isCompressable() argument
200 return !(Sec.Flags & ELF::SHF_COMPRESSED) && in isCompressable()
201 StringRef(Sec.Name).startswith(".debug"); in isCompressable()
211 for (auto &Sec : Obj.sections()) in replaceDebugSections() local
212 if (ShouldReplace(Sec)) in replaceDebugSections()
213 ToReplace.push_back(&Sec); in replaceDebugSections()
325 for (SectionBase &Sec : Obj.sections()) in updateAndRemoveSymbols()
326 Sec.markSymbols(); in updateAndRemoveSymbols()
375 RemovePred = [&Config](const SectionBase &Sec) { in replaceAndRemoveSections() argument
376 return Config.ToRemove.matches(Sec.Name); in replaceAndRemoveSections()
381 RemovePred = [RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
382 return isDWOSection(Sec) || RemovePred(Sec); in replaceAndRemoveSections()
386 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
387 return onlyKeepDWOPred(Obj, Sec) || RemovePred(Sec); in replaceAndRemoveSections()
391 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
392 if (RemovePred(Sec)) in replaceAndRemoveSections()
394 if ((Sec.Flags & SHF_ALLOC) != 0) in replaceAndRemoveSections()
396 if (&Sec == Obj.SectionNames) in replaceAndRemoveSections()
398 switch (Sec.Type) { in replaceAndRemoveSections()
405 return isDebugSection(Sec); in replaceAndRemoveSections()
409 RemovePred = [RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
410 return RemovePred(Sec) || Sec.ParentSegment == nullptr; in replaceAndRemoveSections()
415 RemovePred = [RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
416 return RemovePred(Sec) || isDebugSection(Sec); in replaceAndRemoveSections()
421 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
422 if (RemovePred(Sec)) in replaceAndRemoveSections()
424 if (&Sec == Obj.SectionNames) in replaceAndRemoveSections()
426 return (Sec.Flags & SHF_ALLOC) == 0 && Sec.ParentSegment == nullptr; in replaceAndRemoveSections()
430 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
431 if (RemovePred(Sec)) in replaceAndRemoveSections()
433 if (&Sec == Obj.SectionNames) in replaceAndRemoveSections()
435 if (StringRef(Sec.Name).startswith(".gnu.warning")) in replaceAndRemoveSections()
441 if (Sec.Type == SHT_ARM_ATTRIBUTES) in replaceAndRemoveSections()
443 if (Sec.ParentSegment != nullptr) in replaceAndRemoveSections()
445 return (Sec.Flags & SHF_ALLOC) == 0; in replaceAndRemoveSections()
449 RemovePred = [RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
450 if (RemovePred(Sec)) in replaceAndRemoveSections()
452 if (Sec.Type == SHT_LLVM_PART_EHDR || Sec.Type == SHT_LLVM_PART_PHDR) in replaceAndRemoveSections()
454 return (Sec.Flags & SHF_ALLOC) != 0 && !Sec.ParentSegment; in replaceAndRemoveSections()
460 RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
462 if (Config.OnlySection.matches(Sec.Name)) in replaceAndRemoveSections()
466 if (RemovePred(Sec)) in replaceAndRemoveSections()
470 if (Obj.SectionNames == &Sec) in replaceAndRemoveSections()
472 if (Obj.SymbolTable == &Sec || in replaceAndRemoveSections()
473 (Obj.SymbolTable && Obj.SymbolTable->getStrTab() == &Sec)) in replaceAndRemoveSections()
482 RemovePred = [&Config, RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
484 if (Config.KeepSection.matches(Sec.Name)) in replaceAndRemoveSections()
487 return RemovePred(Sec); in replaceAndRemoveSections()
498 RemovePred = [&Obj, RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
499 if (&Sec == Obj.SymbolTable || &Sec == Obj.SymbolTable->getStrTab()) in replaceAndRemoveSections()
501 return RemovePred(Sec); in replaceAndRemoveSections()
533 SectionBase *Sec = Obj.findSection(SymInfo.SectionName); in addSymbol() local
534 uint64_t Value = Sec ? Sec->Addr + SymInfo.Value : SymInfo.Value; in addSymbol()
580 SymInfo.SymbolName, Bind, Type, Sec, Value, Visibility, in addSymbol()
581 Sec ? (uint16_t)SYMBOL_SIMPLE_INDEX : (uint16_t)SHN_ABS, 0); in addSymbol()
610 [&Obj](const SectionBase &Sec) { return onlyKeepDWOPred(Obj, Sec); }); in handleArgs() argument
633 for (SectionBase &Sec : Obj.sections()) { in handleArgs()
634 auto I = Config.SetSectionAlignment.find(Sec.Name); in handleArgs()
636 Sec.Align = I->second; in handleArgs()
641 for (auto &Sec : Obj.sections()) in handleArgs() local
642 if (Sec.Flags & SHF_ALLOC && Sec.Type != SHT_NOTE) in handleArgs()
643 Sec.Type = SHT_NOBITS; in handleArgs()
680 for (auto &Sec : Obj.sections()) { in handleArgs() local
681 const auto Iter = Config.SetSectionFlags.find(Sec.Name); in handleArgs()
684 setSectionFlagsAndType(Sec, SFU.NewFlags); in handleArgs()
686 auto It2 = Config.SetSectionType.find(Sec.Name); in handleArgs()
688 Sec.Type = It2->second; in handleArgs()
695 for (SectionBase &Sec : Obj.sections()) { in handleArgs()
696 auto *RelocSec = dyn_cast<RelocationSectionBase>(&Sec); in handleArgs()
697 const auto Iter = Config.SectionsToRename.find(Sec.Name); in handleArgs()
700 Sec.Name = std::string(SR.NewName); in handleArgs()
702 setSectionFlagsAndType(Sec, SR.NewFlags.value()); in handleArgs()
703 RenamedSections.insert(&Sec); in handleArgs()
704 } else if (RelocSec && !(Sec.Flags & SHF_ALLOC)) in handleArgs()
727 for (SectionBase &Sec : Obj.sections()) { in handleArgs()
728 if (Sec.Flags & SHF_ALLOC) { in handleArgs()
729 Sec.Name = (Config.AllocSectionsPrefix + Sec.Name).str(); in handleArgs()
730 PrefixedSections.insert(&Sec); in handleArgs()
731 } else if (auto *RelocSec = dyn_cast<RelocationSectionBase>(&Sec)) { in handleArgs()
746 Sec.Name = (RelocSec->getNamePrefix() + TargetSec->Name).str(); in handleArgs()
748 Sec.Name = (RelocSec->getNamePrefix() + Config.AllocSectionsPrefix + in handleArgs()