Path: blob/main/contrib/llvm-project/llvm/lib/ObjCopy/ConfigManager.cpp
35232 views
//===- ConfigManager.cpp --------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/ObjCopy/ConfigManager.h"9#include "llvm/Support/Errc.h"10#include "llvm/Support/Error.h"1112namespace llvm {13namespace objcopy {1415Expected<const COFFConfig &> ConfigManager::getCOFFConfig() const {16if (!Common.SplitDWO.empty() || !Common.SymbolsPrefix.empty() ||17!Common.SymbolsPrefixRemove.empty() || !Common.SymbolsToSkip.empty() ||18!Common.AllocSectionsPrefix.empty() || !Common.KeepSection.empty() ||19!Common.SymbolsToGlobalize.empty() || !Common.SymbolsToKeep.empty() ||20!Common.SymbolsToLocalize.empty() || !Common.SymbolsToWeaken.empty() ||21!Common.SymbolsToKeepGlobal.empty() || !Common.SectionsToRename.empty() ||22!Common.SetSectionAlignment.empty() || !Common.SetSectionType.empty() ||23Common.ExtractDWO || Common.PreserveDates || Common.StripDWO ||24Common.StripNonAlloc || Common.StripSections || Common.Weaken ||25Common.DecompressDebugSections ||26Common.DiscardMode == DiscardType::Locals ||27!Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||28Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0)29return createStringError(llvm::errc::invalid_argument,30"option is not supported for COFF");3132return COFF;33}3435Expected<const MachOConfig &> ConfigManager::getMachOConfig() const {36if (!Common.SplitDWO.empty() || !Common.SymbolsPrefix.empty() ||37!Common.SymbolsPrefixRemove.empty() || !Common.SymbolsToSkip.empty() ||38!Common.AllocSectionsPrefix.empty() || !Common.KeepSection.empty() ||39!Common.SymbolsToGlobalize.empty() || !Common.SymbolsToKeep.empty() ||40!Common.SymbolsToLocalize.empty() ||41!Common.SymbolsToKeepGlobal.empty() || !Common.SectionsToRename.empty() ||42!Common.UnneededSymbolsToRemove.empty() ||43!Common.SetSectionAlignment.empty() || !Common.SetSectionFlags.empty() ||44!Common.SetSectionType.empty() || Common.ExtractDWO ||45Common.PreserveDates || Common.StripAllGNU || Common.StripDWO ||46Common.StripNonAlloc || Common.StripSections ||47Common.DecompressDebugSections || Common.StripUnneeded ||48Common.DiscardMode == DiscardType::Locals ||49!Common.SymbolsToAdd.empty() || Common.GapFill != 0 ||50Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0)51return createStringError(llvm::errc::invalid_argument,52"option is not supported for MachO");5354return MachO;55}5657Expected<const WasmConfig &> ConfigManager::getWasmConfig() const {58if (!Common.AddGnuDebugLink.empty() || Common.ExtractPartition ||59!Common.SplitDWO.empty() || !Common.SymbolsPrefix.empty() ||60!Common.SymbolsPrefixRemove.empty() || !Common.SymbolsToSkip.empty() ||61!Common.AllocSectionsPrefix.empty() ||62Common.DiscardMode != DiscardType::None || !Common.SymbolsToAdd.empty() ||63!Common.SymbolsToGlobalize.empty() || !Common.SymbolsToLocalize.empty() ||64!Common.SymbolsToKeep.empty() || !Common.SymbolsToRemove.empty() ||65!Common.UnneededSymbolsToRemove.empty() ||66!Common.SymbolsToWeaken.empty() || !Common.SymbolsToKeepGlobal.empty() ||67!Common.SectionsToRename.empty() || !Common.SetSectionAlignment.empty() ||68!Common.SetSectionFlags.empty() || !Common.SetSectionType.empty() ||69!Common.SymbolsToRename.empty() || Common.GapFill != 0 ||70Common.PadTo != 0 || Common.ChangeSectionLMAValAll != 0)71return createStringError(llvm::errc::invalid_argument,72"only flags for section dumping, removal, and "73"addition are supported");7475return Wasm;76}7778Expected<const XCOFFConfig &> ConfigManager::getXCOFFConfig() const {79if (!Common.AddGnuDebugLink.empty() || Common.ExtractPartition ||80!Common.SplitDWO.empty() || !Common.SymbolsPrefix.empty() ||81!Common.SymbolsPrefixRemove.empty() || !Common.SymbolsToSkip.empty() ||82!Common.AllocSectionsPrefix.empty() ||83Common.DiscardMode != DiscardType::None || !Common.AddSection.empty() ||84!Common.DumpSection.empty() || !Common.SymbolsToAdd.empty() ||85!Common.KeepSection.empty() || !Common.OnlySection.empty() ||86!Common.ToRemove.empty() || !Common.SymbolsToGlobalize.empty() ||87!Common.SymbolsToKeep.empty() || !Common.SymbolsToLocalize.empty() ||88!Common.SymbolsToRemove.empty() ||89!Common.UnneededSymbolsToRemove.empty() ||90!Common.SymbolsToWeaken.empty() || !Common.SymbolsToKeepGlobal.empty() ||91!Common.SectionsToRename.empty() || !Common.SetSectionAlignment.empty() ||92!Common.SetSectionFlags.empty() || !Common.SetSectionType.empty() ||93!Common.SymbolsToRename.empty() || Common.ExtractDWO ||94Common.ExtractMainPartition || Common.OnlyKeepDebug ||95Common.PreserveDates || Common.StripAllGNU || Common.StripDWO ||96Common.StripDebug || Common.StripNonAlloc || Common.StripSections ||97Common.Weaken || Common.StripUnneeded || Common.DecompressDebugSections ||98Common.GapFill != 0 || Common.PadTo != 0 ||99Common.ChangeSectionLMAValAll != 0) {100return createStringError(101llvm::errc::invalid_argument,102"no flags are supported yet, only basic copying is allowed");103}104105return XCOFF;106}107108} // end namespace objcopy109} // end namespace llvm110111112