2017-11-18 02:14:09 +08:00
|
|
|
//===- SymbolTable.cpp ----------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "SymbolTable.h"
|
|
|
|
#include "Config.h"
|
2018-01-10 09:13:34 +08:00
|
|
|
#include "InputChunks.h"
|
2018-02-23 13:08:53 +08:00
|
|
|
#include "InputGlobal.h"
|
2017-11-30 09:40:08 +08:00
|
|
|
#include "WriterUtils.h"
|
2017-11-18 02:14:09 +08:00
|
|
|
#include "lld/Common/ErrorHandler.h"
|
2017-11-29 04:39:17 +08:00
|
|
|
#include "lld/Common/Memory.h"
|
2018-02-14 06:30:52 +08:00
|
|
|
#include "llvm/ADT/SetVector.h"
|
2017-11-18 02:14:09 +08:00
|
|
|
|
|
|
|
#define DEBUG_TYPE "lld"
|
|
|
|
|
|
|
|
using namespace llvm;
|
2018-01-10 08:52:20 +08:00
|
|
|
using namespace llvm::wasm;
|
2017-11-18 02:14:09 +08:00
|
|
|
using namespace lld;
|
|
|
|
using namespace lld::wasm;
|
|
|
|
|
|
|
|
SymbolTable *lld::wasm::Symtab;
|
|
|
|
|
|
|
|
void SymbolTable::addFile(InputFile *File) {
|
|
|
|
log("Processing: " + toString(File));
|
|
|
|
File->parse();
|
|
|
|
|
2018-05-31 02:07:52 +08:00
|
|
|
// LLVM bitcode file
|
|
|
|
if (auto *F = dyn_cast<BitcodeFile>(File))
|
|
|
|
BitcodeFiles.push_back(F);
|
|
|
|
else if (auto *F = dyn_cast<ObjFile>(File))
|
2017-11-18 02:14:09 +08:00
|
|
|
ObjectFiles.push_back(F);
|
|
|
|
}
|
|
|
|
|
2018-05-31 02:07:52 +08:00
|
|
|
// This function is where all the optimizations of link-time
|
|
|
|
// optimization happens. When LTO is in use, some input files are
|
|
|
|
// not in native object file format but in the LLVM bitcode format.
|
|
|
|
// This function compiles bitcode files into a few big native files
|
|
|
|
// using LLVM functions and replaces bitcode symbols with the results.
|
|
|
|
// Because all bitcode files that the program consists of are passed
|
|
|
|
// to the compiler at once, it can do whole-program optimization.
|
|
|
|
void SymbolTable::addCombinedLTOObject() {
|
|
|
|
if (BitcodeFiles.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Compile bitcode files and replace bitcode symbols.
|
|
|
|
LTO.reset(new BitcodeCompiler);
|
|
|
|
for (BitcodeFile *F : BitcodeFiles)
|
|
|
|
LTO->add(*F);
|
|
|
|
|
|
|
|
for (StringRef Filename : LTO->compile()) {
|
|
|
|
auto *Obj = make<ObjFile>(MemoryBufferRef(Filename, "lto.tmp"));
|
|
|
|
Obj->parse();
|
|
|
|
ObjectFiles.push_back(Obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
void SymbolTable::reportRemainingUndefines() {
|
2018-02-14 06:30:52 +08:00
|
|
|
SetVector<Symbol *> Undefs;
|
2017-12-07 09:51:24 +08:00
|
|
|
for (Symbol *Sym : SymVector) {
|
2018-05-31 02:07:52 +08:00
|
|
|
if (!Sym->isUndefined() || Sym->isWeak())
|
|
|
|
continue;
|
|
|
|
if (Config->AllowUndefinedSymbols.count(Sym->getName()) != 0)
|
|
|
|
continue;
|
|
|
|
if (!Sym->IsUsedInRegularObj)
|
|
|
|
continue;
|
|
|
|
Undefs.insert(Sym);
|
2017-11-18 02:14:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Undefs.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (ObjFile *File : ObjectFiles)
|
|
|
|
for (Symbol *Sym : File->getSymbols())
|
|
|
|
if (Undefs.count(Sym))
|
|
|
|
error(toString(File) + ": undefined symbol: " + toString(*Sym));
|
|
|
|
|
|
|
|
for (Symbol *Sym : Undefs)
|
|
|
|
if (!Sym->getFile())
|
|
|
|
error("undefined symbol: " + toString(*Sym));
|
|
|
|
}
|
|
|
|
|
|
|
|
Symbol *SymbolTable::find(StringRef Name) {
|
2018-03-01 07:03:06 +08:00
|
|
|
return SymMap.lookup(CachedHashStringRef(Name));
|
2017-11-18 02:14:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::pair<Symbol *, bool> SymbolTable::insert(StringRef Name) {
|
2017-11-28 07:16:06 +08:00
|
|
|
Symbol *&Sym = SymMap[CachedHashStringRef(Name)];
|
2017-11-18 02:14:09 +08:00
|
|
|
if (Sym)
|
|
|
|
return {Sym, false};
|
2018-02-15 02:27:59 +08:00
|
|
|
Sym = reinterpret_cast<Symbol *>(make<SymbolUnion>());
|
2018-05-31 02:07:52 +08:00
|
|
|
Sym->IsUsedInRegularObj = false;
|
2017-12-07 09:51:24 +08:00
|
|
|
SymVector.emplace_back(Sym);
|
2017-11-18 02:14:09 +08:00
|
|
|
return {Sym, true};
|
|
|
|
}
|
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
static void reportTypeError(const Symbol *Existing, const InputFile *File,
|
2018-05-15 06:42:33 +08:00
|
|
|
llvm::wasm::WasmSymbolType Type) {
|
2018-02-28 08:09:22 +08:00
|
|
|
error("symbol type mismatch: " + toString(*Existing) + "\n>>> defined as " +
|
|
|
|
toString(Existing->getWasmType()) + " in " +
|
2018-05-15 06:42:33 +08:00
|
|
|
toString(Existing->getFile()) + "\n>>> defined as " + toString(Type) +
|
|
|
|
" in " + toString(File));
|
2018-02-28 08:09:22 +08:00
|
|
|
}
|
2018-02-23 13:08:53 +08:00
|
|
|
|
2018-06-22 23:13:10 +08:00
|
|
|
static void checkFunctionType(const Symbol *Existing, const InputFile *File,
|
2018-02-28 08:09:22 +08:00
|
|
|
const WasmSignature *NewSig) {
|
2018-05-15 07:01:16 +08:00
|
|
|
auto ExistingFunction = dyn_cast<FunctionSymbol>(Existing);
|
|
|
|
if (!ExistingFunction) {
|
2018-05-15 06:42:33 +08:00
|
|
|
reportTypeError(Existing, File, WASM_SYMBOL_TYPE_FUNCTION);
|
2017-11-30 09:40:08 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-15 07:01:16 +08:00
|
|
|
const WasmSignature *OldSig = ExistingFunction->getFunctionType();
|
|
|
|
if (OldSig && NewSig && *NewSig != *OldSig) {
|
2018-06-22 23:13:10 +08:00
|
|
|
warn("function signature mismatch: " + Existing->getName() +
|
|
|
|
"\n>>> defined as " + toString(*OldSig) + " in " +
|
|
|
|
toString(Existing->getFile()) + "\n>>> defined as " +
|
|
|
|
toString(*NewSig) + " in " + toString(File));
|
2018-02-28 08:09:22 +08:00
|
|
|
}
|
|
|
|
}
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
// Check the type of new symbol matches that of the symbol is replacing.
|
|
|
|
// For functions this can also involve verifying that the signatures match.
|
|
|
|
static void checkGlobalType(const Symbol *Existing, const InputFile *File,
|
|
|
|
const WasmGlobalType *NewType) {
|
|
|
|
if (!isa<GlobalSymbol>(Existing)) {
|
2018-05-15 06:42:33 +08:00
|
|
|
reportTypeError(Existing, File, WASM_SYMBOL_TYPE_GLOBAL);
|
2018-02-28 08:09:22 +08:00
|
|
|
return;
|
|
|
|
}
|
2018-02-23 13:08:53 +08:00
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
const WasmGlobalType *OldType = cast<GlobalSymbol>(Existing)->getGlobalType();
|
|
|
|
if (*NewType != *OldType) {
|
|
|
|
error("Global type mismatch: " + Existing->getName() + "\n>>> defined as " +
|
|
|
|
toString(*OldType) + " in " + toString(Existing->getFile()) +
|
|
|
|
"\n>>> defined as " + toString(*NewType) + " in " + toString(File));
|
2018-02-23 13:08:53 +08:00
|
|
|
}
|
2018-01-29 03:57:01 +08:00
|
|
|
}
|
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
static void checkDataType(const Symbol *Existing, const InputFile *File) {
|
|
|
|
if (!isa<DataSymbol>(Existing))
|
2018-05-15 06:42:33 +08:00
|
|
|
reportTypeError(Existing, File, WASM_SYMBOL_TYPE_DATA);
|
2018-02-28 08:09:22 +08:00
|
|
|
}
|
|
|
|
|
2018-02-15 02:27:59 +08:00
|
|
|
DefinedFunction *SymbolTable::addSyntheticFunction(StringRef Name,
|
2018-03-10 00:43:05 +08:00
|
|
|
uint32_t Flags,
|
|
|
|
InputFunction *Function) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "addSyntheticFunction: " << Name << "\n");
|
2018-03-01 06:51:51 +08:00
|
|
|
assert(!find(Name));
|
2018-03-10 00:43:05 +08:00
|
|
|
SyntheticFunctions.emplace_back(Function);
|
|
|
|
return replaceSymbol<DefinedFunction>(insert(Name).first, Name, Flags,
|
|
|
|
nullptr, Function);
|
2018-01-13 02:35:13 +08:00
|
|
|
}
|
|
|
|
|
2018-02-21 07:38:27 +08:00
|
|
|
DefinedData *SymbolTable::addSyntheticDataSymbol(StringRef Name,
|
|
|
|
uint32_t Flags) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "addSyntheticDataSymbol: " << Name << "\n");
|
2018-03-01 06:51:51 +08:00
|
|
|
assert(!find(Name));
|
|
|
|
return replaceSymbol<DefinedData>(insert(Name).first, Name, Flags);
|
2017-11-18 02:14:09 +08:00
|
|
|
}
|
|
|
|
|
2018-02-23 13:08:53 +08:00
|
|
|
DefinedGlobal *SymbolTable::addSyntheticGlobal(StringRef Name, uint32_t Flags,
|
|
|
|
InputGlobal *Global) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "addSyntheticGlobal: " << Name << " -> " << Global
|
|
|
|
<< "\n");
|
2018-03-01 06:51:51 +08:00
|
|
|
assert(!find(Name));
|
2018-03-10 00:43:05 +08:00
|
|
|
SyntheticGlobals.emplace_back(Global);
|
2018-03-01 06:51:51 +08:00
|
|
|
return replaceSymbol<DefinedGlobal>(insert(Name).first, Name, Flags, nullptr,
|
|
|
|
Global);
|
2018-02-23 13:08:53 +08:00
|
|
|
}
|
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
static bool shouldReplace(const Symbol *Existing, InputFile *NewFile,
|
|
|
|
uint32_t NewFlags) {
|
2018-02-21 05:08:47 +08:00
|
|
|
// If existing symbol is undefined, replace it.
|
2018-02-28 08:09:22 +08:00
|
|
|
if (!Existing->isDefined()) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "resolving existing undefined symbol: "
|
|
|
|
<< Existing->getName() << "\n");
|
2018-02-21 05:08:47 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now we have two defined symbols. If the new one is weak, we can ignore it.
|
|
|
|
if ((NewFlags & WASM_SYMBOL_BINDING_MASK) == WASM_SYMBOL_BINDING_WEAK) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "existing symbol takes precedence\n");
|
2018-02-21 05:08:47 +08:00
|
|
|
return false;
|
2017-11-18 02:14:09 +08:00
|
|
|
}
|
|
|
|
|
2018-02-21 05:08:47 +08:00
|
|
|
// If the existing symbol is weak, we should replace it.
|
2018-02-28 08:09:22 +08:00
|
|
|
if (Existing->isWeak()) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "replacing existing weak symbol\n");
|
2018-02-21 05:08:47 +08:00
|
|
|
return true;
|
|
|
|
}
|
2018-02-21 02:55:06 +08:00
|
|
|
|
2018-02-21 05:08:47 +08:00
|
|
|
// Neither symbol is week. They conflict.
|
2018-02-28 08:09:22 +08:00
|
|
|
error("duplicate symbol: " + toString(*Existing) + "\n>>> defined in " +
|
|
|
|
toString(Existing->getFile()) + "\n>>> defined in " +
|
|
|
|
toString(NewFile));
|
2018-02-21 05:08:47 +08:00
|
|
|
return true;
|
2018-02-21 02:55:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Symbol *SymbolTable::addDefinedFunction(StringRef Name, uint32_t Flags,
|
2018-02-28 08:09:22 +08:00
|
|
|
InputFile *File,
|
|
|
|
InputFunction *Function) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "addDefinedFunction: " << Name << "\n");
|
2018-02-21 02:55:06 +08:00
|
|
|
Symbol *S;
|
|
|
|
bool WasInserted;
|
|
|
|
std::tie(S, WasInserted) = insert(Name);
|
2018-02-28 08:09:22 +08:00
|
|
|
|
2018-05-31 02:07:52 +08:00
|
|
|
if (!File || File->kind() == InputFile::ObjectKind)
|
|
|
|
S->IsUsedInRegularObj = true;
|
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
if (WasInserted || S->isLazy()) {
|
|
|
|
replaceSymbol<DefinedFunction>(S, Name, Flags, File, Function);
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2018-05-31 02:07:52 +08:00
|
|
|
if (Function)
|
|
|
|
checkFunctionType(S, File, &Function->Signature);
|
2018-02-28 08:09:22 +08:00
|
|
|
|
|
|
|
if (shouldReplace(S, File, Flags))
|
|
|
|
replaceSymbol<DefinedFunction>(S, Name, Flags, File, Function);
|
2018-02-21 02:55:06 +08:00
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2018-02-21 07:38:27 +08:00
|
|
|
Symbol *SymbolTable::addDefinedData(StringRef Name, uint32_t Flags,
|
2018-02-28 08:09:22 +08:00
|
|
|
InputFile *File, InputSegment *Segment,
|
2018-02-23 13:08:53 +08:00
|
|
|
uint32_t Address, uint32_t Size) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "addDefinedData:" << Name << " addr:" << Address
|
|
|
|
<< "\n");
|
2018-02-21 02:55:06 +08:00
|
|
|
Symbol *S;
|
|
|
|
bool WasInserted;
|
|
|
|
std::tie(S, WasInserted) = insert(Name);
|
2018-02-28 08:09:22 +08:00
|
|
|
|
2018-05-31 02:07:52 +08:00
|
|
|
if (!File || File->kind() == InputFile::ObjectKind)
|
|
|
|
S->IsUsedInRegularObj = true;
|
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
if (WasInserted || S->isLazy()) {
|
|
|
|
replaceSymbol<DefinedData>(S, Name, Flags, File, Segment, Address, Size);
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkDataType(S, File);
|
|
|
|
|
|
|
|
if (shouldReplace(S, File, Flags))
|
|
|
|
replaceSymbol<DefinedData>(S, Name, Flags, File, Segment, Address, Size);
|
2017-11-18 02:14:09 +08:00
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2018-02-23 13:08:53 +08:00
|
|
|
Symbol *SymbolTable::addDefinedGlobal(StringRef Name, uint32_t Flags,
|
2018-02-28 08:09:22 +08:00
|
|
|
InputFile *File, InputGlobal *Global) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "addDefinedGlobal:" << Name << "\n");
|
2018-02-23 13:08:53 +08:00
|
|
|
Symbol *S;
|
|
|
|
bool WasInserted;
|
|
|
|
std::tie(S, WasInserted) = insert(Name);
|
2018-02-28 08:09:22 +08:00
|
|
|
|
2018-05-31 02:07:52 +08:00
|
|
|
if (!File || File->kind() == InputFile::ObjectKind)
|
|
|
|
S->IsUsedInRegularObj = true;
|
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
if (WasInserted || S->isLazy()) {
|
|
|
|
replaceSymbol<DefinedGlobal>(S, Name, Flags, File, Global);
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkGlobalType(S, File, &Global->getType());
|
|
|
|
|
|
|
|
if (shouldReplace(S, File, Flags))
|
|
|
|
replaceSymbol<DefinedGlobal>(S, Name, Flags, File, Global);
|
2018-02-23 13:08:53 +08:00
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
Symbol *SymbolTable::addUndefinedFunction(StringRef Name, uint32_t Flags,
|
|
|
|
InputFile *File,
|
|
|
|
const WasmSignature *Sig) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "addUndefinedFunction: " << Name << "\n");
|
2018-02-21 05:08:47 +08:00
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
Symbol *S;
|
|
|
|
bool WasInserted;
|
2018-01-10 08:52:20 +08:00
|
|
|
std::tie(S, WasInserted) = insert(Name);
|
2018-02-21 05:08:47 +08:00
|
|
|
|
2018-05-31 02:07:52 +08:00
|
|
|
if (!File || File->kind() == InputFile::ObjectKind)
|
|
|
|
S->IsUsedInRegularObj = true;
|
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
if (WasInserted)
|
|
|
|
replaceSymbol<UndefinedFunction>(S, Name, Flags, File, Sig);
|
|
|
|
else if (auto *Lazy = dyn_cast<LazySymbol>(S))
|
2018-03-01 06:51:51 +08:00
|
|
|
Lazy->fetch();
|
2018-02-28 08:09:22 +08:00
|
|
|
else if (S->isDefined())
|
|
|
|
checkFunctionType(S, File, Sig);
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
|
|
|
Symbol *SymbolTable::addUndefinedData(StringRef Name, uint32_t Flags,
|
|
|
|
InputFile *File) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "addUndefinedData: " << Name << "\n");
|
2018-02-21 05:08:47 +08:00
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
Symbol *S;
|
|
|
|
bool WasInserted;
|
|
|
|
std::tie(S, WasInserted) = insert(Name);
|
|
|
|
|
|
|
|
if (WasInserted)
|
|
|
|
replaceSymbol<UndefinedData>(S, Name, Flags, File);
|
|
|
|
else if (auto *Lazy = dyn_cast<LazySymbol>(S))
|
2018-03-01 06:51:51 +08:00
|
|
|
Lazy->fetch();
|
2018-02-28 08:09:22 +08:00
|
|
|
else if (S->isDefined())
|
|
|
|
checkDataType(S, File);
|
|
|
|
return S;
|
|
|
|
}
|
2018-02-21 05:08:47 +08:00
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
Symbol *SymbolTable::addUndefinedGlobal(StringRef Name, uint32_t Flags,
|
|
|
|
InputFile *File,
|
|
|
|
const WasmGlobalType *Type) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "addUndefinedGlobal: " << Name << "\n");
|
2018-02-23 13:08:53 +08:00
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
Symbol *S;
|
|
|
|
bool WasInserted;
|
|
|
|
std::tie(S, WasInserted) = insert(Name);
|
|
|
|
|
2018-05-31 02:07:52 +08:00
|
|
|
if (!File || File->kind() == InputFile::ObjectKind)
|
|
|
|
S->IsUsedInRegularObj = true;
|
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
if (WasInserted)
|
|
|
|
replaceSymbol<UndefinedGlobal>(S, Name, Flags, File, Type);
|
|
|
|
else if (auto *Lazy = dyn_cast<LazySymbol>(S))
|
2018-03-01 06:51:51 +08:00
|
|
|
Lazy->fetch();
|
2018-02-28 08:09:22 +08:00
|
|
|
else if (S->isDefined())
|
|
|
|
checkGlobalType(S, File, Type);
|
2017-11-18 02:14:09 +08:00
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2018-02-28 08:09:22 +08:00
|
|
|
void SymbolTable::addLazy(ArchiveFile *File, const Archive::Symbol *Sym) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "addLazy: " << Sym->getName() << "\n");
|
2017-11-18 02:14:09 +08:00
|
|
|
StringRef Name = Sym->getName();
|
2018-02-21 05:08:47 +08:00
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
Symbol *S;
|
|
|
|
bool WasInserted;
|
|
|
|
std::tie(S, WasInserted) = insert(Name);
|
2018-02-21 05:08:47 +08:00
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
if (WasInserted) {
|
2018-02-28 08:09:22 +08:00
|
|
|
replaceSymbol<LazySymbol>(S, Name, File, *Sym);
|
2018-02-21 05:08:47 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there is an existing undefined symbol, load a new one from the archive.
|
|
|
|
if (S->isUndefined()) {
|
2018-05-15 21:36:20 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "replacing existing undefined\n");
|
2018-02-28 08:09:22 +08:00
|
|
|
File->addMember(Sym);
|
2017-11-18 02:14:09 +08:00
|
|
|
}
|
|
|
|
}
|
2018-01-13 06:25:17 +08:00
|
|
|
|
2018-03-14 23:45:11 +08:00
|
|
|
bool SymbolTable::addComdat(StringRef Name) {
|
|
|
|
return Comdats.insert(CachedHashStringRef(Name)).second;
|
2018-01-13 06:25:17 +08:00
|
|
|
}
|