[sanitizer] Improve FreeBSD ASLR detection
[llvm-project.git] / llvm / tools / dsymutil / LinkUtils.h
blob872a65deb4dcd5ef6a40675ae3f7807ec23c0e94
1 //===- tools/dsymutil/LinkUtils.h - Dwarf linker utilities ------*- C++ -*-===//
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_DSYMUTIL_LINKOPTIONS_H
10 #define LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
12 #include "SymbolMap.h"
14 #include "llvm/ADT/Twine.h"
15 #include "llvm/Remarks/RemarkFormat.h"
16 #include "llvm/Support/VirtualFileSystem.h"
17 #include "llvm/Support/WithColor.h"
19 #include "llvm/DWARFLinker/DWARFLinker.h"
20 #include "llvm/DWARFLinker/DWARFStreamer.h"
21 #include <string>
23 namespace llvm {
24 namespace dsymutil {
26 struct LinkOptions {
27 /// Verbosity
28 bool Verbose = false;
30 /// Statistics
31 bool Statistics = false;
33 /// Skip emitting output
34 bool NoOutput = false;
36 /// Do not unique types according to ODR
37 bool NoODR = false;
39 /// Update
40 bool Update = false;
42 /// Do not check swiftmodule timestamp
43 bool NoTimestamp = false;
45 /// Whether we want a static variable to force us to keep its enclosing
46 /// function.
47 bool KeepFunctionForStatic = false;
49 /// Number of threads.
50 unsigned Threads = 1;
52 // Output file type.
53 OutputFileType FileType = OutputFileType::Object;
55 /// The accelerator table kind
56 AccelTableKind TheAccelTableKind;
58 /// -oso-prepend-path
59 std::string PrependPath;
61 /// The -object-prefix-map.
62 std::map<std::string, std::string> ObjectPrefixMap;
64 /// The Resources directory in the .dSYM bundle.
65 Optional<std::string> ResourceDir;
67 /// Symbol map translator.
68 SymbolMapTranslator Translator;
70 /// Virtual File System.
71 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
72 vfs::getRealFileSystem();
74 /// Fields used for linking and placing remarks into the .dSYM bundle.
75 /// @{
77 /// Number of debug maps processed in total.
78 unsigned NumDebugMaps = 0;
80 /// -remarks-prepend-path: prepend a path to all the external remark file
81 /// paths found in remark metadata.
82 std::string RemarksPrependPath;
84 /// The output format of the remarks.
85 remarks::Format RemarksFormat = remarks::Format::Bitstream;
87 /// @}
89 LinkOptions() = default;
92 inline void warn(Twine Warning, Twine Context = {}) {
93 WithColor::warning() << Warning + "\n";
94 if (!Context.isTriviallyEmpty())
95 WithColor::note() << Twine("while processing ") + Context + "\n";
98 inline bool error(Twine Error, Twine Context = {}) {
99 WithColor::error() << Error + "\n";
100 if (!Context.isTriviallyEmpty())
101 WithColor::note() << Twine("while processing ") + Context + "\n";
102 return false;
105 } // end namespace dsymutil
106 } // end namespace llvm
108 #endif // LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H