Lines Matching defs:Config

152 static std::unique_ptr<Writer> createELFWriter(const CommonConfig &Config,
158 return std::make_unique<ELFWriter<ELF32LE>>(Obj, Out, !Config.StripSections,
159 Config.OnlyKeepDebug);
161 return std::make_unique<ELFWriter<ELF64LE>>(Obj, Out, !Config.StripSections,
162 Config.OnlyKeepDebug);
164 return std::make_unique<ELFWriter<ELF32BE>>(Obj, Out, !Config.StripSections,
165 Config.OnlyKeepDebug);
167 return std::make_unique<ELFWriter<ELF64BE>>(Obj, Out, !Config.StripSections,
168 Config.OnlyKeepDebug);
173 static std::unique_ptr<Writer> createWriter(const CommonConfig &Config,
176 switch (Config.OutputFormat) {
178 return std::make_unique<BinaryWriter>(Obj, Out, Config);
180 return std::make_unique<IHexWriter>(Obj, Out, Config.OutputFilename);
182 return std::make_unique<SRECWriter>(Obj, Out, Config.OutputFilename);
184 return createELFWriter(Config, Obj, Out, OutputElfType);
212 Error Object::compressOrDecompressSections(const CommonConfig &Config) {
220 for (auto &[Matcher, T] : Config.compressSections)
226 if (Config.CompressionType != DebugCompressionType::None)
227 CType = Config.CompressionType;
228 else if (Config.DecompressDebugSections)
299 static Error updateAndRemoveSymbols(const CommonConfig &Config,
307 if (Config.SymbolsToSkip.matches(Sym.Name))
315 Config.SymbolsToLocalize.matches(Sym.Name)))
332 if (!Config.SymbolsToKeepGlobal.empty() &&
333 !Config.SymbolsToKeepGlobal.matches(Sym.Name) &&
337 if (Config.SymbolsToGlobalize.matches(Sym.Name) &&
342 if (Config.SymbolsToWeaken.matches(Sym.Name) && Sym.Binding != STB_LOCAL)
345 if (Config.Weaken && Sym.Binding != STB_LOCAL &&
349 const auto I = Config.SymbolsToRename.find(Sym.Name);
350 if (I != Config.SymbolsToRename.end())
353 if (!Config.SymbolsPrefixRemove.empty() && Sym.Type != STT_SECTION)
354 if (Sym.Name.compare(0, Config.SymbolsPrefixRemove.size(),
355 Config.SymbolsPrefixRemove) == 0)
356 Sym.Name = Sym.Name.substr(Config.SymbolsPrefixRemove.size());
358 if (!Config.SymbolsPrefix.empty() && Sym.Type != STT_SECTION)
359 Sym.Name = (Config.SymbolsPrefix + Sym.Name).str();
365 if (Config.StripUnneeded || !Config.UnneededSymbolsToRemove.empty() ||
366 !Config.OnlySection.empty()) {
372 if (Config.SymbolsToKeep.matches(Sym.Name) ||
376 if (Config.SymbolsToRemove.matches(Sym.Name))
379 if (Config.StripAll || Config.StripAllGNU)
385 if (Config.StripDebug && Sym.Type == STT_FILE)
388 if ((Config.DiscardMode == DiscardType::All ||
389 (Config.DiscardMode == DiscardType::Locals &&
395 if ((Config.StripUnneeded ||
396 Config.UnneededSymbolsToRemove.matches(Sym.Name)) &&
401 if (!Config.OnlySection.empty() && !Sym.Referenced &&
411 static Error replaceAndRemoveSections(const CommonConfig &Config,
416 if (!Config.ToRemove.empty()) {
417 RemovePred = [&Config](const SectionBase &Sec) {
418 return Config.ToRemove.matches(Sec.Name);
422 if (Config.StripDWO)
427 if (Config.ExtractDWO)
432 if (Config.StripAllGNU)
450 if (Config.StripSections) {
456 if (Config.StripDebug || Config.StripUnneeded) {
462 if (Config.StripNonAlloc)
471 if (Config.StripAll)
492 if (Config.ExtractPartition || Config.ExtractMainPartition) {
503 if (!Config.OnlySection.empty()) {
504 RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) {
506 if (Config.OnlySection.matches(Sec.Name))
525 if (!Config.KeepSection.empty()) {
526 RemovePred = [&Config, RemovePred](const SectionBase &Sec) {
528 if (Config.KeepSection.matches(Sec.Name))
540 if ((!Config.SymbolsToKeep.empty() || ELFConfig.KeepFileSymbols) &&
552 if (Error E = Obj.compressOrDecompressSections(Config))
783 static Error handleArgs(const CommonConfig &Config, const ELFConfig &ELFConfig,
785 if (Config.OutputArch) {
786 Obj.Machine = Config.OutputArch->EMachine;
787 Obj.OSABI = Config.OutputArch->OSABI;
790 if (!Config.SplitDWO.empty() && Config.ExtractDWO) {
797 for (StringRef Flag : Config.DumpSection) {
809 if (Error E = replaceAndRemoveSections(Config, ELFConfig, Obj))
812 if (Error E = updateAndRemoveSymbols(Config, ELFConfig, Obj))
815 if (!Config.SetSectionAlignment.empty()) {
817 auto I = Config.SetSectionAlignment.find(Sec.Name);
818 if (I != Config.SetSectionAlignment.end())
823 if (Config.ChangeSectionLMAValAll != 0) {
826 if (Config.ChangeSectionLMAValAll > 0 &&
828 Config.ChangeSectionLMAValAll) {
833 Twine::utohexstr(Config.ChangeSectionLMAValAll) +
835 } else if (Config.ChangeSectionLMAValAll < 0 &&
837 Config.ChangeSectionLMAValAll) {
842 Twine::utohexstr(std::abs(Config.ChangeSectionLMAValAll)) +
845 Seg.PAddr += Config.ChangeSectionLMAValAll;
850 if (!Config.ChangeSectionAddress.empty()) {
858 make_range(Config.ChangeSectionAddress.rbegin(),
859 Config.ChangeSectionAddress.rend())) {
900 if (Config.OnlyKeepDebug)
911 removeNotes(Obj, E, ELFConfig.NotesToRemove, Config.ErrorCallback))
915 for (const NewSectionInfo &AddedSection : Config.AddSection) {
930 for (const NewSectionInfo &NewSection : Config.UpdateSection) {
938 if (!Config.AddGnuDebugLink.empty())
939 Obj.addSection<GnuDebugLinkSection>(Config.AddGnuDebugLink,
940 Config.GnuDebugLinkCRC32);
944 if (!Obj.SymbolTable && !Config.SymbolsToAdd.empty())
948 for (const NewSymbolInfo &SI : Config.SymbolsToAdd)
952 if (!Config.SetSectionFlags.empty() || !Config.SetSectionType.empty()) {
954 const auto Iter = Config.SetSectionFlags.find(Sec.Name);
955 if (Iter != Config.SetSectionFlags.end()) {
960 auto It2 = Config.SetSectionType.find(Sec.Name);
961 if (It2 != Config.SetSectionType.end())
966 if (!Config.SectionsToRename.empty()) {
971 const auto Iter = Config.SectionsToRename.find(Sec.Name);
972 if (Iter != Config.SectionsToRename.end()) {
999 // should be done after renaming the section by Config.SectionToRename to
1001 if (!Config.AllocSectionsPrefix.empty()) {
1005 Sec.Name = (Config.AllocSectionsPrefix + Sec.Name).str();
1018 // don't add Config.AllocSectionsPrefix because we've already added
1024 Sec.Name = (RelocSec->getNamePrefix() + Config.AllocSectionsPrefix +
1037 static Error writeOutput(const CommonConfig &Config, Object &Obj,
1040 createWriter(Config, Obj, Out, OutputElfType);
1046 Error objcopy::elf::executeObjcopyOnIHex(const CommonConfig &Config,
1055 getOutputElfType(Config.OutputArch.value_or(MachineInfo()));
1056 if (Error E = handleArgs(Config, ELFConfig, OutputElfType, **Obj))
1058 return writeOutput(Config, **Obj, Out, OutputElfType);
1061 Error objcopy::elf::executeObjcopyOnRawBinary(const CommonConfig &Config,
1073 getOutputElfType(Config.OutputArch.value_or(MachineInfo()));
1074 if (Error E = handleArgs(Config, ELFConfig, OutputElfType, **Obj))
1076 return writeOutput(Config, **Obj, Out, OutputElfType);
1079 Error objcopy::elf::executeObjcopyOnBinary(const CommonConfig &Config,
1083 ELFReader Reader(&In, Config.ExtractPartition);
1085 Reader.create(!Config.SymbolsToAdd.empty());
1089 const ElfType OutputElfType = Config.OutputArch
1090 ? getOutputElfType(*Config.OutputArch)
1093 if (Error E = handleArgs(Config, ELFConfig, OutputElfType, **Obj))
1094 return createFileError(Config.InputFilename, std::move(E));
1096 if (Error E = writeOutput(Config, **Obj, Out, OutputElfType))
1097 return createFileError(Config.InputFilename, std::move(E));