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()
185 return std::make_unique<IHexWriter>(Obj, Out, Config.OutputFilename); in createWriter()
187 return std::make_unique<SRECWriter>(Obj, Out, Config.OutputFilename); in createWriter()
189 return createELFWriter(Config, Obj, Out, OutputElfType); in createWriter()
217 Error Object::compressOrDecompressSections(const CommonConfig &Config) { in compressOrDecompressSections() argument
225 for (auto &[Matcher, T] : Config.compressSections) in compressOrDecompressSections()
231 if (Config.CompressionType != DebugCompressionType::None) in compressOrDecompressSections()
232 CType = Config.CompressionType; in compressOrDecompressSections()
233 else if (Config.DecompressDebugSections) in compressOrDecompressSections()
304 static Error updateAndRemoveSymbols(const CommonConfig &Config, in updateAndRemoveSymbols() argument
312 if (Config.SymbolsToSkip.matches(Sym.Name)) in updateAndRemoveSymbols()
320 Config.SymbolsToLocalize.matches(Sym.Name))) in updateAndRemoveSymbols()
337 if (!Config.SymbolsToKeepGlobal.empty() && in updateAndRemoveSymbols()
338 !Config.SymbolsToKeepGlobal.matches(Sym.Name) && in updateAndRemoveSymbols()
342 if (Config.SymbolsToGlobalize.matches(Sym.Name) && in updateAndRemoveSymbols()
347 if (Config.SymbolsToWeaken.matches(Sym.Name) && Sym.Binding != STB_LOCAL) in updateAndRemoveSymbols()
350 if (Config.Weaken && Sym.Binding != STB_LOCAL && in updateAndRemoveSymbols()
354 const auto I = Config.SymbolsToRename.find(Sym.Name); in updateAndRemoveSymbols()
355 if (I != Config.SymbolsToRename.end()) in updateAndRemoveSymbols()
358 if (!Config.SymbolsPrefixRemove.empty() && Sym.Type != STT_SECTION) in updateAndRemoveSymbols()
359 if (Sym.Name.compare(0, Config.SymbolsPrefixRemove.size(), in updateAndRemoveSymbols()
360 Config.SymbolsPrefixRemove) == 0) in updateAndRemoveSymbols()
361 Sym.Name = Sym.Name.substr(Config.SymbolsPrefixRemove.size()); in updateAndRemoveSymbols()
363 if (!Config.SymbolsPrefix.empty() && Sym.Type != STT_SECTION) in updateAndRemoveSymbols()
364 Sym.Name = (Config.SymbolsPrefix + Sym.Name).str(); in updateAndRemoveSymbols()
370 if (Config.StripUnneeded || !Config.UnneededSymbolsToRemove.empty() || in updateAndRemoveSymbols()
371 !Config.OnlySection.empty()) { in updateAndRemoveSymbols()
377 if (Config.SymbolsToKeep.matches(Sym.Name) || in updateAndRemoveSymbols()
381 if (Config.SymbolsToRemove.matches(Sym.Name)) in updateAndRemoveSymbols()
384 if (Config.StripAll || Config.StripAllGNU) in updateAndRemoveSymbols()
390 if (Config.StripDebug && Sym.Type == STT_FILE) in updateAndRemoveSymbols()
393 if ((Config.DiscardMode == DiscardType::All || in updateAndRemoveSymbols()
394 (Config.DiscardMode == DiscardType::Locals && in updateAndRemoveSymbols()
400 if ((Config.StripUnneeded || in updateAndRemoveSymbols()
401 Config.UnneededSymbolsToRemove.matches(Sym.Name)) && in updateAndRemoveSymbols()
406 if (!Config.OnlySection.empty() && !Sym.Referenced && in updateAndRemoveSymbols()
416 static Error replaceAndRemoveSections(const CommonConfig &Config, in replaceAndRemoveSections() argument
421 if (!Config.ToRemove.empty()) { in replaceAndRemoveSections()
422 RemovePred = [&Config](const SectionBase &Sec) { in replaceAndRemoveSections()
423 return Config.ToRemove.matches(Sec.Name); in replaceAndRemoveSections()
427 if (Config.StripDWO) in replaceAndRemoveSections()
432 if (Config.ExtractDWO) in replaceAndRemoveSections()
437 if (Config.StripAllGNU) in replaceAndRemoveSections()
455 if (Config.StripSections) { in replaceAndRemoveSections()
461 if (Config.StripDebug || Config.StripUnneeded) { in replaceAndRemoveSections()
467 if (Config.StripNonAlloc) in replaceAndRemoveSections()
476 if (Config.StripAll) in replaceAndRemoveSections()
497 if (Config.ExtractPartition || Config.ExtractMainPartition) { in replaceAndRemoveSections()
508 if (!Config.OnlySection.empty()) { in replaceAndRemoveSections()
509 RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) { in replaceAndRemoveSections()
511 if (Config.OnlySection.matches(Sec.Name)) in replaceAndRemoveSections()
530 if (!Config.KeepSection.empty()) { in replaceAndRemoveSections()
531 RemovePred = [&Config, RemovePred](const SectionBase &Sec) { in replaceAndRemoveSections()
533 if (Config.KeepSection.matches(Sec.Name)) in replaceAndRemoveSections()
545 if ((!Config.SymbolsToKeep.empty() || ELFConfig.KeepFileSymbols) && in replaceAndRemoveSections()
557 if (Error E = Obj.compressOrDecompressSections(Config)) in replaceAndRemoveSections()
681 static Error handleArgs(const CommonConfig &Config, const ELFConfig &ELFConfig, in handleArgs() argument
683 if (Config.OutputArch) { in handleArgs()
684 Obj.Machine = Config.OutputArch->EMachine; in handleArgs()
685 Obj.OSABI = Config.OutputArch->OSABI; in handleArgs()
688 if (!Config.SplitDWO.empty() && Config.ExtractDWO) { in handleArgs()
695 for (StringRef Flag : Config.DumpSection) { in handleArgs()
707 if (Error E = replaceAndRemoveSections(Config, ELFConfig, Obj)) in handleArgs()
710 if (Error E = updateAndRemoveSymbols(Config, ELFConfig, Obj)) in handleArgs()
713 if (!Config.SetSectionAlignment.empty()) { in handleArgs()
715 auto I = Config.SetSectionAlignment.find(Sec.Name); in handleArgs()
716 if (I != Config.SetSectionAlignment.end()) in handleArgs()
721 if (Config.ChangeSectionLMAValAll != 0) { in handleArgs()
724 if (Config.ChangeSectionLMAValAll > 0 && in handleArgs()
726 Config.ChangeSectionLMAValAll) { in handleArgs()
731 Twine::utohexstr(Config.ChangeSectionLMAValAll) + in handleArgs()
733 } else if (Config.ChangeSectionLMAValAll < 0 && in handleArgs()
735 Config.ChangeSectionLMAValAll) { in handleArgs()
740 Twine::utohexstr(std::abs(Config.ChangeSectionLMAValAll)) + in handleArgs()
743 Seg.PAddr += Config.ChangeSectionLMAValAll; in handleArgs()
748 if (Config.OnlyKeepDebug) in handleArgs()
757 for (const NewSectionInfo &AddedSection : Config.AddSection) { in handleArgs()
772 for (const NewSectionInfo &NewSection : Config.UpdateSection) { in handleArgs()
780 if (!Config.AddGnuDebugLink.empty()) in handleArgs()
781 Obj.addSection<GnuDebugLinkSection>(Config.AddGnuDebugLink, in handleArgs()
782 Config.GnuDebugLinkCRC32); in handleArgs()
786 if (!Obj.SymbolTable && !Config.SymbolsToAdd.empty()) in handleArgs()
790 for (const NewSymbolInfo &SI : Config.SymbolsToAdd) in handleArgs()
794 if (!Config.SetSectionFlags.empty() || !Config.SetSectionType.empty()) { in handleArgs()
796 const auto Iter = Config.SetSectionFlags.find(Sec.Name); in handleArgs()
797 if (Iter != Config.SetSectionFlags.end()) { in handleArgs()
802 auto It2 = Config.SetSectionType.find(Sec.Name); in handleArgs()
803 if (It2 != Config.SetSectionType.end()) in handleArgs()
808 if (!Config.SectionsToRename.empty()) { in handleArgs()
813 const auto Iter = Config.SectionsToRename.find(Sec.Name); in handleArgs()
814 if (Iter != Config.SectionsToRename.end()) { in handleArgs()
843 if (!Config.AllocSectionsPrefix.empty()) { in handleArgs()
847 Sec.Name = (Config.AllocSectionsPrefix + Sec.Name).str(); in handleArgs()
866 Sec.Name = (RelocSec->getNamePrefix() + Config.AllocSectionsPrefix + in handleArgs()
879 static Error writeOutput(const CommonConfig &Config, Object &Obj, in writeOutput() argument
882 createWriter(Config, Obj, Out, OutputElfType); in writeOutput()
888 Error objcopy::elf::executeObjcopyOnIHex(const CommonConfig &Config, in executeObjcopyOnIHex() argument
897 getOutputElfType(Config.OutputArch.value_or(MachineInfo())); in executeObjcopyOnIHex()
898 if (Error E = handleArgs(Config, ELFConfig, OutputElfType, **Obj)) in executeObjcopyOnIHex()
900 return writeOutput(Config, **Obj, Out, OutputElfType); in executeObjcopyOnIHex()
903 Error objcopy::elf::executeObjcopyOnRawBinary(const CommonConfig &Config, in executeObjcopyOnRawBinary() argument
915 getOutputElfType(Config.OutputArch.value_or(MachineInfo())); in executeObjcopyOnRawBinary()
916 if (Error E = handleArgs(Config, ELFConfig, OutputElfType, **Obj)) in executeObjcopyOnRawBinary()
918 return writeOutput(Config, **Obj, Out, OutputElfType); in executeObjcopyOnRawBinary()
921 Error objcopy::elf::executeObjcopyOnBinary(const CommonConfig &Config, in executeObjcopyOnBinary() argument
925 ELFReader Reader(&In, Config.ExtractPartition); in executeObjcopyOnBinary()
927 Reader.create(!Config.SymbolsToAdd.empty()); in executeObjcopyOnBinary()
931 const ElfType OutputElfType = Config.OutputArch in executeObjcopyOnBinary()
932 ? getOutputElfType(*Config.OutputArch) in executeObjcopyOnBinary()
935 if (Error E = handleArgs(Config, ELFConfig, OutputElfType, **Obj)) in executeObjcopyOnBinary()
936 return createFileError(Config.InputFilename, std::move(E)); in executeObjcopyOnBinary()
938 if (Error E = writeOutput(Config, **Obj, Out, OutputElfType)) in executeObjcopyOnBinary()
939 return createFileError(Config.InputFilename, std::move(E)); in executeObjcopyOnBinary()