[ASan] Do not instrument other runtime functions with `__asan_handle_no_return`
[llvm-core.git] / tools / llvm-objcopy / CopyConfig.h
blob9a9a0981bc81fc295afb07144cc9f8daa4ecf0fa
1 //===- CopyConfig.h -------------------------------------------------------===//
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_TOOLS_LLVM_OBJCOPY_COPY_CONFIG_H
10 #define LLVM_TOOLS_LLVM_OBJCOPY_COPY_CONFIG_H
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/Optional.h"
14 #include "llvm/ADT/SmallVector.h"
15 #include "llvm/ADT/StringMap.h"
16 #include "llvm/ADT/StringRef.h"
17 // Necessary for llvm::DebugCompressionType::None
18 #include "llvm/Target/TargetOptions.h"
19 #include <string>
20 #include <vector>
22 namespace llvm {
23 namespace objcopy {
25 // This type keeps track of the machine info for various architectures. This
26 // lets us map architecture names to ELF types and the e_machine value of the
27 // ELF file.
28 struct MachineInfo {
29 uint16_t EMachine;
30 bool Is64Bit;
31 bool IsLittleEndian;
34 struct SectionRename {
35 StringRef OriginalName;
36 StringRef NewName;
37 Optional<uint64_t> NewFlags;
40 struct SectionFlagsUpdate {
41 StringRef Name;
42 uint64_t NewFlags;
45 enum class DiscardType {
46 None, // Default
47 All, // --discard-all (-x)
48 Locals, // --discard-locals (-X)
51 // Configuration for copying/stripping a single file.
52 struct CopyConfig {
53 // Main input/output options
54 StringRef InputFilename;
55 StringRef InputFormat;
56 StringRef OutputFilename;
57 StringRef OutputFormat;
59 // Only applicable for --input-format=binary
60 MachineInfo BinaryArch;
61 // Only applicable when --output-format!=binary (e.g. elf64-x86-64).
62 Optional<MachineInfo> OutputArch;
64 // Advanced options
65 StringRef AddGnuDebugLink;
66 StringRef BuildIdLinkDir;
67 Optional<StringRef> BuildIdLinkInput;
68 Optional<StringRef> BuildIdLinkOutput;
69 StringRef SplitDWO;
70 StringRef SymbolsPrefix;
71 DiscardType DiscardMode = DiscardType::None;
73 // Repeated options
74 std::vector<StringRef> AddSection;
75 std::vector<StringRef> DumpSection;
76 std::vector<StringRef> KeepSection;
77 std::vector<StringRef> OnlySection;
78 std::vector<StringRef> SymbolsToGlobalize;
79 std::vector<StringRef> SymbolsToKeep;
80 std::vector<StringRef> SymbolsToLocalize;
81 std::vector<StringRef> SymbolsToRemove;
82 std::vector<StringRef> SymbolsToWeaken;
83 std::vector<StringRef> ToRemove;
84 std::vector<std::string> SymbolsToKeepGlobal;
86 // Map options
87 StringMap<SectionRename> SectionsToRename;
88 StringMap<SectionFlagsUpdate> SetSectionFlags;
89 StringMap<StringRef> SymbolsToRename;
91 // Boolean options
92 bool DeterministicArchives = true;
93 bool ExtractDWO = false;
94 bool KeepFileSymbols = false;
95 bool LocalizeHidden = false;
96 bool OnlyKeepDebug = false;
97 bool PreserveDates = false;
98 bool StripAll = false;
99 bool StripAllGNU = false;
100 bool StripDWO = false;
101 bool StripDebug = false;
102 bool StripNonAlloc = false;
103 bool StripSections = false;
104 bool StripUnneeded = false;
105 bool Weaken = false;
106 bool DecompressDebugSections = false;
107 DebugCompressionType CompressionType = DebugCompressionType::None;
110 // Configuration for the overall invocation of this tool. When invoked as
111 // objcopy, will always contain exactly one CopyConfig. When invoked as strip,
112 // will contain one or more CopyConfigs.
113 struct DriverConfig {
114 SmallVector<CopyConfig, 1> CopyConfigs;
117 // ParseObjcopyOptions returns the config and sets the input arguments. If a
118 // help flag is set then ParseObjcopyOptions will print the help messege and
119 // exit.
120 DriverConfig parseObjcopyOptions(ArrayRef<const char *> ArgsArr);
122 // ParseStripOptions returns the config and sets the input arguments. If a
123 // help flag is set then ParseStripOptions will print the help messege and
124 // exit.
125 DriverConfig parseStripOptions(ArrayRef<const char *> ArgsArr);
127 } // namespace objcopy
128 } // namespace llvm
130 #endif