xref: /freebsd/contrib/llvm-project/lld/MachO/Config.h (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
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/TextAPI/MachO/Architecture.h"
16 
17 #include <vector>
18 
19 namespace lld {
20 namespace macho {
21 
22 class Symbol;
23 struct SymbolPriorityEntry;
24 
25 struct Configuration {
26   Symbol *entry;
27   bool hasReexports = false;
28   llvm::StringRef installName;
29   llvm::StringRef outputFile;
30   llvm::MachO::Architecture arch;
31   llvm::MachO::HeaderFileType outputType;
32   std::vector<llvm::StringRef> librarySearchPaths;
33   // TODO: use the framework search paths
34   std::vector<llvm::StringRef> frameworkSearchPaths;
35   llvm::DenseMap<llvm::StringRef, SymbolPriorityEntry> priorities;
36 };
37 
38 // The symbol with the highest priority should be ordered first in the output
39 // section (modulo input section contiguity constraints). Using priority
40 // (highest first) instead of order (lowest first) has the convenient property
41 // that the default-constructed zero priority -- for symbols/sections without a
42 // user-defined order -- naturally ends up putting them at the end of the
43 // output.
44 struct SymbolPriorityEntry {
45   // The priority given to a matching symbol, regardless of which object file
46   // it originated from.
47   size_t anyObjectFile = 0;
48   // The priority given to a matching symbol from a particular object file.
49   llvm::DenseMap<llvm::StringRef, size_t> objectFiles;
50 };
51 
52 extern Configuration *config;
53 
54 } // namespace macho
55 } // namespace lld
56 
57 #endif
58