Index: ELF/OutputSections.h =================================================================== --- ELF/OutputSections.h +++ ELF/OutputSections.h @@ -15,6 +15,8 @@ #include "llvm/MC/StringTableBuilder.h" #include "llvm/Object/ELF.h" +#include "Config.h" + #include namespace lld { @@ -41,6 +43,14 @@ bool includeInSymtab(const SymbolBody &B); bool includeInDynamicSymtab(const SymbolBody &B); +static bool shouldKeepInSymtab(StringRef SymName) { + if (Config->DiscardNone) + return true; + + // ELF defines dynamic locals as symbols which name starts with ".L". + return !(Config->DiscardLocals && SymName.startswith(".L")); +} + // This represents a section in an output file. // Different sub classes represent different types of sections. Some contain // input sections, others are created by the linker. @@ -186,8 +196,6 @@ ++NumLocals; } - bool shouldKeepInSymtab(StringRef Name); - StringTableSection &getStrTabSec() const { return StrTabSec; } unsigned getNumSymbols() const { return NumVisible + 1; } Index: ELF/OutputSections.cpp =================================================================== --- ELF/OutputSections.cpp +++ ELF/OutputSections.cpp @@ -272,15 +272,6 @@ return true; } -template -bool SymbolTableSection::shouldKeepInSymtab(StringRef SymName) { - if (Config->DiscardNone) - return true; - - // ELF defines dynamic locals as symbols which name starts with ".L". - return !(Config->DiscardLocals && SymName.startswith(".L")); -} - bool lld::elf2::includeInDynamicSymtab(const SymbolBody &B) { if (Config->ExportDynamic || Config->Shared) return true; Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -336,7 +336,7 @@ Elf_Sym_Range Syms = File.getLocalSymbols(); for (const Elf_Sym &Sym : Syms) { ErrorOr SymName = Sym.getName(File.getStringTable()); - if (SymName && SymTabSec.shouldKeepInSymtab(*SymName)) + if (SymName && shouldKeepInSymtab(*SymName)) SymTabSec.addSymbol(*SymName, true); } }