Lines Matching refs:Sec

54 using SectionPred = std::function<bool(const SectionBase &Sec)>;
56 static bool isDebugSection(const SectionBase &Sec) { in isDebugSection() argument
57 return StringRef(Sec.Name).startswith(".debug") || in isDebugSection()
58 StringRef(Sec.Name).startswith(".zdebug") || Sec.Name == ".gdb_index"; in isDebugSection()
61 static bool isDWOSection(const SectionBase &Sec) { in isDWOSection() argument
62 return StringRef(Sec.Name).endswith(".dwo"); in isDWOSection()
65 static bool onlyKeepDWOPred(const Object &Obj, const SectionBase &Sec) { in onlyKeepDWOPred() argument
67 if (&Sec == Obj.SectionNames) in onlyKeepDWOPred()
71 return !isDWOSection(Sec); in onlyKeepDWOPred()
103 static void setSectionFlagsAndType(SectionBase &Sec, SectionFlag Flags) { in setSectionFlagsAndType() argument
104 Sec.Flags = getSectionFlagsPreserveMask(Sec.Flags, getNewShfFlags(Flags)); in setSectionFlagsAndType()
109 if (Sec.Type == SHT_NOBITS && in setSectionFlagsAndType()
110 (!(Sec.Flags & ELF::SHF_ALLOC) || in setSectionFlagsAndType()
112 Sec.Type = SHT_PROGBITS; in setSectionFlagsAndType()
179 for (auto &Sec : Obj.sections()) { in dumpSectionToFile() local
180 if (Sec.Name == SecName) { in dumpSectionToFile()
181 if (Sec.Type == SHT_NOBITS) in dumpSectionToFile()
186 FileOutputBuffer::create(Filename, Sec.OriginalData.size()); in dumpSectionToFile()
190 std::copy(Sec.OriginalData.begin(), Sec.OriginalData.end(), in dumpSectionToFile()
201 static bool isCompressable(const SectionBase &Sec) { in isCompressable() argument
202 return !(Sec.Flags & ELF::SHF_COMPRESSED) && in isCompressable()
203 StringRef(Sec.Name).startswith(".debug"); in isCompressable()
214 for (auto &Sec : Obj.sections()) in replaceDebugSections() local
215 if (ShouldReplace(Sec)) in replaceDebugSections()
216 ToReplace.push_back(&Sec); in replaceDebugSections()
231 for (auto &Sec : Obj.sections()) in replaceDebugSections() local
232 Sec.replaceSectionReferences(FromTo); in replaceDebugSections()
234 RemovePred = [ShouldReplace, RemovePred](const SectionBase &Sec) { in replaceDebugSections() argument
235 return ShouldReplace(Sec) || RemovePred(Sec); in replaceDebugSections()
301 for (SectionBase &Sec : Obj.sections()) in updateAndRemoveSymbols()
302 Sec.markSymbols(); in updateAndRemoveSymbols()
347 RemovePred = [&Config](const SectionBase &Sec) { in replaceAndRemoveSections() argument
348 return Config.ToRemove.matches(Sec.Name); in replaceAndRemoveSections()
353 RemovePred = [RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
354 return isDWOSection(Sec) || RemovePred(Sec); in replaceAndRemoveSections()
358 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
359 return onlyKeepDWOPred(Obj, Sec) || RemovePred(Sec); in replaceAndRemoveSections()
363 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
364 if (RemovePred(Sec)) in replaceAndRemoveSections()
366 if ((Sec.Flags & SHF_ALLOC) != 0) in replaceAndRemoveSections()
368 if (&Sec == Obj.SectionNames) in replaceAndRemoveSections()
370 switch (Sec.Type) { in replaceAndRemoveSections()
377 return isDebugSection(Sec); in replaceAndRemoveSections()
381 RemovePred = [RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
382 return RemovePred(Sec) || Sec.ParentSegment == nullptr; in replaceAndRemoveSections()
387 RemovePred = [RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
388 return RemovePred(Sec) || isDebugSection(Sec); in replaceAndRemoveSections()
393 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
394 if (RemovePred(Sec)) in replaceAndRemoveSections()
396 if (&Sec == Obj.SectionNames) in replaceAndRemoveSections()
398 return (Sec.Flags & SHF_ALLOC) == 0 && Sec.ParentSegment == nullptr; in replaceAndRemoveSections()
402 RemovePred = [RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
403 if (RemovePred(Sec)) in replaceAndRemoveSections()
405 if (&Sec == Obj.SectionNames) in replaceAndRemoveSections()
407 if (StringRef(Sec.Name).startswith(".gnu.warning")) in replaceAndRemoveSections()
413 if (Sec.Type == SHT_ARM_ATTRIBUTES) in replaceAndRemoveSections()
415 if (Sec.ParentSegment != nullptr) in replaceAndRemoveSections()
417 return (Sec.Flags & SHF_ALLOC) == 0; in replaceAndRemoveSections()
421 RemovePred = [RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
422 if (RemovePred(Sec)) in replaceAndRemoveSections()
424 if (Sec.Type == SHT_LLVM_PART_EHDR || Sec.Type == SHT_LLVM_PART_PHDR) in replaceAndRemoveSections()
426 return (Sec.Flags & SHF_ALLOC) != 0 && !Sec.ParentSegment; in replaceAndRemoveSections()
432 RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections() argument
434 if (Config.OnlySection.matches(Sec.Name)) in replaceAndRemoveSections()
438 if (RemovePred(Sec)) in replaceAndRemoveSections()
442 if (Obj.SectionNames == &Sec) in replaceAndRemoveSections()
444 if (Obj.SymbolTable == &Sec || in replaceAndRemoveSections()
445 (Obj.SymbolTable && Obj.SymbolTable->getStrTab() == &Sec)) in replaceAndRemoveSections()
454 RemovePred = [&Config, RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
456 if (Config.KeepSection.matches(Sec.Name)) in replaceAndRemoveSections()
459 return RemovePred(Sec); in replaceAndRemoveSections()
470 RemovePred = [&Obj, RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections() argument
471 if (&Sec == Obj.SymbolTable || &Sec == Obj.SymbolTable->getStrTab()) in replaceAndRemoveSections()
473 return RemovePred(Sec); in replaceAndRemoveSections()
506 SectionBase *Sec = Obj.findSection(SymInfo.SectionName); in addSymbol() local
507 uint64_t Value = Sec ? Sec->Addr + SymInfo.Value : SymInfo.Value; in addSymbol()
553 SymInfo.SymbolName, Bind, Type, Sec, Value, Visibility, in addSymbol()
554 Sec ? (uint16_t)SYMBOL_SIMPLE_INDEX : (uint16_t)SHN_ABS, 0); in addSymbol()
574 [&Obj](const SectionBase &Sec) { return onlyKeepDWOPred(Obj, Sec); }); in handleArgs() argument
597 for (SectionBase &Sec : Obj.sections()) { in handleArgs()
598 const auto Iter = Config.SectionsToRename.find(Sec.Name); in handleArgs()
601 Sec.Name = std::string(SR.NewName); in handleArgs()
603 setSectionFlagsAndType(Sec, SR.NewFlags.getValue()); in handleArgs()
613 for (SectionBase &Sec : Obj.sections()) { in handleArgs()
614 if (Sec.Flags & SHF_ALLOC) { in handleArgs()
615 Sec.Name = (Config.AllocSectionsPrefix + Sec.Name).str(); in handleArgs()
616 PrefixedSections.insert(&Sec); in handleArgs()
617 } else if (auto *RelocSec = dyn_cast<RelocationSectionBase>(&Sec)) { in handleArgs()
628 switch (Sec.Type) { in handleArgs()
644 Sec.Name = (prefix + TargetSec->Name).str(); in handleArgs()
646 Sec.Name = in handleArgs()
654 for (SectionBase &Sec : Obj.sections()) { in handleArgs()
655 auto I = Config.SetSectionAlignment.find(Sec.Name); in handleArgs()
657 Sec.Align = I->second; in handleArgs()
662 for (auto &Sec : Obj.sections()) in handleArgs() local
663 if (Sec.Flags & SHF_ALLOC && Sec.Type != SHT_NOTE) in handleArgs()
664 Sec.Type = SHT_NOBITS; in handleArgs()
699 for (auto &Sec : Obj.sections()) { in handleArgs() local
700 const auto Iter = Config.SetSectionFlags.find(Sec.Name); in handleArgs()
703 setSectionFlagsAndType(Sec, SFU.NewFlags); in handleArgs()