Delete the CommonSection class.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 8 Nov 2016 14:42:34 +0000 (14:42 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 8 Nov 2016 14:42:34 +0000 (14:42 +0000)
With the current infrastructure it can be just an ordinary
InputSection like the real .bss sections.

llvm-svn: 286234

lld/ELF/SyntheticSections.cpp
lld/ELF/SyntheticSections.h
lld/ELF/Writer.cpp

index 34d2bb8840236b5bc617960d6787dec8ca4e4110..f1d6331531fea4d2d65b580233cf993bd607ed2e 100644 (file)
@@ -48,11 +48,10 @@ template <class ELFT> static std::vector<DefinedCommon *> getCommonSymbols() {
 }
 
 // Find all common symbols and allocate space for them.
-template <class ELFT>
-CommonSection<ELFT>::CommonSection()
-    : InputSection<ELFT>(SHF_ALLOC | SHF_WRITE, SHT_NOBITS, 1,
-                         ArrayRef<uint8_t>(), "COMMON") {
-  this->Live = true;
+template <class ELFT> InputSection<ELFT> *elf::createCommonSection() {
+  auto *Ret = make<InputSection<ELFT>>(SHF_ALLOC | SHF_WRITE, SHT_NOBITS, 1,
+                                       ArrayRef<uint8_t>(), "COMMON");
+  Ret->Live = true;
 
   // Sort the common symbols by alignment as an heuristic to pack them better.
   std::vector<DefinedCommon *> Syms = getCommonSymbols<ELFT>();
@@ -72,8 +71,9 @@ CommonSection<ELFT>::CommonSection()
     Sym->Offset = Size;
     Size += Sym->Size;
   }
-  this->Alignment = Alignment;
-  this->Data = makeArrayRef<uint8_t>(nullptr, Size);
+  Ret->Alignment = Alignment;
+  Ret->Data = makeArrayRef<uint8_t>(nullptr, Size);
+  return Ret;
 }
 
 static ArrayRef<uint8_t> createInterp() {
@@ -188,10 +188,10 @@ void BuildIdHexstring<ELFT>::writeBuildId(MutableArrayRef<uint8_t> Buf) {
          Config->BuildIdVector.size());
 }
 
-template class elf::CommonSection<ELF32LE>;
-template class elf::CommonSection<ELF32BE>;
-template class elf::CommonSection<ELF64LE>;
-template class elf::CommonSection<ELF64BE>;
+template InputSection<ELF32LE> *elf::createCommonSection();
+template InputSection<ELF32BE> *elf::createCommonSection();
+template InputSection<ELF64LE> *elf::createCommonSection();
+template InputSection<ELF64BE> *elf::createCommonSection();
 
 template class elf::InterpSection<ELF32LE>;
 template class elf::InterpSection<ELF32BE>;
index 86763a32529a92e1d7a059c295bfd521f022168a..4e62f30c56cf7d959344c061c96b88d4ce2cfdf0 100644 (file)
 namespace lld {
 namespace elf {
 
-// This class represents a BSS section containing all common symbols.
-template <class ELFT> class CommonSection final : public InputSection<ELFT> {
-public:
-  CommonSection();
-};
-
 // .interp section.
 template <class ELFT> class InterpSection final : public InputSection<ELFT> {
 public:
@@ -79,15 +73,17 @@ public:
   void writeBuildId(llvm::MutableArrayRef<uint8_t>) override;
 };
 
+template <class ELFT> InputSection<ELFT> *createCommonSection();
+
 // Linker generated sections which can be used as inputs.
 template <class ELFT> struct In {
   static BuildIdSection<ELFT> *BuildId;
-  static CommonSection<ELFT> *Common;
+  static InputSection<ELFT> *Common;
   static InterpSection<ELFT> *Interp;
 };
 
 template <class ELFT> BuildIdSection<ELFT> *In<ELFT>::BuildId;
-template <class ELFT> CommonSection<ELFT> *In<ELFT>::Common;
+template <class ELFT> InputSection<ELFT> *In<ELFT>::Common;
 template <class ELFT> InterpSection<ELFT> *In<ELFT>::Interp;
 
 } // namespace elf
index 7f244d925aac235b6024ff708f719931157db819..5084b749fbd2794508d26e8dbc9a642859bb2a2f 100644 (file)
@@ -287,7 +287,7 @@ template <class ELFT> void Writer<ELFT>::createSyntheticSections() {
   if (In<ELFT>::BuildId)
     Symtab<ELFT>::X->Sections.push_back(In<ELFT>::BuildId);
 
-  CommonSection<ELFT> *Common = make<CommonSection<ELFT>>();
+  InputSection<ELFT> *Common = createCommonSection<ELFT>();
   if (!Common->Data.empty()) {
     In<ELFT>::Common = Common;
     Symtab<ELFT>::X->Sections.push_back(Common);