void SymbolTable<ELFT>::addShared(SharedFile<ELFT> *F, StringRef Name, const Elf_Sym &Sym, const typename ELFT::Verdef *Verdef) { // DSO symbols do not affect visibility in the output, so we pass STV_DEFAULT // as the visibility, which will leave the visibility in the symbol table // unchanged. Symbol *S; bool WasInserted; std::tie(S, WasInserted) = insert(Name, Sym.getType(), STV_DEFAULT, /*CanOmitFromDynSym*/ true, /*IsUsedInRegularObj*/ false, F); // Make sure we preempt DSO symbols with default visibility. if (Sym.getVisibility() == STV_DEFAULT) S->ExportDynamic = true; if (WasInserted || isa<Undefined>(S->body())) { replaceBody<SharedSymbol<ELFT>>(S, F, Name, Sym, Verdef); if (!S->isWeak()) F->IsUsed = true; } }
void SymbolTable<ELFT>::addShared(SharedFile<ELFT> *F, StringRef Name, const Elf_Sym &Sym, const typename ELFT::Verdef *Verdef) { // DSO symbols do not affect visibility in the output, so we pass STV_DEFAULT // as the visibility, which will leave the visibility in the symbol table // unchanged. Symbol *S; bool WasInserted; std::tie(S, WasInserted) = insert(Name, Sym.getType(), STV_DEFAULT, /*CanOmitFromDynSym*/ true, F); // Make sure we preempt DSO symbols with default visibility. if (Sym.getVisibility() == STV_DEFAULT) { S->ExportDynamic = true; // Exporting preempting symbols takes precedence over linker scripts. if (S->VersionId == VER_NDX_LOCAL) S->VersionId = VER_NDX_GLOBAL; } if (WasInserted || isa<Undefined<ELFT>>(S->body())) { replaceBody<SharedSymbol<ELFT>>(S, F, Name, Sym, Verdef); if (!S->isWeak()) F->IsUsed = true; } }
UndefinedElf<ELFT>::UndefinedElf(const Elf_Sym &Sym) : SymbolBody(SymbolBody::UndefinedElfKind, Sym.st_name, Sym.st_other, Sym.getType()), Size(Sym.st_size) { assert(Sym.getBinding() == STB_LOCAL); }
UndefinedElf<ELFT>::UndefinedElf(StringRef N, const Elf_Sym &Sym) : SymbolBody(SymbolBody::UndefinedElfKind, N, Sym.getBinding(), Sym.st_other, Sym.getType()), Size(Sym.st_size) {}