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
This commit is contained in:
Rafael Espindola 2015-10-15 15:29:53 +00:00
parent c2d2b4259c
commit ae81a7bf49
7 changed files with 19 additions and 15 deletions

View File

@ -18,6 +18,7 @@ namespace elf2 {
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 @@ public:
// 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;

View File

@ -346,7 +346,7 @@ template <class ELFT> void DynamicSection<ELFT>::writeTo(uint8_t *Buf) {
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 @@ void SymbolTableSection<ELFT>::writeGlobalSymbols(uint8_t *&Buf) {
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()) {

View File

@ -267,9 +267,9 @@ public:
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 @@ template <class ELFT> struct Out {
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> GotSection<ELFT> *Out<ELFT>::Got;
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;

View File

@ -71,9 +71,9 @@ SymbolBody *SymbolTable<ELFT>::addUndefinedOpt(StringRef Name) {
}
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));

View File

@ -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 @@ public:
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();

View File

@ -37,6 +37,7 @@ class InputFile;
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 @@ template <class ELFT> class DefinedSynthetic : public Defined<ELFT> {
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.

View File

@ -427,7 +427,7 @@ template <class ELFT> void Writer<ELFT>::createSections() {
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());