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