LLVM 22.0.0git
ConfigManager.cpp
Go to the documentation of this file.
1//===- ConfigManager.cpp --------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "llvm/Support/Errc.h"
11#include "llvm/Support/Error.h"
12
13using namespace llvm;
14using namespace llvm::objcopy;
15
17 if (!Common.ExtractSection.empty())
19 "option is not supported for ELF");
20 return ELF;
21}
22
24 if (!Common.SplitDWO.empty() || !Common.SymbolsPrefix.empty() ||
25 !Common.SymbolsPrefixRemove.empty() || !Common.SymbolsToSkip.empty() ||
26 !Common.AllocSectionsPrefix.empty() || !Common.KeepSection.empty() ||
27 !Common.SymbolsToGlobalize.empty() || !Common.SymbolsToKeep.empty() ||
28 !Common.SymbolsToLocalize.empty() || !Common.SymbolsToWeaken.empty() ||
29 !Common.SymbolsToKeepGlobal.empty() || !Common.SectionsToRename.empty() ||
30 !Common.SetSectionAlignment.empty() || !Common.SetSectionType.empty() ||
31 Common.ExtractDWO || Common.PreserveDates || Common.StripDWO ||
32 Common.StripNonAlloc || Common.StripSections || Common.Weaken ||
33 Common.DecompressDebugSections ||
34 Common.DiscardMode == DiscardType::Locals ||
35 !Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
36 Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
37 !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty())
39 "option is not supported for COFF");
40
41 return COFF;
42}
43
45 if (!Common.SplitDWO.empty() || !Common.SymbolsPrefix.empty() ||
46 !Common.SymbolsPrefixRemove.empty() ||
47 !Common.AllocSectionsPrefix.empty() || !Common.KeepSection.empty() ||
48 !Common.SymbolsToKeep.empty() || !Common.SectionsToRename.empty() ||
49 !Common.UnneededSymbolsToRemove.empty() ||
50 !Common.SetSectionAlignment.empty() || !Common.SetSectionFlags.empty() ||
51 !Common.SetSectionType.empty() || Common.ExtractDWO ||
52 Common.PreserveDates || Common.StripAllGNU || Common.StripDWO ||
53 Common.StripNonAlloc || Common.StripSections ||
54 Common.DecompressDebugSections || Common.StripUnneeded ||
55 Common.DiscardMode == DiscardType::Locals ||
56 !Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
57 Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
58 !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty())
60 "option is not supported for MachO");
61
62 return MachO;
63}
64
66 if (!Common.AddGnuDebugLink.empty() || Common.ExtractPartition ||
67 !Common.SplitDWO.empty() || !Common.SymbolsPrefix.empty() ||
68 !Common.SymbolsPrefixRemove.empty() || !Common.SymbolsToSkip.empty() ||
69 !Common.AllocSectionsPrefix.empty() ||
70 Common.DiscardMode != DiscardType::None || !Common.SymbolsToAdd.empty() ||
71 !Common.SymbolsToGlobalize.empty() || !Common.SymbolsToLocalize.empty() ||
72 !Common.SymbolsToKeep.empty() || !Common.SymbolsToRemove.empty() ||
73 !Common.UnneededSymbolsToRemove.empty() ||
74 !Common.SymbolsToWeaken.empty() || !Common.SymbolsToKeepGlobal.empty() ||
75 !Common.SectionsToRename.empty() || !Common.SetSectionAlignment.empty() ||
76 !Common.SetSectionFlags.empty() || !Common.SetSectionType.empty() ||
77 !Common.SymbolsToRename.empty() || Common.GapFill != 0 ||
78 Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
79 !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty())
81 "only flags for section dumping, removal, and "
82 "addition are supported");
83
84 return Wasm;
85}
86
88 if (!Common.AddGnuDebugLink.empty() || Common.ExtractPartition ||
89 !Common.SplitDWO.empty() || !Common.SymbolsPrefix.empty() ||
90 !Common.SymbolsPrefixRemove.empty() || !Common.SymbolsToSkip.empty() ||
91 !Common.AllocSectionsPrefix.empty() ||
92 Common.DiscardMode != DiscardType::None || !Common.AddSection.empty() ||
93 !Common.DumpSection.empty() || !Common.SymbolsToAdd.empty() ||
94 !Common.KeepSection.empty() || !Common.OnlySection.empty() ||
95 !Common.ToRemove.empty() || !Common.SymbolsToGlobalize.empty() ||
96 !Common.SymbolsToKeep.empty() || !Common.SymbolsToLocalize.empty() ||
97 !Common.SymbolsToRemove.empty() ||
98 !Common.UnneededSymbolsToRemove.empty() ||
99 !Common.SymbolsToWeaken.empty() || !Common.SymbolsToKeepGlobal.empty() ||
100 !Common.SectionsToRename.empty() || !Common.SetSectionAlignment.empty() ||
101 !Common.SetSectionFlags.empty() || !Common.SetSectionType.empty() ||
102 !Common.SymbolsToRename.empty() || Common.ExtractDWO ||
103 Common.ExtractMainPartition || Common.OnlyKeepDebug ||
104 Common.PreserveDates || Common.StripAllGNU || Common.StripDWO ||
105 Common.StripDebug || Common.StripNonAlloc || Common.StripSections ||
106 Common.Weaken || Common.StripUnneeded || Common.DecompressDebugSections ||
107 Common.GapFill != 0 || Common.PadTo != 0 ||
108 Common.ChangeSectionLMAValAll != 0 ||
109 !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty()) {
110 return createStringError(
112 "no flags are supported yet, only basic copying is allowed");
113 }
114
115 return XCOFF;
116}
117
120 // All other flags are either supported or not applicable for DXContainer
121 // object files and will be silently ignored.
122 if (!Common.AddGnuDebugLink.empty() || !Common.SplitDWO.empty() ||
123 !Common.AllocSectionsPrefix.empty() ||
124 Common.DiscardMode != DiscardType::None || !Common.AddSection.empty() ||
125 !Common.DumpSection.empty() || !Common.KeepSection.empty() ||
126 !Common.SectionsToRename.empty() || !Common.SetSectionAlignment.empty() ||
127 !Common.SetSectionFlags.empty() || !Common.SetSectionType.empty() ||
128 Common.ExtractDWO || Common.OnlyKeepDebug || Common.StripAllGNU ||
129 Common.StripDWO || Common.StripDebug || Common.StripNonAlloc ||
130 Common.StripSections || Common.StripUnneeded ||
131 Common.DecompressDebugSections || Common.GapFill != 0 ||
132 Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
133 !Common.ChangeSectionAddress.empty()) {
135 "option is not supported for DXContainer");
136 }
137 return DXContainer;
138}
Tagged union holding either a T or a Error.
Definition Error.h:485
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition Error.h:1305
@ invalid_argument
Definition Errc.h:56
Expected< const DXContainerConfig & > getDXContainerConfig() const override
Expected< const XCOFFConfig & > getXCOFFConfig() const override
Expected< const WasmConfig & > getWasmConfig() const override
Expected< const ELFConfig & > getELFConfig() const override
Expected< const COFFConfig & > getCOFFConfig() const override
Expected< const MachOConfig & > getMachOConfig() const override
DXContainerConfig DXContainer