From 682a5bc2c13143522a68ef98074fbef58a792435 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 8 Nov 2016 14:42:34 +0000 Subject: [PATCH] Delete the CommonSection class. With the current infrastructure it can be just an ordinary InputSection like the real .bss sections. llvm-svn: 286234 --- lld/ELF/SyntheticSections.cpp | 22 +++++++++++----------- lld/ELF/SyntheticSections.h | 12 ++++-------- lld/ELF/Writer.cpp | 2 +- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 34d2bb8..f1d6331 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -48,11 +48,10 @@ template static std::vector getCommonSymbols() { } // Find all common symbols and allocate space for them. -template -CommonSection::CommonSection() - : InputSection(SHF_ALLOC | SHF_WRITE, SHT_NOBITS, 1, - ArrayRef(), "COMMON") { - this->Live = true; +template InputSection *elf::createCommonSection() { + auto *Ret = make>(SHF_ALLOC | SHF_WRITE, SHT_NOBITS, 1, + ArrayRef(), "COMMON"); + Ret->Live = true; // Sort the common symbols by alignment as an heuristic to pack them better. std::vector Syms = getCommonSymbols(); @@ -72,8 +71,9 @@ CommonSection::CommonSection() Sym->Offset = Size; Size += Sym->Size; } - this->Alignment = Alignment; - this->Data = makeArrayRef(nullptr, Size); + Ret->Alignment = Alignment; + Ret->Data = makeArrayRef(nullptr, Size); + return Ret; } static ArrayRef createInterp() { @@ -188,10 +188,10 @@ void BuildIdHexstring::writeBuildId(MutableArrayRef Buf) { Config->BuildIdVector.size()); } -template class elf::CommonSection; -template class elf::CommonSection; -template class elf::CommonSection; -template class elf::CommonSection; +template InputSection *elf::createCommonSection(); +template InputSection *elf::createCommonSection(); +template InputSection *elf::createCommonSection(); +template InputSection *elf::createCommonSection(); template class elf::InterpSection; template class elf::InterpSection; diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h index 86763a3..4e62f30 100644 --- a/lld/ELF/SyntheticSections.h +++ b/lld/ELF/SyntheticSections.h @@ -15,12 +15,6 @@ namespace lld { namespace elf { -// This class represents a BSS section containing all common symbols. -template class CommonSection final : public InputSection { -public: - CommonSection(); -}; - // .interp section. template class InterpSection final : public InputSection { public: @@ -79,15 +73,17 @@ public: void writeBuildId(llvm::MutableArrayRef) override; }; +template InputSection *createCommonSection(); + // Linker generated sections which can be used as inputs. template struct In { static BuildIdSection *BuildId; - static CommonSection *Common; + static InputSection *Common; static InterpSection *Interp; }; template BuildIdSection *In::BuildId; -template CommonSection *In::Common; +template InputSection *In::Common; template InterpSection *In::Interp; } // namespace elf diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 7f244d9..5084b74 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -287,7 +287,7 @@ template void Writer::createSyntheticSections() { if (In::BuildId) Symtab::X->Sections.push_back(In::BuildId); - CommonSection *Common = make>(); + InputSection *Common = createCommonSection(); if (!Common->Data.empty()) { In::Common = Common; Symtab::X->Sections.push_back(Common); -- 2.7.4