1 //===- Config.h -------------------------------------------------*- 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 //===----------------------------------------------------------------------===// 8 9 #ifndef LLD_WASM_CONFIG_H 10 #define LLD_WASM_CONFIG_H 11 12 #include "llvm/ADT/StringRef.h" 13 #include "llvm/ADT/StringSet.h" 14 #include "llvm/BinaryFormat/Wasm.h" 15 #include "llvm/Support/CachePruning.h" 16 17 namespace lld { 18 namespace wasm { 19 20 // For --unresolved-symbols. 21 // The `ImportFuncs` mode is an additional mode that corresponds to the 22 // --allow-undefined flag which turns undefined functions in imports 23 // as opposed ed to Ignore or Warn which turn them into unreachables. 24 enum class UnresolvedPolicy { ReportError, Warn, Ignore, ImportFuncs }; 25 26 // This struct contains the global configuration for the linker. 27 // Most fields are direct mapping from the command line options 28 // and such fields have the same name as the corresponding options. 29 // Most fields are initialized by the driver. 30 struct Configuration { 31 bool bsymbolic; 32 bool checkFeatures; 33 bool compressRelocations; 34 bool demangle; 35 bool disableVerify; 36 bool experimentalPic; 37 bool emitRelocs; 38 bool exportAll; 39 bool exportDynamic; 40 bool exportTable; 41 bool growableTable; 42 bool gcSections; 43 bool importMemory; 44 bool sharedMemory; 45 bool importTable; 46 llvm::Optional<bool> is64; 47 bool mergeDataSegments; 48 bool pie; 49 bool printGcSections; 50 bool relocatable; 51 bool saveTemps; 52 bool shared; 53 bool stripAll; 54 bool stripDebug; 55 bool stackFirst; 56 bool trace; 57 uint64_t globalBase; 58 uint64_t initialMemory; 59 uint64_t maxMemory; 60 uint64_t zStackSize; 61 unsigned ltoPartitions; 62 unsigned ltoo; 63 unsigned optimize; 64 llvm::StringRef thinLTOJobs; 65 bool ltoNewPassManager; 66 bool ltoDebugPassManager; 67 UnresolvedPolicy unresolvedSymbols; 68 69 llvm::StringRef entry; 70 llvm::StringRef mapFile; 71 llvm::StringRef outputFile; 72 llvm::StringRef thinLTOCacheDir; 73 74 llvm::StringSet<> allowUndefinedSymbols; 75 llvm::StringSet<> exportedSymbols; 76 std::vector<llvm::StringRef> searchPaths; 77 llvm::CachePruningPolicy thinLTOCachePolicy; 78 llvm::Optional<std::vector<std::string>> features; 79 80 // The following config options do not directly correspond to any 81 // particualr command line options. 82 83 // True if we are creating position-independent code. 84 bool isPic; 85 86 // The table offset at which to place function addresses. We reserve zero 87 // for the null function pointer. This gets set to 1 for executables and 0 88 // for shared libraries (since they always added to a dynamic offset at 89 // runtime). 90 uint32_t tableBase = 0; 91 }; 92 93 // The only instance of Configuration struct. 94 extern Configuration *config; 95 96 } // namespace wasm 97 } // namespace lld 98 99 #endif 100