comparison lld/MachO/SymbolTable.h @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 0572611fdcc8
children c4bab56944e8
comparison
equal deleted inserted replaced
173:0572611fdcc8 207:2e18cbf3894f
7 //===----------------------------------------------------------------------===// 7 //===----------------------------------------------------------------------===//
8 8
9 #ifndef LLD_MACHO_SYMBOL_TABLE_H 9 #ifndef LLD_MACHO_SYMBOL_TABLE_H
10 #define LLD_MACHO_SYMBOL_TABLE_H 10 #define LLD_MACHO_SYMBOL_TABLE_H
11 11
12 #include "Symbols.h"
13
12 #include "lld/Common/LLVM.h" 14 #include "lld/Common/LLVM.h"
13 #include "llvm/ADT/CachedHashString.h" 15 #include "llvm/ADT/CachedHashString.h"
14 #include "llvm/ADT/DenseMap.h" 16 #include "llvm/ADT/DenseMap.h"
15 #include "llvm/Object/Archive.h" 17 #include "llvm/Object/Archive.h"
16 18
17 namespace lld { 19 namespace lld {
18 namespace macho { 20 namespace macho {
19 21
20 class ArchiveFile; 22 class ArchiveFile;
21 class DylibFile; 23 class DylibFile;
24 class InputFile;
25 class ObjFile;
22 class InputSection; 26 class InputSection;
27 class MachHeaderSection;
23 class Symbol; 28 class Symbol;
29 class Defined;
30 class Undefined;
24 31
32 /*
33 * Note that the SymbolTable handles name collisions by calling
34 * replaceSymbol(), which does an in-place update of the Symbol via `placement
35 * new`. Therefore, there is no need to update any relocations that hold
36 * pointers the "old" Symbol -- they will automatically point to the new one.
37 */
25 class SymbolTable { 38 class SymbolTable {
26 public: 39 public:
27 Symbol *addDefined(StringRef name, InputSection *isec, uint32_t value); 40 Defined *addDefined(StringRef name, InputFile *, InputSection *,
41 uint64_t value, uint64_t size, bool isWeakDef,
42 bool isPrivateExtern, bool isThumb,
43 bool isReferencedDynamically, bool noDeadStrip);
28 44
29 Symbol *addUndefined(StringRef name); 45 Symbol *addUndefined(StringRef name, InputFile *, bool isWeakRef);
30 46
31 Symbol *addDylib(StringRef name, DylibFile *file); 47 Symbol *addCommon(StringRef name, InputFile *, uint64_t size, uint32_t align,
48 bool isPrivateExtern);
49
50 Symbol *addDylib(StringRef name, DylibFile *file, bool isWeakDef, bool isTlv);
51 Symbol *addDynamicLookup(StringRef name);
32 52
33 Symbol *addLazy(StringRef name, ArchiveFile *file, 53 Symbol *addLazy(StringRef name, ArchiveFile *file,
34 const llvm::object::Archive::Symbol &sym); 54 const llvm::object::Archive::Symbol &sym);
35 55
56 Defined *addSynthetic(StringRef name, InputSection *, uint64_t value,
57 bool isPrivateExtern, bool includeInSymtab,
58 bool referencedDynamically);
59
36 ArrayRef<Symbol *> getSymbols() const { return symVector; } 60 ArrayRef<Symbol *> getSymbols() const { return symVector; }
37 Symbol *find(StringRef name); 61 Symbol *find(llvm::CachedHashStringRef name);
62 Symbol *find(StringRef name) { return find(llvm::CachedHashStringRef(name)); }
38 63
39 private: 64 private:
40 std::pair<Symbol *, bool> insert(StringRef name); 65 std::pair<Symbol *, bool> insert(StringRef name, const InputFile *);
41 llvm::DenseMap<llvm::CachedHashStringRef, int> symMap; 66 llvm::DenseMap<llvm::CachedHashStringRef, int> symMap;
42 std::vector<Symbol *> symVector; 67 std::vector<Symbol *> symVector;
43 }; 68 };
69
70 void treatUndefinedSymbol(const Undefined &, StringRef source = "");
44 71
45 extern SymbolTable *symtab; 72 extern SymbolTable *symtab;
46 73
47 } // namespace macho 74 } // namespace macho
48 } // namespace lld 75 } // namespace lld