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