[lld] r209592 - [Mips] Factor out the code create Mips specific runtime file into

Simon Atanasyan simon at atanasyan.com
Sun May 25 02:04:58 PDT 2014


Author: atanasyan
Date: Sun May 25 04:04:57 2014
New Revision: 209592

URL: http://llvm.org/viewvc/llvm-project?rev=209592&view=rev
Log:
[Mips] Factor out the code create Mips specific runtime file into
the MipsELFWriters member function.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h?rev=209592&r1=209591&r2=209592&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h Sun May 25 04:04:57 2014
@@ -42,16 +42,7 @@ protected:
   LLD_UNIQUE_BUMP_PTR(DynamicSymbolTable<ELFT>) createDynamicSymbolTable();
 
 private:
-  void addDefaultAtoms() {
-    if (this->_context.isDynamic()) {
-      _mipsRuntimeFile->addAbsoluteAtom("_GLOBAL_OFFSET_TABLE_");
-      _mipsRuntimeFile->addAbsoluteAtom("_gp");
-      _mipsRuntimeFile->addAbsoluteAtom("_gp_disp");
-    }
-  }
-
   MipsELFWriter<ELFT> _writeHelper;
-  std::unique_ptr<MipsRuntimeFile<ELFT>> _mipsRuntimeFile;
   MipsLinkingContext &_mipsContext;
   MipsTargetLayout<Mips32ElELFType> &_mipsTargetLayout;
 };
@@ -61,16 +52,13 @@ MipsDynamicLibraryWriter<ELFT>::MipsDyna
     MipsLinkingContext &context, MipsTargetLayout<ELFT> &layout)
     : DynamicLibraryWriter<ELFT>(context, layout),
       _writeHelper(context, layout),
-      _mipsRuntimeFile(new MipsRuntimeFile<ELFT>(context)),
       _mipsContext(context), _mipsTargetLayout(layout) {}
 
 template <class ELFT>
 bool MipsDynamicLibraryWriter<ELFT>::createImplicitFiles(
     std::vector<std::unique_ptr<File>> &result) {
   DynamicLibraryWriter<ELFT>::createImplicitFiles(result);
-  // Add the default atoms as defined for mips
-  addDefaultAtoms();
-  result.push_back(std::move(_mipsRuntimeFile));
+  result.push_back(std::move(_writeHelper.createRuntimeFile()));
   return true;
 }
 

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h?rev=209592&r1=209591&r2=209592&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h Sun May 25 04:04:57 2014
@@ -66,6 +66,16 @@ public:
     return _targetLayout.getGOTSection().hasGlobalGOTEntry(a);
   }
 
+  std::unique_ptr<MipsRuntimeFile<ELFT>> createRuntimeFile() {
+    auto file = llvm::make_unique<MipsRuntimeFile<ELFT>>(_context);
+    if (_context.isDynamic()) {
+      file->addAbsoluteAtom("_GLOBAL_OFFSET_TABLE_");
+      file->addAbsoluteAtom("_gp");
+      file->addAbsoluteAtom("_gp_disp");
+    }
+    return file;
+  }
+
 private:
   MipsLinkingContext &_context;
   MipsTargetLayout<ELFT> &_targetLayout;

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h?rev=209592&r1=209591&r2=209592&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h Sun May 25 04:04:57 2014
@@ -44,16 +44,7 @@ protected:
   LLD_UNIQUE_BUMP_PTR(DynamicSymbolTable<ELFT>) createDynamicSymbolTable();
 
 private:
-  void addDefaultAtoms() {
-    if (this->_context.isDynamic()) {
-      _mipsRuntimeFile->addAbsoluteAtom("_GLOBAL_OFFSET_TABLE_");
-      _mipsRuntimeFile->addAbsoluteAtom("_gp");
-      _mipsRuntimeFile->addAbsoluteAtom("_gp_disp");
-    }
-  }
-
   MipsELFWriter<ELFT> _writeHelper;
-  std::unique_ptr<MipsRuntimeFile<ELFT>> _mipsRuntimeFile;
   MipsLinkingContext &_mipsContext;
   MipsTargetLayout<Mips32ElELFType> &_mipsTargetLayout;
 };
@@ -61,9 +52,7 @@ private:
 template <class ELFT>
 MipsExecutableWriter<ELFT>::MipsExecutableWriter(MipsLinkingContext &context,
                                                  MipsTargetLayout<ELFT> &layout)
-    : ExecutableWriter<ELFT>(context, layout),
-      _writeHelper(context, layout),
-      _mipsRuntimeFile(new MipsRuntimeFile<ELFT>(context)),
+    : ExecutableWriter<ELFT>(context, layout), _writeHelper(context, layout),
       _mipsContext(context), _mipsTargetLayout(layout) {}
 
 template <class ELFT>
@@ -84,9 +73,7 @@ template <class ELFT>
 bool MipsExecutableWriter<ELFT>::createImplicitFiles(
     std::vector<std::unique_ptr<File>> &result) {
   ExecutableWriter<ELFT>::createImplicitFiles(result);
-  // Add the default atoms as defined for mips
-  addDefaultAtoms();
-  result.push_back(std::move(_mipsRuntimeFile));
+  result.push_back(std::move(_writeHelper.createRuntimeFile()));
   return true;
 }
 





More information about the llvm-commits mailing list