1 //===- Config.h -------------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLD_WASM_CONFIG_H
10 #define LLD_WASM_CONFIG_H
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/ADT/StringSet.h"
14 #include "llvm/BinaryFormat/Wasm.h"
15 #include "llvm/Support/CachePruning.h"
20 // For --unresolved-symbols.
21 enum class UnresolvedPolicy
{ ReportError
, Warn
, Ignore
};
23 // This struct contains the global configuration for the linker.
24 // Most fields are direct mapping from the command line options
25 // and such fields have the same name as the corresponding options.
26 // Most fields are initialized by the driver.
27 struct Configuration
{
30 bool compressRelocations
;
44 llvm::Optional
<bool> is64
;
45 bool mergeDataSegments
;
56 uint64_t initialMemory
;
59 unsigned ltoPartitions
;
62 llvm::StringRef thinLTOJobs
;
63 bool ltoNewPassManager
;
64 bool ltoDebugPassManager
;
65 UnresolvedPolicy unresolvedSymbols
;
67 llvm::StringRef entry
;
68 llvm::StringRef mapFile
;
69 llvm::StringRef outputFile
;
70 llvm::StringRef thinLTOCacheDir
;
72 llvm::StringSet
<> allowUndefinedSymbols
;
73 llvm::StringSet
<> exportedSymbols
;
74 std::vector
<llvm::StringRef
> requiredExports
;
75 std::vector
<llvm::StringRef
> searchPaths
;
76 llvm::CachePruningPolicy thinLTOCachePolicy
;
77 llvm::Optional
<std::vector
<std::string
>> features
;
79 // The following config options do not directly correspond to any
80 // particualr command line options.
82 // True if we are creating position-independent code.
85 // True if we have an MVP input that uses __indirect_function_table and which
86 // requires it to be allocated to table number 0.
87 bool legacyFunctionTable
= false;
89 // The table offset at which to place function addresses. We reserve zero
90 // for the null function pointer. This gets set to 1 for executables and 0
91 // for shared libraries (since they always added to a dynamic offset at
93 uint32_t tableBase
= 0;
96 // The only instance of Configuration struct.
97 extern Configuration
*config
;