Lines Matching refs:Config
134 static std::unique_ptr<Writer> createELFWriter(const CommonConfig &Config, in createELFWriter() argument
140 return std::make_unique<ELFWriter<ELF32LE>>(Obj, Out, !Config.StripSections, in createELFWriter()
141 Config.OnlyKeepDebug); in createELFWriter()
143 return std::make_unique<ELFWriter<ELF64LE>>(Obj, Out, !Config.StripSections, in createELFWriter()
144 Config.OnlyKeepDebug); in createELFWriter()
146 return std::make_unique<ELFWriter<ELF32BE>>(Obj, Out, !Config.StripSections, in createELFWriter()
147 Config.OnlyKeepDebug); in createELFWriter()
149 return std::make_unique<ELFWriter<ELF64BE>>(Obj, Out, !Config.StripSections, in createELFWriter()
150 Config.OnlyKeepDebug); in createELFWriter()
155 static std::unique_ptr<Writer> createWriter(const CommonConfig &Config, in createWriter() argument
158 switch (Config.OutputFormat) { in createWriter()
164 return createELFWriter(Config, Obj, Out, OutputElfType); in createWriter()
269 static Error updateAndRemoveSymbols(const CommonConfig &Config, in updateAndRemoveSymbols() argument
282 Config.SymbolsToLocalize.matches(Sym.Name))) in updateAndRemoveSymbols()
295 if (!Config.SymbolsToKeepGlobal.empty() && in updateAndRemoveSymbols()
296 !Config.SymbolsToKeepGlobal.matches(Sym.Name) && in updateAndRemoveSymbols()
300 if (Config.SymbolsToGlobalize.matches(Sym.Name) && in updateAndRemoveSymbols()
305 if (Config.SymbolsToWeaken.matches(Sym.Name) && Sym.Binding != STB_LOCAL) in updateAndRemoveSymbols()
308 if (Config.Weaken && Sym.Binding != STB_LOCAL && in updateAndRemoveSymbols()
312 const auto I = Config.SymbolsToRename.find(Sym.Name); in updateAndRemoveSymbols()
313 if (I != Config.SymbolsToRename.end()) in updateAndRemoveSymbols()
316 if (!Config.SymbolsPrefix.empty() && Sym.Type != STT_SECTION) in updateAndRemoveSymbols()
317 Sym.Name = (Config.SymbolsPrefix + Sym.Name).str(); in updateAndRemoveSymbols()
323 if (Config.StripUnneeded || !Config.UnneededSymbolsToRemove.empty() || in updateAndRemoveSymbols()
324 !Config.OnlySection.empty()) { in updateAndRemoveSymbols()
330 if (Config.SymbolsToKeep.matches(Sym.Name) || in updateAndRemoveSymbols()
334 if (Config.SymbolsToRemove.matches(Sym.Name)) in updateAndRemoveSymbols()
337 if (Config.StripAll || Config.StripAllGNU) in updateAndRemoveSymbols()
343 if (Config.StripDebug && Sym.Type == STT_FILE) in updateAndRemoveSymbols()
346 if ((Config.DiscardMode == DiscardType::All || in updateAndRemoveSymbols()
347 (Config.DiscardMode == DiscardType::Locals && in updateAndRemoveSymbols()
353 if ((Config.StripUnneeded || in updateAndRemoveSymbols()
354 Config.UnneededSymbolsToRemove.matches(Sym.Name)) && in updateAndRemoveSymbols()
359 if (!Config.OnlySection.empty() && !Sym.Referenced && in updateAndRemoveSymbols()
369 static Error replaceAndRemoveSections(const CommonConfig &Config, in replaceAndRemoveSections() argument
374 if (!Config.ToRemove.empty()) { in replaceAndRemoveSections()
375 RemovePred = [&Config](const SectionBase &Sec) { in replaceAndRemoveSections()
376 return Config.ToRemove.matches(Sec.Name); in replaceAndRemoveSections()
380 if (Config.StripDWO) in replaceAndRemoveSections()
385 if (Config.ExtractDWO) in replaceAndRemoveSections()
390 if (Config.StripAllGNU) in replaceAndRemoveSections()
408 if (Config.StripSections) { in replaceAndRemoveSections()
414 if (Config.StripDebug || Config.StripUnneeded) { in replaceAndRemoveSections()
420 if (Config.StripNonAlloc) in replaceAndRemoveSections()
429 if (Config.StripAll) in replaceAndRemoveSections()
448 if (Config.ExtractPartition || Config.ExtractMainPartition) { in replaceAndRemoveSections()
459 if (!Config.OnlySection.empty()) { in replaceAndRemoveSections()
460 RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections()
462 if (Config.OnlySection.matches(Sec.Name)) in replaceAndRemoveSections()
481 if (!Config.KeepSection.empty()) { in replaceAndRemoveSections()
482 RemovePred = [&Config, RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections()
484 if (Config.KeepSection.matches(Sec.Name)) in replaceAndRemoveSections()
496 if ((!Config.SymbolsToKeep.empty() || ELFConfig.KeepFileSymbols) && in replaceAndRemoveSections()
508 if (Config.CompressionType != DebugCompressionType::None) { in replaceAndRemoveSections()
511 [&Config, &Obj](const SectionBase *S) -> Expected<SectionBase *> { in replaceAndRemoveSections()
513 CompressedSection(*S, Config.CompressionType)); in replaceAndRemoveSections()
516 } else if (Config.DecompressDebugSections) { in replaceAndRemoveSections()
600 static Error handleArgs(const CommonConfig &Config, const ELFConfig &ELFConfig, in handleArgs() argument
602 if (Config.OutputArch) { in handleArgs()
603 Obj.Machine = Config.OutputArch.value().EMachine; in handleArgs()
604 Obj.OSABI = Config.OutputArch.value().OSABI; in handleArgs()
607 if (!Config.SplitDWO.empty() && Config.ExtractDWO) { in handleArgs()
614 for (StringRef Flag : Config.DumpSection) { in handleArgs()
626 if (Error E = replaceAndRemoveSections(Config, ELFConfig, Obj)) in handleArgs()
629 if (Error E = updateAndRemoveSymbols(Config, ELFConfig, Obj)) in handleArgs()
632 if (!Config.SetSectionAlignment.empty()) { in handleArgs()
634 auto I = Config.SetSectionAlignment.find(Sec.Name); in handleArgs()
635 if (I != Config.SetSectionAlignment.end()) in handleArgs()
640 if (Config.OnlyKeepDebug) in handleArgs()
645 for (const NewSectionInfo &AddedSection : Config.AddSection) { in handleArgs()
657 for (const NewSectionInfo &NewSection : Config.UpdateSection) { in handleArgs()
665 if (!Config.AddGnuDebugLink.empty()) in handleArgs()
666 Obj.addSection<GnuDebugLinkSection>(Config.AddGnuDebugLink, in handleArgs()
667 Config.GnuDebugLinkCRC32); in handleArgs()
671 if (!Obj.SymbolTable && !Config.SymbolsToAdd.empty()) in handleArgs()
675 for (const NewSymbolInfo &SI : Config.SymbolsToAdd) in handleArgs()
679 if (!Config.SetSectionFlags.empty() || !Config.SetSectionType.empty()) { in handleArgs()
681 const auto Iter = Config.SetSectionFlags.find(Sec.Name); in handleArgs()
682 if (Iter != Config.SetSectionFlags.end()) { in handleArgs()
686 auto It2 = Config.SetSectionType.find(Sec.Name); in handleArgs()
687 if (It2 != Config.SetSectionType.end()) in handleArgs()
692 if (!Config.SectionsToRename.empty()) { in handleArgs()
697 const auto Iter = Config.SectionsToRename.find(Sec.Name); in handleArgs()
698 if (Iter != Config.SectionsToRename.end()) { in handleArgs()
725 if (!Config.AllocSectionsPrefix.empty()) { in handleArgs()
729 Sec.Name = (Config.AllocSectionsPrefix + Sec.Name).str(); in handleArgs()
748 Sec.Name = (RelocSec->getNamePrefix() + Config.AllocSectionsPrefix + in handleArgs()
761 static Error writeOutput(const CommonConfig &Config, Object &Obj, in writeOutput() argument
764 createWriter(Config, Obj, Out, OutputElfType); in writeOutput()
770 Error objcopy::elf::executeObjcopyOnIHex(const CommonConfig &Config, in executeObjcopyOnIHex() argument
779 getOutputElfType(Config.OutputArch.value_or(MachineInfo())); in executeObjcopyOnIHex()
780 if (Error E = handleArgs(Config, ELFConfig, **Obj)) in executeObjcopyOnIHex()
782 return writeOutput(Config, **Obj, Out, OutputElfType); in executeObjcopyOnIHex()
785 Error objcopy::elf::executeObjcopyOnRawBinary(const CommonConfig &Config, in executeObjcopyOnRawBinary() argument
797 getOutputElfType(Config.OutputArch.value_or(MachineInfo())); in executeObjcopyOnRawBinary()
798 if (Error E = handleArgs(Config, ELFConfig, **Obj)) in executeObjcopyOnRawBinary()
800 return writeOutput(Config, **Obj, Out, OutputElfType); in executeObjcopyOnRawBinary()
803 Error objcopy::elf::executeObjcopyOnBinary(const CommonConfig &Config, in executeObjcopyOnBinary() argument
807 ELFReader Reader(&In, Config.ExtractPartition); in executeObjcopyOnBinary()
809 Reader.create(!Config.SymbolsToAdd.empty()); in executeObjcopyOnBinary()
814 Config.OutputArch ? getOutputElfType(Config.OutputArch.value()) in executeObjcopyOnBinary()
817 if (Error E = handleArgs(Config, ELFConfig, **Obj)) in executeObjcopyOnBinary()
818 return createFileError(Config.InputFilename, std::move(E)); in executeObjcopyOnBinary()
820 if (Error E = writeOutput(Config, **Obj, Out, OutputElfType)) in executeObjcopyOnBinary()
821 return createFileError(Config.InputFilename, std::move(E)); in executeObjcopyOnBinary()