LLVM 23.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.StripDWO || Common.StripNonAlloc ||
32 Common.StripSections || Common.Weaken ||
33 Common.CompressionType != DebugCompressionType::None ||
34 !Common.compressSections.empty() || Common.DecompressDebugSections ||
35 Common.DiscardMode == DiscardType::Locals ||
36 !Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
37 Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
38 !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty())
40 "option is not supported for COFF");
41
42 return COFF;
43}
44
46 if (!Common.SplitDWO.empty() || !Common.SymbolsPrefix.empty() ||
47 !Common.SymbolsPrefixRemove.empty() ||
48 !Common.AllocSectionsPrefix.empty() || !Common.KeepSection.empty() ||
49 !Common.SymbolsToKeep.empty() || !Common.SectionsToRename.empty() ||
50 !Common.UnneededSymbolsToRemove.empty() ||
51 !Common.SetSectionAlignment.empty() || !Common.SetSectionFlags.empty() ||
52 !Common.SetSectionType.empty() || Common.ExtractDWO ||
53 Common.PreserveDates || Common.StripAllGNU || Common.StripDWO ||
54 Common.StripNonAlloc || Common.StripSections ||
55 Common.CompressionType != DebugCompressionType::None ||
56 !Common.compressSections.empty() || Common.DecompressDebugSections ||
57 Common.StripUnneeded || Common.DiscardMode == DiscardType::Locals ||
58 !Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||
59 Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0 ||
60 !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty())
62 "option is not supported for MachO");
63
64 return MachO;
65}
66
68 if (!Common.AddGnuDebugLink.empty() || Common.ExtractPartition ||
69 !Common.SplitDWO.empty() || !Common.SymbolsPrefix.empty() ||
70 !Common.SymbolsPrefixRemove.empty() || !Common.SymbolsToSkip.empty() ||
71 !Common.AllocSectionsPrefix.empty() ||
72 Common.DiscardMode != DiscardType::None || !Common.SymbolsToAdd.empty() ||
73 !Common.SymbolsToGlobalize.empty() || !Common.SymbolsToLocalize.empty() ||
74 !Common.SymbolsToKeep.empty() || !Common.SymbolsToRemove.empty() ||
75 !Common.UnneededSymbolsToRemove.empty() ||
76 !Common.SymbolsToWeaken.empty() || !Common.SymbolsToKeepGlobal.empty() ||
77 !Common.SectionsToRename.empty() || !Common.SetSectionAlignment.empty() ||
78 !Common.SetSectionFlags.empty() || !Common.SetSectionType.empty() ||
79 !Common.SymbolsToRename.empty() ||
80 Common.CompressionType != DebugCompressionType::None ||
81 !Common.compressSections.empty() || Common.DecompressDebugSections ||
82 Common.GapFill != 0 || Common.PadTo != 0 ||
83 Common.ChangeSectionLMAValAll != 0 ||
84 !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty())
86 "only flags for section dumping, removal, and "
87 "addition are supported");
88
89 return Wasm;
90}
91
93 if (!Common.AddGnuDebugLink.empty() || Common.ExtractPartition ||
94 !Common.SplitDWO.empty() || !Common.SymbolsPrefix.empty() ||
95 !Common.SymbolsPrefixRemove.empty() || !Common.SymbolsToSkip.empty() ||
96 !Common.AllocSectionsPrefix.empty() ||
97 Common.DiscardMode != DiscardType::None || !Common.AddSection.empty() ||
98 !Common.DumpSection.empty() || !Common.SymbolsToAdd.empty() ||
99 !Common.KeepSection.empty() || !Common.OnlySection.empty() ||
100 !Common.ToRemove.empty() || !Common.SymbolsToGlobalize.empty() ||
101 !Common.SymbolsToKeep.empty() || !Common.SymbolsToLocalize.empty() ||
102 !Common.SymbolsToRemove.empty() ||
103 !Common.UnneededSymbolsToRemove.empty() ||
104 !Common.SymbolsToWeaken.empty() || !Common.SymbolsToKeepGlobal.empty() ||
105 !Common.SectionsToRename.empty() || !Common.SetSectionAlignment.empty() ||
106 !Common.SetSectionFlags.empty() || !Common.SetSectionType.empty() ||
107 !Common.SymbolsToRename.empty() || Common.ExtractDWO ||
108 Common.ExtractMainPartition || Common.OnlyKeepDebug ||
109 Common.PreserveDates || Common.StripAllGNU || Common.StripDWO ||
110 Common.StripDebug || Common.StripNonAlloc || Common.StripSections ||
111 Common.Weaken || Common.StripUnneeded ||
112 Common.CompressionType != DebugCompressionType::None ||
113 !Common.compressSections.empty() || Common.DecompressDebugSections ||
114 Common.GapFill != 0 || Common.PadTo != 0 ||
115 Common.ChangeSectionLMAValAll != 0 ||
116 !Common.ChangeSectionAddress.empty() || !Common.ExtractSection.empty()) {
117 return createStringError(
119 "no flags are supported yet, only basic copying is allowed");
120 }
121
122 return XCOFF;
123}
124
127 // All other flags are either supported or not applicable for DXContainer
128 // object files and will be silently ignored.
129 if (!Common.AddGnuDebugLink.empty() || !Common.SplitDWO.empty() ||
130 !Common.AllocSectionsPrefix.empty() ||
131 Common.DiscardMode != DiscardType::None || !Common.AddSection.empty() ||
132 !Common.KeepSection.empty() || !Common.SectionsToRename.empty() ||
133 !Common.SetSectionAlignment.empty() || !Common.SetSectionFlags.empty() ||
134 !Common.SetSectionType.empty() || Common.ExtractDWO ||
135 Common.OnlyKeepDebug || Common.StripAllGNU || Common.StripDWO ||
136 Common.StripDebug || Common.StripNonAlloc || Common.StripSections ||
137 Common.StripUnneeded ||
138 Common.CompressionType != DebugCompressionType::None ||
139 !Common.compressSections.empty() || Common.DecompressDebugSections ||
140 Common.GapFill != 0 || Common.PadTo != 0 ||
141 Common.ChangeSectionLMAValAll != 0 ||
142 !Common.ChangeSectionAddress.empty()) {
144 "option is not supported for DXContainer");
145 }
146 return DXContainer;
147}
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:1321
@ invalid_argument
Definition Errc.h:56
@ None
No compression.
Definition Compression.h:29
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