[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / llvm / tools / llvm-objcopy / ConfigManager.h
blobc0d0e8bbc7219d85a7a63dd82d3e4bf33c73dc8c
1 //===- ConfigManager.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_CONFIGMANAGER_H
10 #define LLVM_TOOLS_LLVM_OBJCOPY_CONFIGMANAGER_H
12 #include "COFF/COFFConfig.h"
13 #include "CommonConfig.h"
14 #include "ELF/ELFConfig.h"
15 #include "MachO/MachOConfig.h"
16 #include "MultiFormatConfig.h"
17 #include "wasm/WasmConfig.h"
18 #include "llvm/Support/Allocator.h"
19 #include <vector>
21 namespace llvm {
22 namespace objcopy {
24 // ConfigManager keeps all configurations and prepare
25 // format-specific options.
26 struct ConfigManager : public MultiFormatConfig {
27 virtual ~ConfigManager() {}
29 const CommonConfig &getCommonConfig() const override { return Common; }
30 Expected<const ELFConfig &> getELFConfig() const override;
31 Expected<const COFFConfig &> getCOFFConfig() const override;
32 Expected<const MachOConfig &> getMachOConfig() const override;
33 Expected<const WasmConfig &> getWasmConfig() const override;
35 // All configs.
36 CommonConfig Common;
37 ELFConfig ELF;
38 COFFConfig COFF;
39 MachOConfig MachO;
40 WasmConfig Wasm;
43 // Configuration for the overall invocation of this tool. When invoked as
44 // objcopy, will always contain exactly one CopyConfig. When invoked as strip,
45 // will contain one or more CopyConfigs.
46 struct DriverConfig {
47 SmallVector<ConfigManager, 1> CopyConfigs;
48 BumpPtrAllocator Alloc;
51 // ParseObjcopyOptions returns the config and sets the input arguments. If a
52 // help flag is set then ParseObjcopyOptions will print the help messege and
53 // exit. ErrorCallback is used to handle recoverable errors. An Error returned
54 // by the callback aborts the parsing and is then returned by this function.
55 Expected<DriverConfig>
56 parseObjcopyOptions(ArrayRef<const char *> ArgsArr,
57 llvm::function_ref<Error(Error)> ErrorCallback);
59 // ParseInstallNameToolOptions returns the config and sets the input arguments.
60 // If a help flag is set then ParseInstallNameToolOptions will print the help
61 // messege and exit.
62 Expected<DriverConfig>
63 parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr);
65 // ParseBitcodeStripOptions returns the config and sets the input arguments.
66 // If a help flag is set then ParseBitcodeStripOptions will print the help
67 // messege and exit.
68 Expected<DriverConfig> parseBitcodeStripOptions(ArrayRef<const char *> ArgsArr);
70 // ParseStripOptions returns the config and sets the input arguments. If a
71 // help flag is set then ParseStripOptions will print the help messege and
72 // exit. ErrorCallback is used to handle recoverable errors. An Error returned
73 // by the callback aborts the parsing and is then returned by this function.
74 Expected<DriverConfig>
75 parseStripOptions(ArrayRef<const char *> ArgsArr,
76 llvm::function_ref<Error(Error)> ErrorCallback);
77 } // namespace objcopy
78 } // namespace llvm
80 #endif // LLVM_TOOLS_LLVM_OBJCOPY_CONFIGMANAGER_H