• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 struct Configuration {
34   Symbol *entry;
35   bool hasReexports = false;
36   bool allLoad = false;
37   bool forceLoadObjC = false;
38   bool staticLink = false;
39   bool isPic = false;
40   bool headerPadMaxInstallNames = false;
41   bool printEachFile = false;
42   bool printWhyLoad = false;
43   bool searchDylibsFirst = false;
44   bool saveTemps = false;
45   uint32_t headerPad;
46   llvm::StringRef installName;
47   llvm::StringRef outputFile;
48   bool demangle = false;
49   llvm::MachO::Architecture arch;
50   PlatformInfo platform;
51   llvm::MachO::HeaderFileType outputType;
52   std::vector<llvm::StringRef> systemLibraryRoots;
53   std::vector<llvm::StringRef> librarySearchPaths;
54   std::vector<llvm::StringRef> frameworkSearchPaths;
55   std::vector<llvm::StringRef> runtimePaths;
56   llvm::DenseMap<llvm::StringRef, SymbolPriorityEntry> priorities;
57 };
58 
59 // The symbol with the highest priority should be ordered first in the output
60 // section (modulo input section contiguity constraints). Using priority
61 // (highest first) instead of order (lowest first) has the convenient property
62 // that the default-constructed zero priority -- for symbols/sections without a
63 // user-defined order -- naturally ends up putting them at the end of the
64 // output.
65 struct SymbolPriorityEntry {
66   // The priority given to a matching symbol, regardless of which object file
67   // it originated from.
68   size_t anyObjectFile = 0;
69   // The priority given to a matching symbol from a particular object file.
70   llvm::DenseMap<llvm::StringRef, size_t> objectFiles;
71 };
72 
73 extern Configuration *config;
74 
75 } // namespace macho
76 } // namespace lld
77 
78 #endif
79