[lld] r248559 - [ELF2] Use static non-member function when it suffices.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 20:56:12 PDT 2015
Author: davide
Date: Thu Sep 24 22:56:11 2015
New Revision: 248559
URL: http://llvm.org/viewvc/llvm-project?rev=248559&view=rev
Log:
[ELF2] Use static non-member function when it suffices.
Pointed out by Rui Ueyama.
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=248559&r1=248558&r2=248559&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Thu Sep 24 22:56:11 2015
@@ -272,15 +272,6 @@ bool lld::elf2::includeInSymtab(const Sy
return true;
}
-template <class ELFT>
-bool SymbolTableSection<ELFT>::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;
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=248559&r1=248558&r2=248559&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Thu Sep 24 22:56:11 2015
@@ -15,6 +15,8 @@
#include "llvm/MC/StringTableBuilder.h"
#include "llvm/Object/ELF.h"
+#include "Config.h"
+
#include <type_traits>
namespace lld {
@@ -41,6 +43,14 @@ getLocalSymVA(const typename llvm::objec
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 @@ public:
++NumLocals;
}
- bool shouldKeepInSymtab(StringRef Name);
-
StringTableSection<ELFT::Is64Bits> &getStrTabSec() const { return StrTabSec; }
unsigned getNumSymbols() const { return NumVisible + 1; }
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=248559&r1=248558&r2=248559&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Sep 24 22:56:11 2015
@@ -314,7 +314,7 @@ template <class ELFT> void Writer<ELFT>:
Elf_Sym_Range Syms = File.getLocalSymbols();
for (const Elf_Sym &Sym : Syms) {
ErrorOr<StringRef> SymName = Sym.getName(File.getStringTable());
- if (SymName && SymTabSec.shouldKeepInSymtab(*SymName))
+ if (SymName && shouldKeepInSymtab(*SymName))
SymTabSec.addSymbol(*SymName, true);
}
}
More information about the llvm-commits
mailing list