[lld] r286234 - Delete the CommonSection class.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 8 06:42:34 PST 2016
Author: rafael
Date: Tue Nov 8 08:42:34 2016
New Revision: 286234
URL: http://llvm.org/viewvc/llvm-project?rev=286234&view=rev
Log:
Delete the CommonSection class.
With the current infrastructure it can be just an ordinary
InputSection like the real .bss sections.
Modified:
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/ELF/SyntheticSections.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=286234&r1=286233&r2=286234&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Tue Nov 8 08:42:34 2016
@@ -48,11 +48,10 @@ template <class ELFT> static std::vector
}
// 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>::writeBuildI
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>;
Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=286234&r1=286233&r2=286234&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Tue Nov 8 08:42:34 2016
@@ -15,12 +15,6 @@
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
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=286234&r1=286233&r2=286234&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Nov 8 08:42:34 2016
@@ -287,7 +287,7 @@ template <class ELFT> void Writer<ELFT>:
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);
More information about the llvm-commits
mailing list