//===- CopyConfig.h -------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLVM_TOOLS_LLVM_OBJCOPY_COPY_CONFIG_H #define LLVM_TOOLS_LLVM_OBJCOPY_COPY_CONFIG_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" // Necessary for llvm::DebugCompressionType::None #include "llvm/Target/TargetOptions.h" #include #include namespace llvm { namespace objcopy { // This type keeps track of the machine info for various architectures. This // lets us map architecture names to ELF types and the e_machine value of the // ELF file. struct MachineInfo { uint16_t EMachine; bool Is64Bit; bool IsLittleEndian; }; struct SectionRename { StringRef OriginalName; StringRef NewName; Optional NewFlags; }; // Configuration for copying/stripping a single file. struct CopyConfig { // Main input/output options StringRef InputFilename; StringRef InputFormat; StringRef OutputFilename; StringRef OutputFormat; // Only applicable for --input-format=binary MachineInfo BinaryArch; // Only applicable when --output-format!=binary (e.g. elf64-x86-64). Optional OutputArch; // Advanced options StringRef AddGnuDebugLink; StringRef BuildIdLinkDir; Optional BuildIdLinkInput; Optional BuildIdLinkOutput; StringRef SplitDWO; StringRef SymbolsPrefix; // Repeated options std::vector AddSection; std::vector DumpSection; std::vector KeepSection; std::vector OnlySection; std::vector SymbolsToGlobalize; std::vector SymbolsToKeep; std::vector SymbolsToLocalize; std::vector SymbolsToRemove; std::vector SymbolsToWeaken; std::vector ToRemove; std::vector SymbolsToKeepGlobal; // Map options StringMap SectionsToRename; StringMap SymbolsToRename; // Boolean options bool DeterministicArchives = true; bool DiscardAll = false; bool ExtractDWO = false; bool KeepFileSymbols = false; bool LocalizeHidden = false; bool OnlyKeepDebug = false; bool PreserveDates = false; bool StripAll = false; bool StripAllGNU = false; bool StripDWO = false; bool StripDebug = false; bool StripNonAlloc = false; bool StripSections = false; bool StripUnneeded = false; bool Weaken = false; bool DecompressDebugSections = false; DebugCompressionType CompressionType = DebugCompressionType::None; }; // Configuration for the overall invocation of this tool. When invoked as // objcopy, will always contain exactly one CopyConfig. When invoked as strip, // will contain one or more CopyConfigs. struct DriverConfig { SmallVector CopyConfigs; }; // ParseObjcopyOptions returns the config and sets the input arguments. If a // help flag is set then ParseObjcopyOptions will print the help messege and // exit. DriverConfig parseObjcopyOptions(ArrayRef ArgsArr); // ParseStripOptions returns the config and sets the input arguments. If a // help flag is set then ParseStripOptions will print the help messege and // exit. DriverConfig parseStripOptions(ArrayRef ArgsArr); } // namespace objcopy } // namespace llvm #endif