[lld] r250419 - Use OutputSectionBase in a few cases where we don't need a OutputSection.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 15 08:29:53 PDT 2015
Author: rafael
Date: Thu Oct 15 10:29:53 2015
New Revision: 250419
URL: http://llvm.org/viewvc/llvm-project?rev=250419&view=rev
Log:
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.
Modified:
lld/trunk/ELF/InputSection.h
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/ELF/SymbolTable.h
lld/trunk/ELF/Symbols.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=250419&r1=250418&r2=250419&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Thu Oct 15 10:29:53 2015
@@ -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;
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=250419&r1=250418&r2=250419&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Thu Oct 15 10:29:53 2015
@@ -346,7 +346,7 @@ template <class ELFT> void DynamicSectio
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>::writeGlob
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()) {
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=250419&r1=250418&r2=250419&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Thu Oct 15 10:29:53 2015
@@ -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> *
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;
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=250419&r1=250418&r2=250419&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Thu Oct 15 10:29:53 2015
@@ -71,9 +71,9 @@ SymbolBody *SymbolTable<ELFT>::addUndefi
}
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));
Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=250419&r1=250418&r2=250419&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Thu Oct 15 10:29:53 2015
@@ -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();
Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=250419&r1=250418&r2=250419&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Thu Oct 15 10:29:53 2015
@@ -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 DefinedSynth
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.
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=250419&r1=250418&r2=250419&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Oct 15 10:29:53 2015
@@ -427,7 +427,7 @@ template <class ELFT> void Writer<ELFT>:
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());
More information about the llvm-commits
mailing list