annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 //===- SymbolTable.h --------------------------------------------*- C++ -*-===//
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 //
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 //
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #ifndef LLD_MACHO_SYMBOL_TABLE_H
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #define LLD_MACHO_SYMBOL_TABLE_H
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
12 #include "Symbols.h"
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
13
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #include "lld/Common/LLVM.h"
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 #include "llvm/ADT/CachedHashString.h"
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 #include "llvm/ADT/DenseMap.h"
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 #include "llvm/Object/Archive.h"
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 namespace lld {
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 namespace macho {
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 class ArchiveFile;
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 class DylibFile;
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
24 class InputFile;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
25 class ObjFile;
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 class InputSection;
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
27 class MachHeaderSection;
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 class Symbol;
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
29 class Defined;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
30 class Undefined;
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
32 /*
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
33 * Note that the SymbolTable handles name collisions by calling
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
34 * replaceSymbol(), which does an in-place update of the Symbol via `placement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
35 * new`. Therefore, there is no need to update any relocations that hold
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
36 * pointers the "old" Symbol -- they will automatically point to the new one.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
37 */
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 class SymbolTable {
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 public:
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
40 Defined *addDefined(StringRef name, InputFile *, InputSection *,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
41 uint64_t value, uint64_t size, bool isWeakDef,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
42 bool isPrivateExtern, bool isThumb,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
43 bool isReferencedDynamically, bool noDeadStrip);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
45 Symbol *addUndefined(StringRef name, InputFile *, bool isWeakRef);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
47 Symbol *addCommon(StringRef name, InputFile *, uint64_t size, uint32_t align,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
48 bool isPrivateExtern);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
49
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
50 Symbol *addDylib(StringRef name, DylibFile *file, bool isWeakDef, bool isTlv);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
51 Symbol *addDynamicLookup(StringRef name);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 Symbol *addLazy(StringRef name, ArchiveFile *file,
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 const llvm::object::Archive::Symbol &sym);
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
56 Defined *addSynthetic(StringRef name, InputSection *, uint64_t value,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
57 bool isPrivateExtern, bool includeInSymtab,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
58 bool referencedDynamically);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
59
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 ArrayRef<Symbol *> getSymbols() const { return symVector; }
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
61 Symbol *find(llvm::CachedHashStringRef name);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
62 Symbol *find(StringRef name) { return find(llvm::CachedHashStringRef(name)); }
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 private:
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
65 std::pair<Symbol *, bool> insert(StringRef name, const InputFile *);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 llvm::DenseMap<llvm::CachedHashStringRef, int> symMap;
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 std::vector<Symbol *> symVector;
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 };
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
70 void treatUndefinedSymbol(const Undefined &, StringRef source = "");
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
71
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 extern SymbolTable *symtab;
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 } // namespace macho
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 } // namespace lld
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 #endif