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_MACHO_CONFIG_H 10 #define LLD_MACHO_CONFIG_H 11 12 #include "llvm/ADT/DenseMap.h" 13 #include "llvm/ADT/StringRef.h" 14 #include "llvm/BinaryFormat/MachO.h" 15 #include "llvm/Support/VersionTuple.h" 16 #include "llvm/TextAPI/MachO/Architecture.h" 17 #include "llvm/TextAPI/MachO/Platform.h" 18 19 #include <vector> 20 21 namespace lld { 22 namespace macho { 23 24 class Symbol; 25 struct SymbolPriorityEntry; 26 27 struct PlatformInfo { 28 llvm::MachO::PlatformKind kind; 29 llvm::VersionTuple minimum; 30 llvm::VersionTuple sdk; 31 }; 32 33 enum class UndefinedSymbolTreatment { 34 unknown, 35 error, 36 warning, 37 suppress, 38 dynamic_lookup, 39 }; 40 41 struct Configuration { 42 Symbol *entry; 43 bool hasReexports = false; 44 bool allLoad = false; 45 bool forceLoadObjC = false; 46 bool staticLink = false; 47 bool implicitDylibs = false; 48 bool isPic = false; 49 bool headerPadMaxInstallNames = false; 50 bool ltoNewPassManager = LLVM_ENABLE_NEW_PASS_MANAGER; 51 bool printEachFile = false; 52 bool printWhyLoad = false; 53 bool searchDylibsFirst = false; 54 bool saveTemps = false; 55 uint32_t headerPad; 56 uint32_t dylibCompatibilityVersion = 0; 57 uint32_t dylibCurrentVersion = 0; 58 llvm::StringRef installName; 59 llvm::StringRef outputFile; 60 llvm::StringRef ltoObjPath; 61 bool demangle = false; 62 llvm::MachO::Architecture arch; 63 PlatformInfo platform; 64 UndefinedSymbolTreatment undefinedSymbolTreatment = 65 UndefinedSymbolTreatment::error; 66 llvm::MachO::HeaderFileType outputType; 67 std::vector<llvm::StringRef> systemLibraryRoots; 68 std::vector<llvm::StringRef> librarySearchPaths; 69 std::vector<llvm::StringRef> frameworkSearchPaths; 70 std::vector<llvm::StringRef> runtimePaths; 71 llvm::DenseMap<llvm::StringRef, SymbolPriorityEntry> priorities; 72 }; 73 74 // The symbol with the highest priority should be ordered first in the output 75 // section (modulo input section contiguity constraints). Using priority 76 // (highest first) instead of order (lowest first) has the convenient property 77 // that the default-constructed zero priority -- for symbols/sections without a 78 // user-defined order -- naturally ends up putting them at the end of the 79 // output. 80 struct SymbolPriorityEntry { 81 // The priority given to a matching symbol, regardless of which object file 82 // it originated from. 83 size_t anyObjectFile = 0; 84 // The priority given to a matching symbol from a particular object file. 85 llvm::DenseMap<llvm::StringRef, size_t> objectFiles; 86 }; 87 88 extern Configuration *config; 89 90 } // namespace macho 91 } // namespace lld 92 93 #endif 94