Lines Matching refs:Config
157 static std::unique_ptr<Writer> createELFWriter(const CommonConfig &Config, in createELFWriter() argument
163 return std::make_unique<ELFWriter<ELF32LE>>(Obj, Out, !Config.StripSections, in createELFWriter()
164 Config.OnlyKeepDebug); in createELFWriter()
166 return std::make_unique<ELFWriter<ELF64LE>>(Obj, Out, !Config.StripSections, in createELFWriter()
167 Config.OnlyKeepDebug); in createELFWriter()
169 return std::make_unique<ELFWriter<ELF32BE>>(Obj, Out, !Config.StripSections, in createELFWriter()
170 Config.OnlyKeepDebug); in createELFWriter()
172 return std::make_unique<ELFWriter<ELF64BE>>(Obj, Out, !Config.StripSections, in createELFWriter()
173 Config.OnlyKeepDebug); in createELFWriter()
178 static std::unique_ptr<Writer> createWriter(const CommonConfig &Config, in createWriter() argument
181 switch (Config.OutputFormat) { in createWriter()
183 return std::make_unique<BinaryWriter>(Obj, Out, Config); in createWriter()
187 return createELFWriter(Config, Obj, Out, OutputElfType); in createWriter()
285 static Error updateAndRemoveSymbols(const CommonConfig &Config, in updateAndRemoveSymbols() argument
298 Config.SymbolsToLocalize.matches(Sym.Name))) in updateAndRemoveSymbols()
311 if (!Config.SymbolsToKeepGlobal.empty() && in updateAndRemoveSymbols()
312 !Config.SymbolsToKeepGlobal.matches(Sym.Name) && in updateAndRemoveSymbols()
316 if (Config.SymbolsToGlobalize.matches(Sym.Name) && in updateAndRemoveSymbols()
321 if (Config.SymbolsToWeaken.matches(Sym.Name) && Sym.Binding != STB_LOCAL) in updateAndRemoveSymbols()
324 if (Config.Weaken && Sym.Binding != STB_LOCAL && in updateAndRemoveSymbols()
328 const auto I = Config.SymbolsToRename.find(Sym.Name); in updateAndRemoveSymbols()
329 if (I != Config.SymbolsToRename.end()) in updateAndRemoveSymbols()
332 if (!Config.SymbolsPrefix.empty() && Sym.Type != STT_SECTION) in updateAndRemoveSymbols()
333 Sym.Name = (Config.SymbolsPrefix + Sym.Name).str(); in updateAndRemoveSymbols()
339 if (Config.StripUnneeded || !Config.UnneededSymbolsToRemove.empty() || in updateAndRemoveSymbols()
340 !Config.OnlySection.empty()) { in updateAndRemoveSymbols()
346 if (Config.SymbolsToKeep.matches(Sym.Name) || in updateAndRemoveSymbols()
350 if (Config.SymbolsToRemove.matches(Sym.Name)) in updateAndRemoveSymbols()
353 if (Config.StripAll || Config.StripAllGNU) in updateAndRemoveSymbols()
359 if (Config.StripDebug && Sym.Type == STT_FILE) in updateAndRemoveSymbols()
362 if ((Config.DiscardMode == DiscardType::All || in updateAndRemoveSymbols()
363 (Config.DiscardMode == DiscardType::Locals && in updateAndRemoveSymbols()
369 if ((Config.StripUnneeded || in updateAndRemoveSymbols()
370 Config.UnneededSymbolsToRemove.matches(Sym.Name)) && in updateAndRemoveSymbols()
375 if (!Config.OnlySection.empty() && !Sym.Referenced && in updateAndRemoveSymbols()
385 static Error replaceAndRemoveSections(const CommonConfig &Config, in replaceAndRemoveSections() argument
390 if (!Config.ToRemove.empty()) { in replaceAndRemoveSections()
391 RemovePred = [&Config](const SectionBase &Sec) { in replaceAndRemoveSections()
392 return Config.ToRemove.matches(Sec.Name); in replaceAndRemoveSections()
396 if (Config.StripDWO) in replaceAndRemoveSections()
401 if (Config.ExtractDWO) in replaceAndRemoveSections()
406 if (Config.StripAllGNU) in replaceAndRemoveSections()
424 if (Config.StripSections) { in replaceAndRemoveSections()
430 if (Config.StripDebug || Config.StripUnneeded) { in replaceAndRemoveSections()
436 if (Config.StripNonAlloc) in replaceAndRemoveSections()
445 if (Config.StripAll) in replaceAndRemoveSections()
464 if (Config.ExtractPartition || Config.ExtractMainPartition) { in replaceAndRemoveSections()
475 if (!Config.OnlySection.empty()) { in replaceAndRemoveSections()
476 RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections()
478 if (Config.OnlySection.matches(Sec.Name)) in replaceAndRemoveSections()
497 if (!Config.KeepSection.empty()) { in replaceAndRemoveSections()
498 RemovePred = [&Config, RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections()
500 if (Config.KeepSection.matches(Sec.Name)) in replaceAndRemoveSections()
512 if ((!Config.SymbolsToKeep.empty() || ELFConfig.KeepFileSymbols) && in replaceAndRemoveSections()
524 if (Config.CompressionType != DebugCompressionType::None) { in replaceAndRemoveSections()
527 [&Config, &Obj](const SectionBase *S) -> Expected<SectionBase *> { in replaceAndRemoveSections()
529 CompressedSection(*S, Config.CompressionType, Obj.Is64Bits)); in replaceAndRemoveSections()
532 } else if (Config.DecompressDebugSections) { in replaceAndRemoveSections()
616 static Error handleArgs(const CommonConfig &Config, const ELFConfig &ELFConfig, in handleArgs() argument
618 if (Config.OutputArch) { in handleArgs()
619 Obj.Machine = Config.OutputArch->EMachine; in handleArgs()
620 Obj.OSABI = Config.OutputArch->OSABI; in handleArgs()
623 if (!Config.SplitDWO.empty() && Config.ExtractDWO) { in handleArgs()
630 for (StringRef Flag : Config.DumpSection) { in handleArgs()
642 if (Error E = replaceAndRemoveSections(Config, ELFConfig, Obj)) in handleArgs()
645 if (Error E = updateAndRemoveSymbols(Config, ELFConfig, Obj)) in handleArgs()
648 if (!Config.SetSectionAlignment.empty()) { in handleArgs()
650 auto I = Config.SetSectionAlignment.find(Sec.Name); in handleArgs()
651 if (I != Config.SetSectionAlignment.end()) in handleArgs()
656 if (Config.OnlyKeepDebug) in handleArgs()
661 for (const NewSectionInfo &AddedSection : Config.AddSection) { in handleArgs()
673 for (const NewSectionInfo &NewSection : Config.UpdateSection) { in handleArgs()
681 if (!Config.AddGnuDebugLink.empty()) in handleArgs()
682 Obj.addSection<GnuDebugLinkSection>(Config.AddGnuDebugLink, in handleArgs()
683 Config.GnuDebugLinkCRC32); in handleArgs()
687 if (!Obj.SymbolTable && !Config.SymbolsToAdd.empty()) in handleArgs()
691 for (const NewSymbolInfo &SI : Config.SymbolsToAdd) in handleArgs()
695 if (!Config.SetSectionFlags.empty() || !Config.SetSectionType.empty()) { in handleArgs()
697 const auto Iter = Config.SetSectionFlags.find(Sec.Name); in handleArgs()
698 if (Iter != Config.SetSectionFlags.end()) { in handleArgs()
703 auto It2 = Config.SetSectionType.find(Sec.Name); in handleArgs()
704 if (It2 != Config.SetSectionType.end()) in handleArgs()
709 if (!Config.SectionsToRename.empty()) { in handleArgs()
714 const auto Iter = Config.SectionsToRename.find(Sec.Name); in handleArgs()
715 if (Iter != Config.SectionsToRename.end()) { in handleArgs()
744 if (!Config.AllocSectionsPrefix.empty()) { in handleArgs()
748 Sec.Name = (Config.AllocSectionsPrefix + Sec.Name).str(); in handleArgs()
767 Sec.Name = (RelocSec->getNamePrefix() + Config.AllocSectionsPrefix + in handleArgs()
780 static Error writeOutput(const CommonConfig &Config, Object &Obj, in writeOutput() argument
783 createWriter(Config, Obj, Out, OutputElfType); in writeOutput()
789 Error objcopy::elf::executeObjcopyOnIHex(const CommonConfig &Config, in executeObjcopyOnIHex() argument
798 getOutputElfType(Config.OutputArch.value_or(MachineInfo())); in executeObjcopyOnIHex()
799 if (Error E = handleArgs(Config, ELFConfig, **Obj)) in executeObjcopyOnIHex()
801 return writeOutput(Config, **Obj, Out, OutputElfType); in executeObjcopyOnIHex()
804 Error objcopy::elf::executeObjcopyOnRawBinary(const CommonConfig &Config, in executeObjcopyOnRawBinary() argument
816 getOutputElfType(Config.OutputArch.value_or(MachineInfo())); in executeObjcopyOnRawBinary()
817 if (Error E = handleArgs(Config, ELFConfig, **Obj)) in executeObjcopyOnRawBinary()
819 return writeOutput(Config, **Obj, Out, OutputElfType); in executeObjcopyOnRawBinary()
822 Error objcopy::elf::executeObjcopyOnBinary(const CommonConfig &Config, in executeObjcopyOnBinary() argument
826 ELFReader Reader(&In, Config.ExtractPartition); in executeObjcopyOnBinary()
828 Reader.create(!Config.SymbolsToAdd.empty()); in executeObjcopyOnBinary()
832 const ElfType OutputElfType = Config.OutputArch in executeObjcopyOnBinary()
833 ? getOutputElfType(*Config.OutputArch) in executeObjcopyOnBinary()
836 if (Error E = handleArgs(Config, ELFConfig, **Obj)) in executeObjcopyOnBinary()
837 return createFileError(Config.InputFilename, std::move(E)); in executeObjcopyOnBinary()
839 if (Error E = writeOutput(Config, **Obj, Out, OutputElfType)) in executeObjcopyOnBinary()
840 return createFileError(Config.InputFilename, std::move(E)); in executeObjcopyOnBinary()