}
// 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>();
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() {
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>;
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:
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
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);