Use OutputSectionBase in a few cases where we don't need a OutputSection.
NFC. This is just preparation for adding a new OutputSection dedicated to
SHF_MERGE input sections.
llvm-svn: 250419
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index 6fa065c..12811a8 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -18,6 +18,7 @@
template <class ELFT> class ObjectFile;
template <class ELFT> class OutputSection;
+template <bool Is64Bits> class OutputSectionBase;
// This corresponds to a section of an input file.
template <class ELFT> class InputSection {
@@ -54,7 +55,7 @@
// The offset from beginning of the output sections this section was assigned
// to. The writer sets a value.
uint64_t OutSecOff = 0;
- OutputSection<ELFT> *OutSec = nullptr;
+ OutputSectionBase<ELFT::Is64Bits> *OutSec = nullptr;
static InputSection<ELFT> Discarded;
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 5663429..19fc7ed 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -346,7 +346,7 @@
WriteVal(DT_SONAME, Out<ELFT>::DynStrTab->getFileOff(Config->SoName));
auto WriteArray = [&](int32_t T1, int32_t T2,
- const OutputSection<ELFT> *Sec) {
+ const OutputSectionBase<ELFT::Is64Bits> *Sec) {
if (!Sec)
return;
WritePtr(T1, Sec->getVA());
@@ -652,7 +652,7 @@
ESym->st_name = StrTabSec.getFileOff(Name);
- const OutputSection<ELFT> *OutSec = nullptr;
+ const OutputSectionBase<ELFT::Is64Bits> *OutSec = nullptr;
const InputSection<ELFT> *Section = nullptr;
switch (Body->kind()) {
diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h
index ba9c07b..2ba7be3 100644
--- a/lld/ELF/OutputSections.h
+++ b/lld/ELF/OutputSections.h
@@ -267,9 +267,9 @@
void finalize() override;
void writeTo(uint8_t *Buf) override;
- OutputSection<ELFT> *PreInitArraySec = nullptr;
- OutputSection<ELFT> *InitArraySec = nullptr;
- OutputSection<ELFT> *FiniArraySec = nullptr;
+ OutputSectionBase<ELFT::Is64Bits> *PreInitArraySec = nullptr;
+ OutputSectionBase<ELFT::Is64Bits> *InitArraySec = nullptr;
+ OutputSectionBase<ELFT::Is64Bits> *FiniArraySec = nullptr;
private:
SymbolTable<ELFT> &SymTab;
@@ -286,7 +286,7 @@
static HashTableSection<ELFT> *HashTab;
static InterpSection<ELFT::Is64Bits> *Interp;
static OutputSection<ELFT> *Bss;
- static OutputSection<ELFT> *Opd;
+ static OutputSectionBase<ELFT::Is64Bits> *Opd;
static uint8_t *OpdBuf;
static PltSection<ELFT> *Plt;
static RelocationSection<ELFT> *RelaDyn;
@@ -301,7 +301,7 @@
template <class ELFT> HashTableSection<ELFT> *Out<ELFT>::HashTab;
template <class ELFT> InterpSection<ELFT::Is64Bits> *Out<ELFT>::Interp;
template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Bss;
-template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Opd;
+template <class ELFT> OutputSectionBase<ELFT::Is64Bits> *Out<ELFT>::Opd;
template <class ELFT> uint8_t *Out<ELFT>::OpdBuf;
template <class ELFT> PltSection<ELFT> *Out<ELFT>::Plt;
template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaDyn;
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index fa3e63f..33340d6 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -71,9 +71,9 @@
}
template <class ELFT>
-void SymbolTable<ELFT>::addSyntheticSym(StringRef Name,
- OutputSection<ELFT> &Section,
- typename ELFFile<ELFT>::uintX_t Value) {
+void SymbolTable<ELFT>::addSyntheticSym(
+ StringRef Name, OutputSectionBase<ELFT::Is64Bits> &Section,
+ typename ELFFile<ELFT>::uintX_t Value) {
typedef typename DefinedSynthetic<ELFT>::Elf_Sym Elf_Sym;
auto ESym = new (Alloc) Elf_Sym;
memset(ESym, 0, sizeof(Elf_Sym));
diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h
index c306fb1..a228ea6 100644
--- a/lld/ELF/SymbolTable.h
+++ b/lld/ELF/SymbolTable.h
@@ -15,6 +15,7 @@
namespace lld {
namespace elf2 {
+template <bool Is64Bits> class OutputSectionBase;
struct Symbol;
// SymbolTable is a bucket of all known symbols, including defined,
@@ -49,7 +50,8 @@
SymbolBody *addUndefined(StringRef Name);
SymbolBody *addUndefinedOpt(StringRef Name);
- void addSyntheticSym(StringRef Name, OutputSection<ELFT> &Section,
+ void addSyntheticSym(StringRef Name,
+ OutputSectionBase<ELFT::Is64Bits> &Section,
typename llvm::object::ELFFile<ELFT>::uintX_t Value);
void addIgnoredSym(StringRef Name);
void scanShlibUndefined();
diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h
index 980507b..b0c5688 100644
--- a/lld/ELF/Symbols.h
+++ b/lld/ELF/Symbols.h
@@ -37,6 +37,7 @@
class SymbolBody;
template <class ELFT> class ObjectFile;
template <class ELFT> class OutputSection;
+template <bool Is64Bits> class OutputSectionBase;
template <class ELFT> class SharedFile;
// Initializes global objects defined in this file.
@@ -233,14 +234,14 @@
public:
typedef typename Base::Elf_Sym Elf_Sym;
DefinedSynthetic(StringRef N, const Elf_Sym &Sym,
- OutputSection<ELFT> &Section)
+ OutputSectionBase<ELFT::Is64Bits> &Section)
: Defined<ELFT>(Base::DefinedSyntheticKind, N, Sym), Section(Section) {}
static bool classof(const SymbolBody *S) {
return S->kind() == Base::DefinedSyntheticKind;
}
- const OutputSection<ELFT> &Section;
+ const OutputSectionBase<ELFT::Is64Bits> &Section;
};
// Undefined symbol.
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 0a86a23..bd82c69 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -427,7 +427,7 @@
Map.lookup({".fini_array", SHT_FINI_ARRAY, SHF_WRITE | SHF_ALLOC});
auto AddStartEnd = [&](StringRef Start, StringRef End,
- OutputSection<ELFT> *OS) {
+ OutputSectionBase<ELFT::Is64Bits> *OS) {
if (OS) {
Symtab.addSyntheticSym(Start, *OS, 0);
Symtab.addSyntheticSym(End, *OS, OS->getSize());