[lld] r222313 - [ELF] Handle ctors/dtors sections

Shankar Easwaran shankare at codeaurora.org
Tue Nov 18 19:51:50 PST 2014


Author: shankare
Date: Tue Nov 18 21:51:50 2014
New Revision: 222313

URL: http://llvm.org/viewvc/llvm-project?rev=222313&view=rev
Log:
[ELF] Handle ctors/dtors sections

Move functionality from MIPS target to DefaultLayout.

No change in functionality.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h

Modified: lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h?rev=222313&r1=222312&r2=222313&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h Tue Nov 18 21:51:50 2014
@@ -438,6 +438,8 @@ DefaultLayout<ELFT>::getOutputSectionNam
                                           StringRef /* path */) const {
   return llvm::StringSwitch<StringRef>(inputSectionName)
       .StartsWith(".text", ".text")
+      .StartsWith(".ctors", ".ctors")
+      .StartsWith(".dtors", ".dtors")
       .StartsWith(".rodata", ".rodata")
       .StartsWith(".gcc_except_table", ".gcc_except_table")
       .StartsWith(".data.rel.ro", ".data.rel.ro")
@@ -471,6 +473,8 @@ Layout::SegmentType DefaultLayout<ELFT>:
   case ORDER_FINI:
   case ORDER_RODATA:
   case ORDER_EH_FRAME:
+  case ORDER_CTORS:
+  case ORDER_DTORS:
     return llvm::ELF::PT_LOAD;
 
   case ORDER_RO_NOTE:
@@ -480,10 +484,6 @@ Layout::SegmentType DefaultLayout<ELFT>:
   case ORDER_DYNAMIC:
     return llvm::ELF::PT_DYNAMIC;
 
-  case ORDER_CTORS:
-  case ORDER_DTORS:
-    return llvm::ELF::PT_GNU_RELRO;
-
   case ORDER_EH_FRAMEHDR:
     return llvm::ELF::PT_GNU_EH_FRAME;
 

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h?rev=222313&r1=222312&r2=222313&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h Tue Nov 18 21:51:50 2014
@@ -45,23 +45,6 @@ public:
                                                  order);
   }
 
-  StringRef getInputSectionName(const DefinedAtom *da) const override {
-    return llvm::StringSwitch<StringRef>(da->customSectionName())
-        .StartsWith(".ctors", ".ctors")
-        .StartsWith(".dtors", ".dtors")
-        .Default(TargetLayout<ELFType>::getInputSectionName(da));
-  }
-
-  Layout::SegmentType getSegmentType(Section<ELFType> *section) const override {
-    switch (section->order()) {
-    case DefaultLayout<ELFType>::ORDER_CTORS:
-    case DefaultLayout<ELFType>::ORDER_DTORS:
-      return llvm::ELF::PT_LOAD;
-    default:
-      return TargetLayout<ELFType>::getSegmentType(section);
-    }
-  }
-
   /// \brief GP offset relative to .got section.
   uint64_t getGPOffset() const { return 0x7FF0; }
 





More information about the llvm-commits mailing list