1 //===- ConfigManager.cpp --------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ObjCopy/ConfigManager.h"
10 #include "llvm/Support/Errc.h"
11 #include "llvm/Support/Error.h"
16 Expected
<const COFFConfig
&> ConfigManager::getCOFFConfig() const {
17 if (!Common
.SplitDWO
.empty() || !Common
.SymbolsPrefix
.empty() ||
18 !Common
.SymbolsPrefixRemove
.empty() || !Common
.SymbolsToSkip
.empty() ||
19 !Common
.AllocSectionsPrefix
.empty() || !Common
.KeepSection
.empty() ||
20 !Common
.SymbolsToGlobalize
.empty() || !Common
.SymbolsToKeep
.empty() ||
21 !Common
.SymbolsToLocalize
.empty() || !Common
.SymbolsToWeaken
.empty() ||
22 !Common
.SymbolsToKeepGlobal
.empty() || !Common
.SectionsToRename
.empty() ||
23 !Common
.SetSectionAlignment
.empty() || !Common
.SetSectionType
.empty() ||
24 Common
.ExtractDWO
|| Common
.PreserveDates
|| Common
.StripDWO
||
25 Common
.StripNonAlloc
|| Common
.StripSections
|| Common
.Weaken
||
26 Common
.DecompressDebugSections
||
27 Common
.DiscardMode
== DiscardType::Locals
||
28 !Common
.SymbolsToAdd
.empty() || Common
.GapFill
!= 0 ||
29 Common
.PadTo
!= 0 || Common
.ChangeSectionLMAValAll
!= 0 ||
30 !Common
.ChangeSectionAddress
.empty())
31 return createStringError(llvm::errc::invalid_argument
,
32 "option is not supported for COFF");
37 Expected
<const MachOConfig
&> ConfigManager::getMachOConfig() const {
38 if (!Common
.SplitDWO
.empty() || !Common
.SymbolsPrefix
.empty() ||
39 !Common
.SymbolsPrefixRemove
.empty() || !Common
.SymbolsToSkip
.empty() ||
40 !Common
.AllocSectionsPrefix
.empty() || !Common
.KeepSection
.empty() ||
41 !Common
.SymbolsToGlobalize
.empty() || !Common
.SymbolsToKeep
.empty() ||
42 !Common
.SymbolsToLocalize
.empty() ||
43 !Common
.SymbolsToKeepGlobal
.empty() || !Common
.SectionsToRename
.empty() ||
44 !Common
.UnneededSymbolsToRemove
.empty() ||
45 !Common
.SetSectionAlignment
.empty() || !Common
.SetSectionFlags
.empty() ||
46 !Common
.SetSectionType
.empty() || Common
.ExtractDWO
||
47 Common
.PreserveDates
|| Common
.StripAllGNU
|| Common
.StripDWO
||
48 Common
.StripNonAlloc
|| Common
.StripSections
||
49 Common
.DecompressDebugSections
|| Common
.StripUnneeded
||
50 Common
.DiscardMode
== DiscardType::Locals
||
51 !Common
.SymbolsToAdd
.empty() || Common
.GapFill
!= 0 ||
52 Common
.PadTo
!= 0 || Common
.ChangeSectionLMAValAll
!= 0 ||
53 !Common
.ChangeSectionAddress
.empty())
54 return createStringError(llvm::errc::invalid_argument
,
55 "option is not supported for MachO");
60 Expected
<const WasmConfig
&> ConfigManager::getWasmConfig() const {
61 if (!Common
.AddGnuDebugLink
.empty() || Common
.ExtractPartition
||
62 !Common
.SplitDWO
.empty() || !Common
.SymbolsPrefix
.empty() ||
63 !Common
.SymbolsPrefixRemove
.empty() || !Common
.SymbolsToSkip
.empty() ||
64 !Common
.AllocSectionsPrefix
.empty() ||
65 Common
.DiscardMode
!= DiscardType::None
|| !Common
.SymbolsToAdd
.empty() ||
66 !Common
.SymbolsToGlobalize
.empty() || !Common
.SymbolsToLocalize
.empty() ||
67 !Common
.SymbolsToKeep
.empty() || !Common
.SymbolsToRemove
.empty() ||
68 !Common
.UnneededSymbolsToRemove
.empty() ||
69 !Common
.SymbolsToWeaken
.empty() || !Common
.SymbolsToKeepGlobal
.empty() ||
70 !Common
.SectionsToRename
.empty() || !Common
.SetSectionAlignment
.empty() ||
71 !Common
.SetSectionFlags
.empty() || !Common
.SetSectionType
.empty() ||
72 !Common
.SymbolsToRename
.empty() || Common
.GapFill
!= 0 ||
73 Common
.PadTo
!= 0 || Common
.ChangeSectionLMAValAll
!= 0 ||
74 !Common
.ChangeSectionAddress
.empty())
75 return createStringError(llvm::errc::invalid_argument
,
76 "only flags for section dumping, removal, and "
77 "addition are supported");
82 Expected
<const XCOFFConfig
&> ConfigManager::getXCOFFConfig() const {
83 if (!Common
.AddGnuDebugLink
.empty() || Common
.ExtractPartition
||
84 !Common
.SplitDWO
.empty() || !Common
.SymbolsPrefix
.empty() ||
85 !Common
.SymbolsPrefixRemove
.empty() || !Common
.SymbolsToSkip
.empty() ||
86 !Common
.AllocSectionsPrefix
.empty() ||
87 Common
.DiscardMode
!= DiscardType::None
|| !Common
.AddSection
.empty() ||
88 !Common
.DumpSection
.empty() || !Common
.SymbolsToAdd
.empty() ||
89 !Common
.KeepSection
.empty() || !Common
.OnlySection
.empty() ||
90 !Common
.ToRemove
.empty() || !Common
.SymbolsToGlobalize
.empty() ||
91 !Common
.SymbolsToKeep
.empty() || !Common
.SymbolsToLocalize
.empty() ||
92 !Common
.SymbolsToRemove
.empty() ||
93 !Common
.UnneededSymbolsToRemove
.empty() ||
94 !Common
.SymbolsToWeaken
.empty() || !Common
.SymbolsToKeepGlobal
.empty() ||
95 !Common
.SectionsToRename
.empty() || !Common
.SetSectionAlignment
.empty() ||
96 !Common
.SetSectionFlags
.empty() || !Common
.SetSectionType
.empty() ||
97 !Common
.SymbolsToRename
.empty() || Common
.ExtractDWO
||
98 Common
.ExtractMainPartition
|| Common
.OnlyKeepDebug
||
99 Common
.PreserveDates
|| Common
.StripAllGNU
|| Common
.StripDWO
||
100 Common
.StripDebug
|| Common
.StripNonAlloc
|| Common
.StripSections
||
101 Common
.Weaken
|| Common
.StripUnneeded
|| Common
.DecompressDebugSections
||
102 Common
.GapFill
!= 0 || Common
.PadTo
!= 0 ||
103 Common
.ChangeSectionLMAValAll
!= 0 ||
104 !Common
.ChangeSectionAddress
.empty()) {
105 return createStringError(
106 llvm::errc::invalid_argument
,
107 "no flags are supported yet, only basic copying is allowed");
113 } // end namespace objcopy
114 } // end namespace llvm