COFF: Support isa<> for Symbol::Body, whose type is std::atomic<SymbolBody *>.
llvm-svn: 241477
This commit is contained in:
parent
e2d75239d1
commit
183f53fd22
|
@ -220,7 +220,7 @@ StringRef LinkerDriver::findDefaultEntry() {
|
||||||
};
|
};
|
||||||
for (auto E : Entries) {
|
for (auto E : Entries) {
|
||||||
Symbol *Sym = Symtab.find(E[0]);
|
Symbol *Sym = Symtab.find(E[0]);
|
||||||
if (Sym && !isa<Undefined>(Sym->Body.load()))
|
if (Sym && !isa<Undefined>(Sym->Body))
|
||||||
return E[1];
|
return E[1];
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
@ -591,7 +591,7 @@ bool LinkerDriver::link(llvm::ArrayRef<const char *> ArgsArr) {
|
||||||
Symbol *Sym = Symtab.find(From);
|
Symbol *Sym = Symtab.find(From);
|
||||||
if (!Sym)
|
if (!Sym)
|
||||||
continue;
|
continue;
|
||||||
if (auto *U = dyn_cast<Undefined>(Sym->Body.load()))
|
if (auto *U = dyn_cast<Undefined>(Sym->Body))
|
||||||
if (!U->WeakAlias)
|
if (!U->WeakAlias)
|
||||||
U->WeakAlias = Symtab.addUndefined(To);
|
U->WeakAlias = Symtab.addUndefined(To);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ std::error_code SymbolTable::readArchives() {
|
||||||
// Add archive member files to ObjectQueue that should resolve
|
// Add archive member files to ObjectQueue that should resolve
|
||||||
// existing undefined symbols.
|
// existing undefined symbols.
|
||||||
for (Symbol *Sym : LazySyms)
|
for (Symbol *Sym : LazySyms)
|
||||||
if (auto EC = addMemberFile(cast<Lazy>(Sym->Body.load())))
|
if (auto EC = addMemberFile(cast<Lazy>(Sym->Body)))
|
||||||
return EC;
|
return EC;
|
||||||
return std::error_code();
|
return std::error_code();
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ bool SymbolTable::reportRemainingUndefines(bool Resolve) {
|
||||||
bool Ret = false;
|
bool Ret = false;
|
||||||
for (auto &I : Symtab) {
|
for (auto &I : Symtab) {
|
||||||
Symbol *Sym = I.second;
|
Symbol *Sym = I.second;
|
||||||
auto *Undef = dyn_cast<Undefined>(Sym->Body.load());
|
auto *Undef = dyn_cast<Undefined>(Sym->Body);
|
||||||
if (!Undef)
|
if (!Undef)
|
||||||
continue;
|
continue;
|
||||||
StringRef Name = Undef->getName();
|
StringRef Name = Undef->getName();
|
||||||
|
@ -140,10 +140,10 @@ bool SymbolTable::reportRemainingUndefines(bool Resolve) {
|
||||||
// This odd rule is for compatibility with MSVC linker.
|
// This odd rule is for compatibility with MSVC linker.
|
||||||
if (Name.startswith("__imp_")) {
|
if (Name.startswith("__imp_")) {
|
||||||
Symbol *Imp = find(Name.substr(strlen("__imp_")));
|
Symbol *Imp = find(Name.substr(strlen("__imp_")));
|
||||||
if (Imp && isa<Defined>(Imp->Body.load())) {
|
if (Imp && isa<Defined>(Imp->Body)) {
|
||||||
if (!Resolve)
|
if (!Resolve)
|
||||||
continue;
|
continue;
|
||||||
auto *D = cast<Defined>(Imp->Body.load());
|
auto *D = cast<Defined>(Imp->Body);
|
||||||
auto *S = new (Alloc) DefinedLocalImport(Name, D);
|
auto *S = new (Alloc) DefinedLocalImport(Name, D);
|
||||||
LocalImportChunks.push_back(S->getChunk());
|
LocalImportChunks.push_back(S->getChunk());
|
||||||
Sym->Body = S;
|
Sym->Body = S;
|
||||||
|
@ -332,11 +332,11 @@ std::error_code SymbolTable::addCombinedLTOObject() {
|
||||||
StringRef Name = Body->getName();
|
StringRef Name = Body->getName();
|
||||||
Symbol *Sym = insert(Body);
|
Symbol *Sym = insert(Body);
|
||||||
|
|
||||||
if (isa<DefinedBitcode>(Sym->Body.load())) {
|
if (isa<DefinedBitcode>(Sym->Body)) {
|
||||||
Sym->Body = Body;
|
Sym->Body = Body;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (auto *L = dyn_cast<Lazy>(Sym->Body.load())) {
|
if (auto *L = dyn_cast<Lazy>(Sym->Body)) {
|
||||||
// We may see new references to runtime library symbols such as __chkstk
|
// We may see new references to runtime library symbols such as __chkstk
|
||||||
// here. These symbols must be wholly defined in non-bitcode files.
|
// here. These symbols must be wholly defined in non-bitcode files.
|
||||||
if (auto EC = addMemberFile(L))
|
if (auto EC = addMemberFile(L))
|
||||||
|
|
|
@ -359,4 +359,13 @@ private:
|
||||||
} // namespace coff
|
} // namespace coff
|
||||||
} // namespace lld
|
} // namespace lld
|
||||||
|
|
||||||
|
// Support isa<>, cast<> and dyn_cast<> for Symbol::Body.
|
||||||
|
namespace llvm {
|
||||||
|
template <typename T>
|
||||||
|
struct simplify_type<std::atomic<T *>> {
|
||||||
|
typedef T *SimpleType;
|
||||||
|
static T *getSimplifiedValue(std::atomic<T *> &A) { return A.load(); }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -244,7 +244,7 @@ void Writer::createImportTables() {
|
||||||
}
|
}
|
||||||
if (!DelayIdata.empty()) {
|
if (!DelayIdata.empty()) {
|
||||||
Symbol *Sym = Symtab->find("__delayLoadHelper2");
|
Symbol *Sym = Symtab->find("__delayLoadHelper2");
|
||||||
Defined *Helper = cast<Defined>(Sym->Body.load());
|
Defined *Helper = cast<Defined>(Sym->Body);
|
||||||
DelayIdata.create(Helper);
|
DelayIdata.create(Helper);
|
||||||
OutputSection *Sec = createSection(".didat");
|
OutputSection *Sec = createSection(".didat");
|
||||||
for (Chunk *C : DelayIdata.getChunks())
|
for (Chunk *C : DelayIdata.getChunks())
|
||||||
|
@ -416,7 +416,7 @@ void Writer::writeHeader() {
|
||||||
Dir[EXCEPTION_TABLE].Size = Sec->getVirtualSize();
|
Dir[EXCEPTION_TABLE].Size = Sec->getVirtualSize();
|
||||||
}
|
}
|
||||||
if (Symbol *Sym = Symtab->find("_tls_used")) {
|
if (Symbol *Sym = Symtab->find("_tls_used")) {
|
||||||
if (Defined *B = dyn_cast<Defined>(Sym->Body.load())) {
|
if (Defined *B = dyn_cast<Defined>(Sym->Body)) {
|
||||||
Dir[TLS_TABLE].RelativeVirtualAddress = B->getRVA();
|
Dir[TLS_TABLE].RelativeVirtualAddress = B->getRVA();
|
||||||
Dir[TLS_TABLE].Size = 40;
|
Dir[TLS_TABLE].Size = 40;
|
||||||
}
|
}
|
||||||
|
@ -542,7 +542,7 @@ OutputSection *Writer::createSection(StringRef Name) {
|
||||||
// Dest is .reloc section. Add contents to that section.
|
// Dest is .reloc section. Add contents to that section.
|
||||||
void Writer::addBaserels(OutputSection *Dest) {
|
void Writer::addBaserels(OutputSection *Dest) {
|
||||||
std::vector<uint32_t> V;
|
std::vector<uint32_t> V;
|
||||||
Defined *ImageBase = cast<Defined>(Symtab->find("__ImageBase")->Body.load());
|
Defined *ImageBase = cast<Defined>(Symtab->find("__ImageBase")->Body);
|
||||||
for (OutputSection *Sec : OutputSections) {
|
for (OutputSection *Sec : OutputSections) {
|
||||||
if (Sec == Dest)
|
if (Sec == Dest)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue