[lld] r263214 - [ELF] - Move initSymbols() to Driver.cpp. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 09:27:03 PST 2016


I now remember what I planned when I wrote the original initSymbols and
doInitSymbols. I was thinking that there is a chance that we will need more
initializers for statically-allocated PODs, and I was planning to define
init<filename> function in each file, each of which is responsible to
initialize all stuff in the file. So initSymbols was not only for
initializing symbols but for everything in Symbols.cpp.

It turned out that we only had one initializer function, so inlining it
into Driver.cpp makes sense now, but when we need more initializers, we may
want to roll this back.

On Fri, Mar 11, 2016 at 6:29 AM, Rafael EspĂ­ndola <
llvm-commits at lists.llvm.org> wrote:

> Thanks!
>
> On 11 March 2016 at 05:07, George Rimar via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> > Author: grimar
> > Date: Fri Mar 11 04:07:18 2016
> > New Revision: 263214
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=263214&view=rev
> > Log:
> > [ELF] - Move initSymbols() to Driver.cpp. NFC.
> >
> > That is followup for http://reviews.llvm.org/D18047
> > patch. initSymbols() moved to Driver.cpp and made static.
> >
> > 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=263214&r1=263213&r2=263214&view=diff
> >
> ==============================================================================
> > --- lld/trunk/ELF/Driver.cpp (original)
> > +++ lld/trunk/ELF/Driver.cpp Fri Mar 11 04:07:18 2016
> > @@ -315,6 +315,14 @@ void LinkerDriver::createFiles(opt::Inpu
> >      error("No input files");
> >  }
> >
> > +template <class ELFT> static void initSymbols() {
> > +  ElfSym<ELFT>::Etext.setBinding(STB_GLOBAL);
> > +  ElfSym<ELFT>::Edata.setBinding(STB_GLOBAL);
> > +  ElfSym<ELFT>::End.setBinding(STB_GLOBAL);
> > +  ElfSym<ELFT>::Ignored.setBinding(STB_WEAK);
> > +  ElfSym<ELFT>::Ignored.setVisibility(STV_HIDDEN);
> > +}
> > +
> >  template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
> >    initSymbols<ELFT>();
> >    // For LTO
> >
> > Modified: lld/trunk/ELF/Symbols.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=263214&r1=263213&r2=263214&view=diff
> >
> ==============================================================================
> > --- lld/trunk/ELF/Symbols.cpp (original)
> > +++ lld/trunk/ELF/Symbols.cpp Fri Mar 11 04:07:18 2016
> > @@ -203,14 +203,6 @@ std::unique_ptr<InputFile> Lazy::getMemb
> >    return createObjectFile(MBRef, File->getName());
> >  }
> >
> > -template <class ELFT> void elf::initSymbols() {
> > -  ElfSym<ELFT>::Etext.setBinding(STB_GLOBAL);
> > -  ElfSym<ELFT>::Edata.setBinding(STB_GLOBAL);
> > -  ElfSym<ELFT>::End.setBinding(STB_GLOBAL);
> > -  ElfSym<ELFT>::Ignored.setBinding(STB_WEAK);
> > -  ElfSym<ELFT>::Ignored.setVisibility(STV_HIDDEN);
> > -}
> > -
> >  // Returns the demangled C++ symbol name for Name.
> >  std::string elf::demangle(StringRef Name) {
> >  #if !defined(HAVE_CXXABI_H)
> > @@ -276,8 +268,3 @@ 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=263214&r1=263213&r2=263214&view=diff
> >
> ==============================================================================
> > --- lld/trunk/ELF/Symbols.h (original)
> > +++ lld/trunk/ELF/Symbols.h Fri Mar 11 04:07:18 2016
> > @@ -40,9 +40,6 @@ template <class ELFT> class OutputSectio
> >  template <class ELFT> class OutputSectionBase;
> >  template <class ELFT> class SharedFile;
> >
> > -// Initializes global objects defined in this file.
> > -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,
> >  // it returns the unmodified string.
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160311/2da9008f/attachment.html>


More information about the llvm-commits mailing list