// They also might be exported if referenced by DSOs.
Script->declareSymbols();
- // Handle undefined symbols in DSOs.
- if (!Config->Shared)
- Symtab->scanShlibUndefined<ELFT>();
-
// Handle the -exclude-libs option.
if (Args.hasArg(OPT_exclude_libs))
excludeLibs<ELFT>(Args);
StringRef Name = CHECK(Sym.getName(this->StringTable), this);
if (Sym.isUndefined()) {
- this->Undefs.insert(Name);
+ Symbol *S = Symtab->addUndefined<ELFT>(Name, Sym.getBinding(),
+ Sym.st_other, Sym.getType(),
+ /*CanOmitFromDynSym=*/false, this);
+ S->ExportDynamic = true;
continue;
}
return Symbols;
}
- // Returns undefined symbols of a shared library.
- // It is a runtime error to call this function on files of other types.
- const llvm::DenseSet<StringRef> &getUndefinedSymbols() {
- assert(FileKind == SharedKind);
- return Undefs;
- }
-
// Filename of .a which contained this file. If this file was
// not in an archive file, it is the empty string. We use this
// string for creating error messages.
InputFile(Kind K, MemoryBufferRef M);
std::vector<InputSectionBase *> Sections;
std::vector<Symbol *> Symbols;
- llvm::DenseSet<StringRef> Undefs;
private:
const Kind FileKind;
Symbol *B = Symtab->find(Cmd->Name);
if (B && !B->isDefined())
return true;
- // It might also be referenced by a DSO.
- for (InputFile *F : SharedFiles)
- if (F->getUndefinedSymbols().count(Cmd->Name))
- return true;
return false;
}
}
}
-// This function takes care of the case in which shared libraries depend on
-// the user program (not the other way, which is usual). Shared libraries
-// may have undefined symbols, expecting that the user program provides
-// the definitions for them. An example is BSD's __progname symbol.
-// We need to put such symbols to the main program's .dynsym so that
-// shared libraries can find them.
-// Except this, we ignore undefined symbols in DSOs.
-template <class ELFT> void SymbolTable::scanShlibUndefined() {
- for (InputFile *F : SharedFiles) {
- for (StringRef U : F->getUndefinedSymbols()) {
- Symbol *Sym = find(U);
- if (!Sym)
- continue;
- if (auto *L = dyn_cast<Lazy>(Sym))
- if (InputFile *File = L->fetch())
- addFile<ELFT>(File);
-
- if (Sym->isDefined())
- Sym->ExportDynamic = true;
- }
- }
-}
-
// Initialize DemangledSyms with a map from demangled symbols to symbol
// objects. Used to handle "extern C++" directive in version scripts.
//
template void SymbolTable::fetchIfLazy<ELF32BE>(StringRef);
template void SymbolTable::fetchIfLazy<ELF64LE>(StringRef);
template void SymbolTable::fetchIfLazy<ELF64BE>(StringRef);
-
-template void SymbolTable::scanShlibUndefined<ELF32LE>();
-template void SymbolTable::scanShlibUndefined<ELF32BE>();
-template void SymbolTable::scanShlibUndefined<ELF64LE>();
-template void SymbolTable::scanShlibUndefined<ELF64BE>();
InputFile *File);
template <class ELFT> void fetchIfLazy(StringRef Name);
- template <class ELFT> void scanShlibUndefined();
void scanVersionScript();
Symbol *find(StringRef Name);
# RUN: ld.lld -y foo -y bar %t %t1.so %t2.so -o %t3 | \
# RUN: FileCheck -check-prefix=SHLIBRBAR %s
-# SHLIBRBAR-NOT: trace-symbols.s.tmp1.so: reference to bar
+# SHLIBRBAR: trace-symbols.s.tmp1.so: reference to bar
# RUN: ld.lld -y foo -y bar %t -u bar --start-lib %t1 %t2 --end-lib -o %t3 | \
# RUN: FileCheck -check-prefix=STARTLIB %s