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") || in isDebugSection()
57 StringRef(Sec.Name).startswith(".zdebug") || Sec.Name == ".gdb_index"; in isDebugSection()
60 static bool isDWOSection(const SectionBase &Sec) { in isDWOSection() argument
61 return StringRef(Sec.Name).endswith(".dwo"); in isDWOSection()
64 static bool onlyKeepDWOPred(const Object &Obj, const SectionBase &Sec) { in onlyKeepDWOPred() argument
66 if (&Sec == Obj.SectionNames) in onlyKeepDWOPred()
70 return !isDWOSection(Sec); in onlyKeepDWOPred()
102 static void setSectionFlagsAndType(SectionBase &Sec, SectionFlag Flags) { in setSectionFlagsAndType() argument
103 Sec.Flags = getSectionFlagsPreserveMask(Sec.Flags, getNewShfFlags(Flags)); in setSectionFlagsAndType()
108 if (Sec.Type == SHT_NOBITS && in setSectionFlagsAndType()
109 (!(Sec.Flags & ELF::SHF_ALLOC) || in setSectionFlagsAndType()
111 Sec.Type = SHT_PROGBITS; in setSectionFlagsAndType()
272 auto OnlyKeepDWOPred = [&DWOFile](const SectionBase &Sec) { in splitDWOToFile() argument
273 return onlyKeepDWOPred(**DWOFile, Sec); in splitDWOToFile()
292 for (auto &Sec : Obj.sections()) { in dumpSectionToFile() local
293 if (Sec.Name == SecName) { in dumpSectionToFile()
294 if (Sec.Type == SHT_NOBITS) in dumpSectionToFile()
299 FileOutputBuffer::create(Filename, Sec.OriginalData.size()); in dumpSectionToFile()
303 std::copy(Sec.OriginalData.begin(), Sec.OriginalData.end(), in dumpSectionToFile()
314 static bool isCompressable(const SectionBase &Sec) { in isCompressable() argument
315 return !(Sec.Flags & ELF::SHF_COMPRESSED) && in isCompressable()
316 StringRef(Sec.Name).startswith(".debug"); in isCompressable()
327 for (auto &Sec : Obj.sections()) in replaceDebugSections() local
328 if (ShouldReplace(Sec)) in replaceDebugSections()
329 ToReplace.push_back(&Sec); in replaceDebugSections()
344 for (auto &Sec : Obj.sections()) in replaceDebugSections() local
345 Sec.replaceSectionReferences(FromTo); in replaceDebugSections()
347 RemovePred = [ShouldReplace, RemovePred](const SectionBase &Sec) { in replaceDebugSections() argument
348 return ShouldReplace(Sec) || RemovePred(Sec); in replaceDebugSections()
414 for (SectionBase &Sec : Obj.sections()) in updateAndRemoveSymbols()
415 Sec.markSymbols(); in updateAndRemoveSymbols()
460 RemovePred = [&Config](const SectionBase &Sec) { in replaceAndRemoveSections() argument
461 return Config.ToRemove.matches(Sec.Name); in replaceAndRemoveSections()
466 RemovePred = [RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
467 return isDWOSection(Sec) || RemovePred(Sec); in replaceAndRemoveSections()
471 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
472 return onlyKeepDWOPred(Obj, Sec) || RemovePred(Sec); in replaceAndRemoveSections()
476 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
477 if (RemovePred(Sec)) in replaceAndRemoveSections()
479 if ((Sec.Flags & SHF_ALLOC) != 0) in replaceAndRemoveSections()
481 if (&Sec == Obj.SectionNames) in replaceAndRemoveSections()
483 switch (Sec.Type) { in replaceAndRemoveSections()
490 return isDebugSection(Sec); in replaceAndRemoveSections()
494 RemovePred = [RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
495 return RemovePred(Sec) || Sec.ParentSegment == nullptr; in replaceAndRemoveSections()
500 RemovePred = [RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
501 return RemovePred(Sec) || isDebugSection(Sec); in replaceAndRemoveSections()
506 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
507 if (RemovePred(Sec)) in replaceAndRemoveSections()
509 if (&Sec == Obj.SectionNames) in replaceAndRemoveSections()
511 return (Sec.Flags & SHF_ALLOC) == 0 && Sec.ParentSegment == nullptr; in replaceAndRemoveSections()
515 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
516 if (RemovePred(Sec)) in replaceAndRemoveSections()
518 if (&Sec == Obj.SectionNames) in replaceAndRemoveSections()
520 if (StringRef(Sec.Name).startswith(".gnu.warning")) in replaceAndRemoveSections()
526 if (Sec.Type == SHT_ARM_ATTRIBUTES) in replaceAndRemoveSections()
528 if (Sec.ParentSegment != nullptr) in replaceAndRemoveSections()
530 return (Sec.Flags & SHF_ALLOC) == 0; in replaceAndRemoveSections()
534 RemovePred = [RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
535 if (RemovePred(Sec)) in replaceAndRemoveSections()
537 if (Sec.Type == SHT_LLVM_PART_EHDR || Sec.Type == SHT_LLVM_PART_PHDR) in replaceAndRemoveSections()
539 return (Sec.Flags & SHF_ALLOC) != 0 && !Sec.ParentSegment; in replaceAndRemoveSections()
545 RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
547 if (Config.OnlySection.matches(Sec.Name)) in replaceAndRemoveSections()
551 if (RemovePred(Sec)) in replaceAndRemoveSections()
555 if (Obj.SectionNames == &Sec) in replaceAndRemoveSections()
557 if (Obj.SymbolTable == &Sec || in replaceAndRemoveSections()
558 (Obj.SymbolTable && Obj.SymbolTable->getStrTab() == &Sec)) in replaceAndRemoveSections()
567 RemovePred = [&Config, RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
569 if (Config.KeepSection.matches(Sec.Name)) in replaceAndRemoveSections()
572 return RemovePred(Sec); in replaceAndRemoveSections()
583 RemovePred = [&Obj, RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
584 if (&Sec == Obj.SymbolTable || &Sec == Obj.SymbolTable->getStrTab()) in replaceAndRemoveSections()
586 return RemovePred(Sec); in replaceAndRemoveSections()
658 for (SectionBase &Sec : Obj.sections()) { in handleArgs()
659 const auto Iter = Config.SectionsToRename.find(Sec.Name); in handleArgs()
662 Sec.Name = std::string(SR.NewName); in handleArgs()
664 setSectionFlagsAndType(Sec, SR.NewFlags.getValue()); in handleArgs()
674 for (SectionBase &Sec : Obj.sections()) { in handleArgs()
675 if (Sec.Flags & SHF_ALLOC) { in handleArgs()
676 Sec.Name = (Config.AllocSectionsPrefix + Sec.Name).str(); in handleArgs()
677 PrefixedSections.insert(&Sec); in handleArgs()
678 } else if (auto *RelocSec = dyn_cast<RelocationSectionBase>(&Sec)) { in handleArgs()
689 switch (Sec.Type) { in handleArgs()
705 Sec.Name = (prefix + TargetSec->Name).str(); in handleArgs()
707 Sec.Name = in handleArgs()
715 for (SectionBase &Sec : Obj.sections()) { in handleArgs()
716 auto I = Config.SetSectionAlignment.find(Sec.Name); in handleArgs()
718 Sec.Align = I->second; in handleArgs()
723 for (auto &Sec : Obj.sections()) in handleArgs() local
724 if (Sec.Flags & SHF_ALLOC && Sec.Type != SHT_NOTE) in handleArgs()
725 Sec.Type = SHT_NOBITS; in handleArgs()
756 SectionBase *Sec = Obj.findSection(SI.SectionName); in handleArgs() local
757 uint64_t Value = Sec ? Sec->Addr + SI.Value : SI.Value; in handleArgs()
759 SI.SymbolName, SI.Bind, SI.Type, Sec, Value, SI.Visibility, in handleArgs()
760 Sec ? (uint16_t)SYMBOL_SIMPLE_INDEX : (uint16_t)SHN_ABS, 0); in handleArgs()
765 for (auto &Sec : Obj.sections()) { in handleArgs() local
766 const auto Iter = Config.SetSectionFlags.find(Sec.Name); in handleArgs()
769 setSectionFlagsAndType(Sec, SFU.NewFlags); in handleArgs()