1 //===- SymbolTable.h --------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLD_MACHO_SYMBOL_TABLE_H
10 #define LLD_MACHO_SYMBOL_TABLE_H
14 #include "lld/Common/LLVM.h"
15 #include "llvm/ADT/CachedHashString.h"
16 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/Object/Archive.h"
27 class MachHeaderSection
;
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.
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
,
44 bool isWeakDefCanBeHidden
);
46 Symbol
*addUndefined(StringRef name
, InputFile
*, bool isWeakRef
);
48 Symbol
*addCommon(StringRef name
, InputFile
*, uint64_t size
, uint32_t align
,
49 bool isPrivateExtern
);
51 Symbol
*addDylib(StringRef name
, DylibFile
*file
, bool isWeakDef
, bool isTlv
);
52 Symbol
*addDynamicLookup(StringRef name
);
54 Symbol
*addLazyArchive(StringRef name
, ArchiveFile
*file
,
55 const llvm::object::Archive::Symbol
&sym
);
56 Symbol
*addLazyObject(StringRef name
, InputFile
&file
);
58 Defined
*addSynthetic(StringRef name
, InputSection
*, uint64_t value
,
59 bool isPrivateExtern
, bool includeInSymtab
,
60 bool referencedDynamically
);
62 ArrayRef
<Symbol
*> getSymbols() const { return symVector
; }
63 Symbol
*find(llvm::CachedHashStringRef name
);
64 Symbol
*find(StringRef name
) { return find(llvm::CachedHashStringRef(name
)); }
67 std::pair
<Symbol
*, bool> insert(StringRef name
, const InputFile
*);
68 llvm::DenseMap
<llvm::CachedHashStringRef
, int> symMap
;
69 std::vector
<Symbol
*> symVector
;
72 void reportPendingUndefinedSymbols();
74 // Call reportPendingUndefinedSymbols() to emit diagnostics.
75 void treatUndefinedSymbol(const Undefined
&, StringRef source
);
76 void treatUndefinedSymbol(const Undefined
&, const InputSection
*,
79 extern std::unique_ptr
<SymbolTable
> symtab
;