xref: /freebsd/contrib/llvm-project/lld/MachO/SymbolTable.h (revision 6be3386466ab79a84b48429ae66244f21526d3df)
1 //===- SymbolTable.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_SYMBOL_TABLE_H
10 #define LLD_MACHO_SYMBOL_TABLE_H
11 
12 #include "lld/Common/LLVM.h"
13 #include "llvm/ADT/CachedHashString.h"
14 #include "llvm/ADT/DenseMap.h"
15 #include "llvm/Object/Archive.h"
16 
17 namespace lld {
18 namespace macho {
19 
20 class ArchiveFile;
21 class DylibFile;
22 class InputSection;
23 class Symbol;
24 
25 class SymbolTable {
26 public:
27   Symbol *addDefined(StringRef name, InputSection *isec, uint32_t value);
28 
29   Symbol *addUndefined(StringRef name);
30 
31   Symbol *addDylib(StringRef name, DylibFile *file);
32 
33   Symbol *addLazy(StringRef name, ArchiveFile *file,
34                   const llvm::object::Archive::Symbol &sym);
35 
36   ArrayRef<Symbol *> getSymbols() const { return symVector; }
37   Symbol *find(StringRef name);
38 
39 private:
40   std::pair<Symbol *, bool> insert(StringRef name);
41   llvm::DenseMap<llvm::CachedHashStringRef, int> symMap;
42   std::vector<Symbol *> symVector;
43 };
44 
45 extern SymbolTable *symtab;
46 
47 } // namespace macho
48 } // namespace lld
49 
50 #endif
51