[lld] r263133 - [ELF] - Do not call doInitSymbols for all ELFTs
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 10 09:38:49 PST 2016
Author: grimar
Date: Thu Mar 10 11:38:49 2016
New Revision: 263133
URL: http://llvm.org/viewvc/llvm-project?rev=263133&view=rev
Log:
[ELF] - Do not call doInitSymbols for all ELFTs
It looks a bit wierd that we have to initialize symbols for all ELFT
types when we use only one ELFT for link. We can only init those
that we need. Patch fixes it.
Differential revision: http://reviews.llvm.org/D18047
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Symbols.cpp
lld/trunk/ELF/Symbols.h
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=263133&r1=263132&r2=263133&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Mar 10 11:38:49 2016
@@ -168,8 +168,6 @@ static bool hasZOption(opt::InputArgList
}
void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
- initSymbols();
-
opt::InputArgList Args = parseArgs(&Alloc, ArgsArr.slice(1));
if (Args.hasArg(OPT_help)) {
printHelp(ArgsArr[0]);
@@ -317,6 +315,7 @@ void LinkerDriver::createFiles(opt::Inpu
}
template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
+ initSymbols<ELFT>();
// For LTO
InitializeAllTargets();
InitializeAllTargetMCs();
Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=263133&r1=263132&r2=263133&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Thu Mar 10 11:38:49 2016
@@ -209,7 +209,7 @@ std::unique_ptr<InputFile> Lazy::getMemb
return createObjectFile(MBRef, File->getName());
}
-template <class ELFT> static void doInitSymbols() {
+template <class ELFT> void elf::initSymbols() {
ElfSym<ELFT>::Etext.setBinding(STB_GLOBAL);
ElfSym<ELFT>::Edata.setBinding(STB_GLOBAL);
ElfSym<ELFT>::End.setBinding(STB_GLOBAL);
@@ -217,13 +217,6 @@ template <class ELFT> static void doInit
ElfSym<ELFT>::Ignored.setVisibility(STV_HIDDEN);
}
-void elf::initSymbols() {
- doInitSymbols<ELF32LE>();
- doInitSymbols<ELF32BE>();
- doInitSymbols<ELF64LE>();
- doInitSymbols<ELF64BE>();
-}
-
// Returns the demangled C++ symbol name for Name.
std::string elf::demangle(StringRef Name) {
#if !defined(HAVE_CXXABI_H)
@@ -289,3 +282,8 @@ template class elf::DefinedSynthetic<ELF
template class elf::DefinedSynthetic<ELF32BE>;
template class elf::DefinedSynthetic<ELF64LE>;
template class elf::DefinedSynthetic<ELF64BE>;
+
+template void elf::initSymbols<ELF32LE>();
+template void elf::initSymbols<ELF32BE>();
+template void elf::initSymbols<ELF64LE>();
+template void elf::initSymbols<ELF64BE>();
Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=263133&r1=263132&r2=263133&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Thu Mar 10 11:38:49 2016
@@ -41,8 +41,7 @@ template <class ELFT> class OutputSectio
template <class ELFT> class SharedFile;
// Initializes global objects defined in this file.
-// Called at the beginning of main().
-void initSymbols();
+template <class ELFT> void initSymbols();
// Returns a demangled C++ symbol name. If Name is not a mangled
// name or the system does not provide __cxa_demangle function,
More information about the llvm-commits
mailing list