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 // This struct contains the global configuration for the linker. 21 // Most fields are direct mapping from the command line options 22 // and such fields have the same name as the corresponding options. 23 // Most fields are initialized by the driver. 24 struct Configuration { 25 bool allowUndefined; 26 bool checkFeatures; 27 bool compressRelocations; 28 bool demangle; 29 bool disableVerify; 30 bool emitRelocs; 31 bool exportAll; 32 bool exportDynamic; 33 bool exportTable; 34 bool growableTable; 35 bool gcSections; 36 bool importMemory; 37 bool sharedMemory; 38 bool importTable; 39 bool mergeDataSegments; 40 bool pie; 41 bool printGcSections; 42 bool relocatable; 43 bool saveTemps; 44 bool shared; 45 bool stripAll; 46 bool stripDebug; 47 bool stackFirst; 48 bool trace; 49 uint32_t globalBase; 50 uint32_t initialMemory; 51 uint32_t maxMemory; 52 uint32_t zStackSize; 53 unsigned ltoPartitions; 54 unsigned ltoo; 55 unsigned optimize; 56 unsigned thinLTOJobs; 57 58 llvm::StringRef entry; 59 llvm::StringRef outputFile; 60 llvm::StringRef thinLTOCacheDir; 61 62 llvm::StringSet<> allowUndefinedSymbols; 63 llvm::StringSet<> exportedSymbols; 64 std::vector<llvm::StringRef> searchPaths; 65 llvm::CachePruningPolicy thinLTOCachePolicy; 66 llvm::Optional<std::vector<std::string>> features; 67 68 // The following config options do not directly correspond to any 69 // particualr command line options. 70 71 // True if we are creating position-independent code. 72 bool isPic; 73 74 // The table offset at which to place function addresses. We reserve zero 75 // for the null function pointer. This gets set to 1 for executables and 0 76 // for shared libraries (since they always added to a dynamic offset at 77 // runtime). 78 uint32_t tableBase = 0; 79 }; 80 81 // The only instance of Configuration struct. 82 extern Configuration *config; 83 84 } // namespace wasm 85 } // namespace lld 86 87 #endif 88