[lld] r237886 - [ELF] Move start/end atom method assignment to OutputELFWriter. NFC

Denis Protivensky dprotivensky at accesssoftek.com
Thu May 21 03:11:27 PDT 2015


Author: denis-protivensky
Date: Thu May 21 05:11:27 2015
New Revision: 237886

URL: http://llvm.org/viewvc/llvm-project?rev=237886&view=rev
Log:
[ELF] Move start/end atom method assignment to OutputELFWriter. NFC

Modified:
    lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h
    lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.cpp
    lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h

Modified: lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h?rev=237886&r1=237885&r2=237886&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ExecutableWriter.h Thu May 21 05:11:27 2015
@@ -26,7 +26,6 @@ public:
       : OutputELFWriter<ELFT>(ctx, layout) {}
 
 protected:
-  void updateScopeAtomValues(StringRef sym, StringRef sec);
   void buildDynamicSymbolTable(const File &file) override;
   void createImplicitFiles(std::vector<std::unique_ptr<File>> &) override;
   void finalizeDefaultAtomValues() override;
@@ -45,25 +44,6 @@ private:
 //===----------------------------------------------------------------------===//
 //  ExecutableWriter
 //===----------------------------------------------------------------------===//
-template <class ELFT>
-void ExecutableWriter<ELFT>::updateScopeAtomValues(StringRef sym,
-                                                   StringRef sec) {
-  std::string start = ("__" + sym + "_start").str();
-  std::string end = ("__" + sym + "_end").str();
-  AtomLayout *s = this->_layout.findAbsoluteAtom(start);
-  AtomLayout *e = this->_layout.findAbsoluteAtom(end);
-  OutputSection<ELFT> *section = this->_layout.findOutputSection(sec);
-  if (!s || !e)
-    return;
-  if (section) {
-    s->_virtualAddr = section->virtualAddr();
-    e->_virtualAddr = section->virtualAddr() + section->memSize();
-  } else {
-    s->_virtualAddr = 0;
-    e->_virtualAddr = 0;
-  }
-}
-
 template<class ELFT>
 void ExecutableWriter<ELFT>::buildDynamicSymbolTable(const File &file) {
   for (auto sec : this->_layout.sections())
@@ -147,13 +127,13 @@ template <class ELFT> void ExecutableWri
   assert((bssStartAtom || bssEndAtom || underScoreEndAtom || endAtom) &&
          "Unable to find the absolute atoms that have been added by lld");
 
-  updateScopeAtomValues("preinit_array", ".preinit_array");
-  updateScopeAtomValues("init_array", ".init_array");
+  this->updateScopeAtomValues("preinit_array", ".preinit_array");
+  this->updateScopeAtomValues("init_array", ".init_array");
   if (this->_ctx.isRelaOutputFormat())
-    updateScopeAtomValues("rela_iplt", ".rela.plt");
+    this->updateScopeAtomValues("rela_iplt", ".rela.plt");
   else
-    updateScopeAtomValues("rel_iplt", ".rel.plt");
-  updateScopeAtomValues("fini_array", ".fini_array");
+    this->updateScopeAtomValues("rel_iplt", ".rel.plt");
+  this->updateScopeAtomValues("fini_array", ".fini_array");
 
   auto bssSection = this->_layout.findOutputSection(".bss");
 

Modified: lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.cpp?rev=237886&r1=237885&r2=237886&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.cpp Thu May 21 05:11:27 2015
@@ -447,6 +447,26 @@ std::error_code OutputELFWriter<ELFT>::w
   return writeOutput(file, path);
 }
 
+template <class ELFT>
+void OutputELFWriter<ELFT>::updateScopeAtomValues(StringRef sym,
+                                                  StringRef sec) {
+  std::string start = ("__" + sym + "_start").str();
+  std::string end = ("__" + sym + "_end").str();
+  AtomLayout *s = _layout.findAbsoluteAtom(start);
+  AtomLayout *e = _layout.findAbsoluteAtom(end);
+  OutputSection<ELFT> *section = _layout.findOutputSection(sec);
+  if (!s || !e)
+    return;
+
+  if (section) {
+    s->_virtualAddr = section->virtualAddr();
+    e->_virtualAddr = section->virtualAddr() + section->memSize();
+  } else {
+    s->_virtualAddr = 0;
+    e->_virtualAddr = 0;
+  }
+}
+
 template class OutputELFWriter<ELF32LE>;
 template class OutputELFWriter<ELF32BE>;
 template class OutputELFWriter<ELF64LE>;

Modified: lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h?rev=237886&r1=237885&r2=237886&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h Thu May 21 05:11:27 2015
@@ -115,6 +115,9 @@ protected:
   virtual void processUndefinedSymbol(StringRef symName,
                                       RuntimeFile<ELFT> &file) const {}
 
+  /// \brief Assign addresses to atoms marking section's start and end.
+  void updateScopeAtomValues(StringRef sym, StringRef sec);
+
   llvm::BumpPtrAllocator _alloc;
 
   ELFLinkingContext &_ctx;





More information about the llvm-commits mailing list