#include "ObjcopyOptions.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/ObjCopy/CommonConfig.h"
#include "llvm/ObjCopy/ConfigManager.h"
#include "llvm/ObjCopy/MachO/MachOConfig.h"
#include "llvm/Object/Binary.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/CRC.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBuffer.h"
usingnamespacellvm;
usingnamespacellvm::objcopy;
usingnamespacellvm::object;
usingnamespacellvm::opt;
namespace {
enum ObjcopyID { … };
namespace objcopy_opt {
#define PREFIX …
#include "ObjcopyOpts.inc"
#undef PREFIX
static constexpr opt::OptTable::Info ObjcopyInfoTable[] = …;
}
class ObjcopyOptTable : public opt::GenericOptTable { … };
enum InstallNameToolID { … };
namespace install_name_tool {
#define PREFIX …
#include "InstallNameToolOpts.inc"
#undef PREFIX
static constexpr opt::OptTable::Info InstallNameToolInfoTable[] = …;
}
class InstallNameToolOptTable : public opt::GenericOptTable { … };
enum BitcodeStripID { … };
namespace bitcode_strip {
#define PREFIX …
#include "BitcodeStripOpts.inc"
#undef PREFIX
static constexpr opt::OptTable::Info BitcodeStripInfoTable[] = …;
}
class BitcodeStripOptTable : public opt::GenericOptTable { … };
enum StripID { … };
namespace strip {
#define PREFIX …
#include "StripOpts.inc"
#undef PREFIX
static constexpr opt::OptTable::Info StripInfoTable[] = …;
}
class StripOptTable : public opt::GenericOptTable { … };
}
static SectionFlag parseSectionRenameFlag(StringRef SectionName) { … }
static Expected<SectionFlag>
parseSectionFlagSet(ArrayRef<StringRef> SectionFlags) { … }
static Expected<SectionRename> parseRenameSectionValue(StringRef FlagValue) { … }
static Expected<std::pair<StringRef, uint64_t>>
parseSetSectionAttribute(StringRef Option, StringRef FlagValue) { … }
static Expected<SectionFlagsUpdate>
parseSetSectionFlagValue(StringRef FlagValue) { … }
static Expected<uint8_t> parseVisibilityType(StringRef VisType) { … }
namespace {
struct TargetInfo { … };
}
static const StringMap<MachineInfo> TargetMap{ … };
static Expected<TargetInfo>
getOutputTargetInfoByTargetName(StringRef TargetName) { … }
static Error addSymbolsFromFile(NameMatcher &Symbols, BumpPtrAllocator &Alloc,
StringRef Filename, MatchStyle MS,
function_ref<Error(Error)> ErrorCallback) { … }
static Error addSymbolsToRenameFromFile(StringMap<StringRef> &SymbolsToRename,
BumpPtrAllocator &Alloc,
StringRef Filename) { … }
template <class T> static ErrorOr<T> getAsInteger(StringRef Val) { … }
namespace {
enum class ToolType { … };
}
static void printHelp(const opt::OptTable &OptTable, raw_ostream &OS,
ToolType Tool) { … }
static Expected<NewSymbolInfo> parseNewSymbolInfo(StringRef FlagValue) { … }
static Error loadNewSectionData(StringRef ArgValue, StringRef OptionName,
SmallVector<NewSectionInfo, 0> &NewSections) { … }
static Expected<int64_t> parseChangeSectionLMA(StringRef ArgValue,
StringRef OptionName) { … }
static Expected<SectionPatternAddressUpdate>
parseChangeSectionAddr(StringRef ArgValue, StringRef OptionName,
MatchStyle SectionMatchStyle,
function_ref<Error(Error)> ErrorCallback) { … }
Expected<DriverConfig>
objcopy::parseObjcopyOptions(ArrayRef<const char *> RawArgsArr,
function_ref<Error(Error)> ErrorCallback) { … }
Expected<DriverConfig>
objcopy::parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr) { … }
Expected<DriverConfig>
objcopy::parseBitcodeStripOptions(ArrayRef<const char *> ArgsArr,
function_ref<Error(Error)> ErrorCallback) { … }
Expected<DriverConfig>
objcopy::parseStripOptions(ArrayRef<const char *> RawArgsArr,
function_ref<Error(Error)> ErrorCallback) { … }