Lines Matching refs:Config
136 static std::unique_ptr<Writer> createELFWriter(const CommonConfig &Config, in createELFWriter() argument
142 return std::make_unique<ELFWriter<ELF32LE>>(Obj, Out, !Config.StripSections, in createELFWriter()
143 Config.OnlyKeepDebug); in createELFWriter()
145 return std::make_unique<ELFWriter<ELF64LE>>(Obj, Out, !Config.StripSections, in createELFWriter()
146 Config.OnlyKeepDebug); in createELFWriter()
148 return std::make_unique<ELFWriter<ELF32BE>>(Obj, Out, !Config.StripSections, in createELFWriter()
149 Config.OnlyKeepDebug); in createELFWriter()
151 return std::make_unique<ELFWriter<ELF64BE>>(Obj, Out, !Config.StripSections, in createELFWriter()
152 Config.OnlyKeepDebug); in createELFWriter()
157 static std::unique_ptr<Writer> createWriter(const CommonConfig &Config, in createWriter() argument
160 switch (Config.OutputFormat) { in createWriter()
166 return createELFWriter(Config, Obj, Out, OutputElfType); in createWriter()
247 static Error updateAndRemoveSymbols(const CommonConfig &Config, Object &Obj) { in updateAndRemoveSymbols() argument
257 ((Config.LocalizeHidden && in updateAndRemoveSymbols()
259 Config.SymbolsToLocalize.matches(Sym.Name))) in updateAndRemoveSymbols()
272 if (!Config.SymbolsToKeepGlobal.empty() && in updateAndRemoveSymbols()
273 !Config.SymbolsToKeepGlobal.matches(Sym.Name) && in updateAndRemoveSymbols()
277 if (Config.SymbolsToGlobalize.matches(Sym.Name) && in updateAndRemoveSymbols()
281 if (Config.SymbolsToWeaken.matches(Sym.Name) && Sym.Binding == STB_GLOBAL) in updateAndRemoveSymbols()
284 if (Config.Weaken && Sym.Binding == STB_GLOBAL && in updateAndRemoveSymbols()
288 const auto I = Config.SymbolsToRename.find(Sym.Name); in updateAndRemoveSymbols()
289 if (I != Config.SymbolsToRename.end()) in updateAndRemoveSymbols()
292 if (!Config.SymbolsPrefix.empty() && Sym.Type != STT_SECTION) in updateAndRemoveSymbols()
293 Sym.Name = (Config.SymbolsPrefix + Sym.Name).str(); in updateAndRemoveSymbols()
299 if (Config.StripUnneeded || !Config.UnneededSymbolsToRemove.empty() || in updateAndRemoveSymbols()
300 !Config.OnlySection.empty()) { in updateAndRemoveSymbols()
306 if (Config.SymbolsToKeep.matches(Sym.Name) || in updateAndRemoveSymbols()
307 (Config.KeepFileSymbols && Sym.Type == STT_FILE)) in updateAndRemoveSymbols()
310 if ((Config.DiscardMode == DiscardType::All || in updateAndRemoveSymbols()
311 (Config.DiscardMode == DiscardType::Locals && in updateAndRemoveSymbols()
317 if (Config.StripAll || Config.StripAllGNU) in updateAndRemoveSymbols()
320 if (Config.StripDebug && Sym.Type == STT_FILE) in updateAndRemoveSymbols()
323 if (Config.SymbolsToRemove.matches(Sym.Name)) in updateAndRemoveSymbols()
326 if ((Config.StripUnneeded || in updateAndRemoveSymbols()
327 Config.UnneededSymbolsToRemove.matches(Sym.Name)) && in updateAndRemoveSymbols()
332 if (!Config.OnlySection.empty() && !Sym.Referenced && in updateAndRemoveSymbols()
342 static Error replaceAndRemoveSections(const CommonConfig &Config, Object &Obj) { in replaceAndRemoveSections() argument
346 if (!Config.ToRemove.empty()) { in replaceAndRemoveSections()
347 RemovePred = [&Config](const SectionBase &Sec) { in replaceAndRemoveSections()
348 return Config.ToRemove.matches(Sec.Name); in replaceAndRemoveSections()
352 if (Config.StripDWO) in replaceAndRemoveSections()
357 if (Config.ExtractDWO) in replaceAndRemoveSections()
362 if (Config.StripAllGNU) in replaceAndRemoveSections()
380 if (Config.StripSections) { in replaceAndRemoveSections()
386 if (Config.StripDebug || Config.StripUnneeded) { in replaceAndRemoveSections()
392 if (Config.StripNonAlloc) in replaceAndRemoveSections()
401 if (Config.StripAll) in replaceAndRemoveSections()
420 if (Config.ExtractPartition || Config.ExtractMainPartition) { in replaceAndRemoveSections()
431 if (!Config.OnlySection.empty()) { in replaceAndRemoveSections()
432 RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections()
434 if (Config.OnlySection.matches(Sec.Name)) in replaceAndRemoveSections()
453 if (!Config.KeepSection.empty()) { in replaceAndRemoveSections()
454 RemovePred = [&Config, RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections()
456 if (Config.KeepSection.matches(Sec.Name)) in replaceAndRemoveSections()
468 if ((!Config.SymbolsToKeep.empty() || Config.KeepFileSymbols) && in replaceAndRemoveSections()
477 if (Config.CompressionType != DebugCompressionType::None) { in replaceAndRemoveSections()
480 [&Config, &Obj](const SectionBase *S) -> Expected<SectionBase *> { in replaceAndRemoveSections()
482 CompressedSection::create(*S, Config.CompressionType); in replaceAndRemoveSections()
489 } else if (Config.DecompressDebugSections) { in replaceAndRemoveSections()
500 return Obj.removeSections(Config.AllowBrokenLinks, RemovePred); in replaceAndRemoveSections()
564 static Error handleArgs(const CommonConfig &Config, const ELFConfig &ELFConfig, in handleArgs() argument
566 if (Config.OutputArch) { in handleArgs()
567 Obj.Machine = Config.OutputArch.getValue().EMachine; in handleArgs()
568 Obj.OSABI = Config.OutputArch.getValue().OSABI; in handleArgs()
571 if (!Config.SplitDWO.empty() && Config.ExtractDWO) { in handleArgs()
573 Config.AllowBrokenLinks, in handleArgs()
578 for (StringRef Flag : Config.DumpSection) { in handleArgs()
590 if (Error E = replaceAndRemoveSections(Config, Obj)) in handleArgs()
593 if (Error E = updateAndRemoveSymbols(Config, Obj)) in handleArgs()
596 if (!Config.SectionsToRename.empty()) { in handleArgs()
598 const auto Iter = Config.SectionsToRename.find(Sec.Name); in handleArgs()
599 if (Iter != Config.SectionsToRename.end()) { in handleArgs()
611 if (!Config.AllocSectionsPrefix.empty()) { in handleArgs()
615 Sec.Name = (Config.AllocSectionsPrefix + Sec.Name).str(); in handleArgs()
647 (prefix + Config.AllocSectionsPrefix + TargetSec->Name).str(); in handleArgs()
653 if (!Config.SetSectionAlignment.empty()) { in handleArgs()
655 auto I = Config.SetSectionAlignment.find(Sec.Name); in handleArgs()
656 if (I != Config.SetSectionAlignment.end()) in handleArgs()
661 if (Config.OnlyKeepDebug) in handleArgs()
666 for (const auto &Flag : Config.AddSection) { in handleArgs()
684 if (!Config.AddGnuDebugLink.empty()) in handleArgs()
685 Obj.addSection<GnuDebugLinkSection>(Config.AddGnuDebugLink, in handleArgs()
686 Config.GnuDebugLinkCRC32); in handleArgs()
690 if (!Obj.SymbolTable && !Config.SymbolsToAdd.empty()) in handleArgs()
694 for (const NewSymbolInfo &SI : Config.SymbolsToAdd) in handleArgs()
698 if (!Config.SetSectionFlags.empty()) { in handleArgs()
700 const auto Iter = Config.SetSectionFlags.find(Sec.Name); in handleArgs()
701 if (Iter != Config.SetSectionFlags.end()) { in handleArgs()
708 if (Config.EntryExpr) in handleArgs()
709 Obj.Entry = Config.EntryExpr(Obj.Entry); in handleArgs()
713 static Error writeOutput(const CommonConfig &Config, Object &Obj, in writeOutput() argument
716 createWriter(Config, Obj, Out, OutputElfType); in writeOutput()
722 Error objcopy::elf::executeObjcopyOnIHex(const CommonConfig &Config, in executeObjcopyOnIHex() argument
731 getOutputElfType(Config.OutputArch.getValueOr(MachineInfo())); in executeObjcopyOnIHex()
732 if (Error E = handleArgs(Config, ELFConfig, **Obj)) in executeObjcopyOnIHex()
734 return writeOutput(Config, **Obj, Out, OutputElfType); in executeObjcopyOnIHex()
737 Error objcopy::elf::executeObjcopyOnRawBinary(const CommonConfig &Config, in executeObjcopyOnRawBinary() argument
749 getOutputElfType(Config.OutputArch.getValueOr(MachineInfo())); in executeObjcopyOnRawBinary()
750 if (Error E = handleArgs(Config, ELFConfig, **Obj)) in executeObjcopyOnRawBinary()
752 return writeOutput(Config, **Obj, Out, OutputElfType); in executeObjcopyOnRawBinary()
755 Error objcopy::elf::executeObjcopyOnBinary(const CommonConfig &Config, in executeObjcopyOnBinary() argument
759 ELFReader Reader(&In, Config.ExtractPartition); in executeObjcopyOnBinary()
761 Reader.create(!Config.SymbolsToAdd.empty()); in executeObjcopyOnBinary()
766 Config.OutputArch ? getOutputElfType(Config.OutputArch.getValue()) in executeObjcopyOnBinary()
769 if (Error E = handleArgs(Config, ELFConfig, **Obj)) in executeObjcopyOnBinary()
770 return createFileError(Config.InputFilename, std::move(E)); in executeObjcopyOnBinary()
772 if (Error E = writeOutput(Config, **Obj, Out, OutputElfType)) in executeObjcopyOnBinary()
773 return createFileError(Config.InputFilename, std::move(E)); in executeObjcopyOnBinary()