<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 10, 2016 at 3:47 PM, Rui Ueyama via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It seems we could do the same thing for InputSectionBase, and it would have the same advantage as this patch aims for. What do you think?</div></blockquote><div><br></div><div>That would have a cost for the sizeof of input sections for 32-bit target links, but I'm not sure how much we care about that.</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 9, 2016 at 3:23 PM, Rafael Espindola via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafael<br>
Date: Wed Nov 9 17:23:45 2016<br>
New Revision: 286414<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=286414&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=286414&view=rev</a><br>
Log:<br>
Make OutputSectionBase a class instead of class template.<br>
<br>
The disadvantage is that we use uint64_t instad of uint32_t for some<br>
value in 32 bit files. The advantage is a substantially simpler code,<br>
faster builds and less code duplication.<br>
<br>
Modified:<br>
lld/trunk/ELF/InputSection.h<br>
lld/trunk/ELF/LinkerScript.cpp<br>
lld/trunk/ELF/LinkerScript.h<br>
lld/trunk/ELF/OutputSections.c<wbr>pp<br>
lld/trunk/ELF/OutputSections.h<br>
lld/trunk/ELF/SymbolTable.cpp<br>
lld/trunk/ELF/SymbolTable.h<br>
lld/trunk/ELF/Symbols.cpp<br>
lld/trunk/ELF/Symbols.h<br>
lld/trunk/ELF/Writer.cpp<br>
lld/trunk/ELF/Writer.h<br>
<br>
Modified: lld/trunk/ELF/InputSection.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=286414&r1=286413&r2=286414&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/InputSecti<wbr>on.h?rev=286414&r1=286413&r2=2<wbr>86414&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/InputSection.h (original)<br>
+++ lld/trunk/ELF/InputSection.h Wed Nov 9 17:23:45 2016<br>
@@ -29,7 +29,7 @@ template <class ELFT> class ICF;<br>
template <class ELFT> class DefinedRegular;<br>
template <class ELFT> class ObjectFile;<br>
template <class ELFT> class OutputSection;<br>
-template <class ELFT> class OutputSectionBase;<br>
+class OutputSectionBase;<br>
<br>
// We need non-template input section class to store symbol layout<br>
// in linker script parser structures, where we do not have ELFT<br>
@@ -104,7 +104,7 @@ public:<br>
uintX_t Entsize, uint32_t Link, uint32_t Info,<br>
uintX_t Addralign, ArrayRef<uint8_t> Data, StringRef Name,<br>
Kind SectionKind);<br>
- OutputSectionBase<ELFT> *OutSec = nullptr;<br>
+ OutputSectionBase *OutSec = nullptr;<br>
<br>
// This pointer points to the "real" instance of this instance.<br>
// Usually Repl == this. However, if ICF merges two sections,<br>
<br>
Modified: lld/trunk/ELF/LinkerScript.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=286414&r1=286413&r2=286414&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/LinkerScri<wbr>pt.cpp?rev=286414&r1=286413&r2<wbr>=286414&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/LinkerScript.cpp (original)<br>
+++ lld/trunk/ELF/LinkerScript.cpp Wed Nov 9 17:23:45 2016<br>
@@ -229,7 +229,7 @@ void LinkerScript<ELFT>::computeInp<wbr>utSec<br>
// section for now.<br>
for (InputSectionData *S : I->Sections) {<br>
auto *S2 = static_cast<InputSectionBase<E<wbr>LFT> *>(S);<br>
- S2->OutSec = (OutputSectionBase<ELFT> *)-1;<br>
+ S2->OutSec = (OutputSectionBase *)-1;<br>
}<br>
}<br>
<br>
@@ -298,7 +298,7 @@ template <class ELFT><br>
void LinkerScript<ELFT>::addSection<wbr>(OutputSectionFactory<ELFT> &Factory,<br>
InputSectionBase<ELFT> *Sec,<br>
StringRef Name) {<br>
- OutputSectionBase<ELFT> *OutSec;<br>
+ OutputSectionBase *OutSec;<br>
bool IsNew;<br>
std::tie(OutSec, IsNew) = Factory.create(createKey(Sec, Name), Sec);<br>
if (IsNew)<br>
@@ -373,8 +373,7 @@ void LinkerScript<ELFT>::createSect<wbr>ions(<br>
// is an offset from beginning of section and regular<br>
// symbols whose value is absolute.<br>
template <class ELFT><br>
-static void assignSectionSymbol(SymbolAssi<wbr>gnment *Cmd,<br>
- OutputSectionBase<ELFT> *Sec,<br>
+static void assignSectionSymbol(SymbolAssi<wbr>gnment *Cmd, OutputSectionBase *Sec,<br>
typename ELFT::uint Value) {<br>
if (!Cmd->Sym)<br>
return;<br>
@@ -388,14 +387,14 @@ static void assignSectionSymbol(SymbolAs<br>
Body->Value = Cmd->Expression(Value);<br>
}<br>
<br>
-template <class ELFT> static bool isTbss(OutputSectionBase<ELFT> *Sec) {<br>
+template <class ELFT> static bool isTbss(OutputSectionBase *Sec) {<br>
return (Sec->Flags & SHF_TLS) && Sec->Type == SHT_NOBITS;<br>
}<br>
<br>
template <class ELFT> void LinkerScript<ELFT>::output(Inp<wbr>utSection<ELFT> *S) {<br>
if (!AlreadyOutputIS.insert(S).se<wbr>cond)<br>
return;<br>
- bool IsTbss = isTbss(CurOutSec);<br>
+ bool IsTbss = isTbss<ELFT>(CurOutSec);<br>
<br>
uintX_t Pos = IsTbss ? Dot + ThreadBssOffset : Dot;<br>
Pos = alignTo(Pos, S->Alignment);<br>
@@ -425,7 +424,7 @@ template <class ELFT> void LinkerScript<<br>
}<br>
<br>
template <class ELFT><br>
-void LinkerScript<ELFT>::switchTo(O<wbr>utputSectionBase<ELFT> *Sec) {<br>
+void LinkerScript<ELFT>::switchTo(O<wbr>utputSectionBase *Sec) {<br>
if (CurOutSec == Sec)<br>
return;<br>
if (AlreadyOutputOS.count(Sec))<br>
@@ -435,7 +434,7 @@ void LinkerScript<ELFT>::switchTo(O<wbr>utput<br>
CurOutSec = Sec;<br>
<br>
Dot = alignTo(Dot, CurOutSec->Addralign);<br>
- CurOutSec->Addr = isTbss(CurOutSec) ? Dot + ThreadBssOffset : Dot;<br>
+ CurOutSec->Addr = isTbss<ELFT>(CurOutSec) ? Dot + ThreadBssOffset : Dot;<br>
<br>
// If neither AT nor AT> is specified for an allocatable section, the linker<br>
// will set the LMA such that the difference between VMA and LMA for the<br>
@@ -480,11 +479,10 @@ template <class ELFT> void LinkerScript<<br>
}<br>
<br>
template <class ELFT><br>
-static std::vector<OutputSectionBase<<wbr>ELFT> *><br>
-findSections(StringRef Name,<br>
- const std::vector<OutputSectionBase<<wbr>ELFT> *> &Sections) {<br>
- std::vector<OutputSectionBase<<wbr>ELFT> *> Ret;<br>
- for (OutputSectionBase<ELFT> *Sec : Sections)<br>
+static std::vector<OutputSectionBase *><br>
+findSections(StringRef Name, const std::vector<OutputSectionBase *> &Sections) {<br>
+ std::vector<OutputSectionBase *> Ret;<br>
+ for (OutputSectionBase *Sec : Sections)<br>
if (Sec->getName() == Name)<br>
Ret.push_back(Sec);<br>
return Ret;<br>
@@ -494,8 +492,8 @@ template <class ELFT><br>
void LinkerScript<ELFT>::assignOffs<wbr>ets(OutputSectionCommand *Cmd) {<br>
if (Cmd->LMAExpr)<br>
LMAOffset = Cmd->LMAExpr(Dot) - Dot;<br>
- std::vector<OutputSectionBase<<wbr>ELFT> *> Sections =<br>
- findSections(Cmd->Name, *OutputSections);<br>
+ std::vector<OutputSectionBase *> Sections =<br>
+ findSections<ELFT>(Cmd->Name, *OutputSections);<br>
if (Sections.empty())<br>
return;<br>
switchTo(Sections[0]);<br>
@@ -508,7 +506,7 @@ void LinkerScript<ELFT>::assignOffs<wbr>ets(O<br>
.base();<br>
for (auto I = Cmd->Commands.begin(); I != E; ++I)<br>
process(**I);<br>
- for (OutputSectionBase<ELFT> *Base : Sections)<br>
+ for (OutputSectionBase *Base : Sections)<br>
switchTo(Base);<br>
flush();<br>
std::for_each(E, Cmd->Commands.end(),<br>
@@ -528,8 +526,8 @@ template <class ELFT> void LinkerScript<<br>
auto *Cmd = dyn_cast<OutputSectionCommand><wbr>(Base.get());<br>
if (!Cmd)<br>
return false;<br>
- std::vector<OutputSectionBase<<wbr>ELFT> *> Secs =<br>
- findSections(Cmd->Name, *OutputSections);<br>
+ std::vector<OutputSectionBase *> Secs =<br>
+ findSections<ELFT>(Cmd->Name, *OutputSections);<br>
if (!Secs.empty())<br>
return false;<br>
for (const std::unique_ptr<BaseCommand> &I : Cmd->Commands)<br>
@@ -549,8 +547,8 @@ template <class ELFT> void LinkerScript<<br>
auto *Cmd = dyn_cast<OutputSectionCommand><wbr>(Base.get());<br>
if (!Cmd)<br>
continue;<br>
- std::vector<OutputSectionBase<<wbr>ELFT> *> Secs =<br>
- findSections(Cmd->Name, *OutputSections);<br>
+ std::vector<OutputSectionBase *> Secs =<br>
+ findSections<ELFT>(Cmd->Name, *OutputSections);<br>
if (!Secs.empty()) {<br>
Flags = Secs[0]->Flags;<br>
Type = Secs[0]->Type;<br>
@@ -597,7 +595,7 @@ void LinkerScript<ELFT>::assignAddr<wbr>esses<br>
// This loops creates or moves commands as needed so that they are in the<br>
// correct order.<br>
int CmdIndex = 0;<br>
- for (OutputSectionBase<ELFT> *Sec : *OutputSections) {<br>
+ for (OutputSectionBase *Sec : *OutputSections) {<br>
StringRef Name = Sec->getName();<br>
<br>
// Find the last spot where we can insert a command and still get the<br>
@@ -633,8 +631,8 @@ void LinkerScript<ELFT>::assignAddr<wbr>esses<br>
if (Cmd->Name == ".") {<br>
Dot = Cmd->Expression(Dot);<br>
} else if (Cmd->Sym) {<br>
- assignSectionSymbol(Cmd, CurOutSec ? CurOutSec : (*OutputSections)[0],<br>
- Dot);<br>
+ assignSectionSymbol<ELFT>(<br>
+ Cmd, CurOutSec ? CurOutSec : (*OutputSections)[0], Dot);<br>
}<br>
continue;<br>
}<br>
@@ -653,9 +651,9 @@ void LinkerScript<ELFT>::assignAddr<wbr>esses<br>
}<br>
<br>
uintX_t MinVA = std::numeric_limits<uintX_t>::<wbr>max();<br>
- for (OutputSectionBase<ELFT> *Sec : *OutputSections) {<br>
+ for (OutputSectionBase *Sec : *OutputSections) {<br>
if (Sec->Flags & SHF_ALLOC)<br>
- MinVA = std::min(MinVA, Sec->Addr);<br>
+ MinVA = std::min<uint64_t>(MinVA, Sec->Addr);<br>
else<br>
Sec->Addr = 0;<br>
}<br>
@@ -730,7 +728,7 @@ std::vector<PhdrEntry<ELFT>> LinkerScrip<br>
}<br>
<br>
// Add output sections to program headers.<br>
- for (OutputSectionBase<ELFT> *Sec : *OutputSections) {<br>
+ for (OutputSectionBase *Sec : *OutputSections) {<br>
if (!(Sec->Flags & SHF_ALLOC))<br>
break;<br>
<br>
@@ -831,7 +829,7 @@ template <class ELFT> bool LinkerScript<<br>
<br>
template <class ELFT><br>
uint64_t LinkerScript<ELFT>::getOutputS<wbr>ectionAddress(StringRef Name) {<br>
- for (OutputSectionBase<ELFT> *Sec : *OutputSections)<br>
+ for (OutputSectionBase *Sec : *OutputSections)<br>
if (Sec->getName() == Name)<br>
return Sec->Addr;<br>
error("undefined section " + Name);<br>
@@ -840,7 +838,7 @@ uint64_t LinkerScript<ELFT>::getOutputS<wbr>e<br>
<br>
template <class ELFT><br>
uint64_t LinkerScript<ELFT>::getOutputS<wbr>ectionLMA(StringRef Name) {<br>
- for (OutputSectionBase<ELFT> *Sec : *OutputSections)<br>
+ for (OutputSectionBase *Sec : *OutputSections)<br>
if (Sec->getName() == Name)<br>
return Sec->getLMA();<br>
error("undefined section " + Name);<br>
@@ -849,7 +847,7 @@ uint64_t LinkerScript<ELFT>::getOutputS<wbr>e<br>
<br>
template <class ELFT><br>
uint64_t LinkerScript<ELFT>::getOutputS<wbr>ectionSize(StringRef Name) {<br>
- for (OutputSectionBase<ELFT> *Sec : *OutputSections)<br>
+ for (OutputSectionBase *Sec : *OutputSections)<br>
if (Sec->getName() == Name)<br>
return Sec->Size;<br>
error("undefined section " + Name);<br>
@@ -858,7 +856,7 @@ uint64_t LinkerScript<ELFT>::getOutputS<wbr>e<br>
<br>
template <class ELFT><br>
uint64_t LinkerScript<ELFT>::getOutputS<wbr>ectionAlign(StringRef Name) {<br>
- for (OutputSectionBase<ELFT> *Sec : *OutputSections)<br>
+ for (OutputSectionBase *Sec : *OutputSections)<br>
if (Sec->getName() == Name)<br>
return Sec->Addralign;<br>
error("undefined section " + Name);<br>
<br>
Modified: lld/trunk/ELF/LinkerScript.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=286414&r1=286413&r2=286414&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/LinkerScri<wbr>pt.h?rev=286414&r1=286413&r2=2<wbr>86414&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/LinkerScript.h (original)<br>
+++ lld/trunk/ELF/LinkerScript.h Wed Nov 9 17:23:45 2016<br>
@@ -32,7 +32,7 @@ class ScriptParser;<br>
class SymbolBody;<br>
template <class ELFT> class InputSectionBase;<br>
template <class ELFT> class InputSection;<br>
-template <class ELFT> class OutputSectionBase;<br>
+class OutputSectionBase;<br>
template <class ELFT> class OutputSectionFactory;<br>
class InputSectionData;<br>
<br>
@@ -240,7 +240,7 @@ public:<br>
bool isDefined(StringRef S) override;<br>
bool isAbsolute(StringRef S) override;<br>
<br>
- std::vector<OutputSectionBase<<wbr>ELFT> *> *OutputSections;<br>
+ std::vector<OutputSectionBase *> *OutputSections;<br>
<br>
int getSectionIndex(StringRef Name);<br>
<br>
@@ -262,13 +262,13 @@ private:<br>
<br>
uintX_t Dot;<br>
uintX_t LMAOffset = 0;<br>
- OutputSectionBase<ELFT> *CurOutSec = nullptr;<br>
+ OutputSectionBase *CurOutSec = nullptr;<br>
uintX_t ThreadBssOffset = 0;<br>
- void switchTo(OutputSectionBase<ELF<wbr>T> *Sec);<br>
+ void switchTo(OutputSectionBase *Sec);<br>
void flush();<br>
void output(InputSection<ELFT> *Sec);<br>
void process(BaseCommand &Base);<br>
- llvm::DenseSet<OutputSectionBa<wbr>se<ELFT> *> AlreadyOutputOS;<br>
+ llvm::DenseSet<OutputSectionBa<wbr>se *> AlreadyOutputOS;<br>
llvm::DenseSet<InputSectionDa<wbr>ta *> AlreadyOutputIS;<br>
};<br>
<br>
<br>
Modified: lld/trunk/ELF/OutputSections.c<wbr>pp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=286414&r1=286413&r2=286414&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/OutputSect<wbr>ions.cpp?rev=286414&r1=286413&<wbr>r2=286414&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/OutputSections.c<wbr>pp (original)<br>
+++ lld/trunk/ELF/OutputSections.c<wbr>pp Wed Nov 9 17:23:45 2016<br>
@@ -32,16 +32,15 @@ using namespace llvm::ELF;<br>
using namespace lld;<br>
using namespace lld::elf;<br>
<br>
-template <class ELFT><br>
-OutputSectionBase<ELFT>::Outp<wbr>utSectionBase(StringRef Name, uint32_t Type,<br>
- uintX_t Flags)<br>
+OutputSectionBase::OutputSect<wbr>ionBase(StringRef Name, uint32_t Type,<br>
+ uint64_t Flags)<br>
: Name(Name) {<br>
this->Type = Type;<br>
this->Flags = Flags;<br>
this->Addralign = 1;<br>
}<br>
<br>
-template <class ELFT> uint32_t OutputSectionBase<ELFT>::getPh<wbr>drFlags() const {<br>
+uint32_t OutputSectionBase::getPhdrFlag<wbr>s() const {<br>
uint32_t Ret = PF_R;<br>
if (Flags & SHF_WRITE)<br>
Ret |= PF_W;<br>
@@ -51,7 +50,7 @@ template <class ELFT> uint32_t OutputSec<br>
}<br>
<br>
template <class ELFT><br>
-void OutputSectionBase<ELFT>::write<wbr>HeaderTo(Elf_Shdr *Shdr) {<br>
+void OutputSectionBase::writeHeader<wbr>To(typename ELFT::Shdr *Shdr) {<br>
Shdr->sh_entsize = Entsize;<br>
Shdr->sh_addralign = Addralign;<br>
Shdr->sh_type = Type;<br>
@@ -66,7 +65,7 @@ void OutputSectionBase<ELFT>::write<wbr>Heade<br>
<br>
template <class ELFT><br>
GdbIndexSection<ELFT>::GdbInd<wbr>exSection()<br>
- : OutputSectionBase<ELFT>(".gdb_<wbr>index", SHT_PROGBITS, 0) {}<br>
+ : OutputSectionBase(".gdb_index"<wbr>, SHT_PROGBITS, 0) {}<br>
<br>
template <class ELFT> void GdbIndexSection<ELFT>::parseDe<wbr>bugSections() {<br>
std::vector<InputSection<ELFT<wbr>> *> &IS =<br>
@@ -110,7 +109,7 @@ template <class ELFT> void GdbIndexSecti<br>
<br>
template <class ELFT><br>
GotPltSection<ELFT>::GotPltSe<wbr>ction()<br>
- : OutputSectionBase<ELFT>(".got.<wbr>plt", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE) {<br>
+ : OutputSectionBase(".got.plt", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE) {<br>
this->Addralign = Target->GotPltEntrySize;<br>
}<br>
<br>
@@ -139,7 +138,7 @@ template <class ELFT> void GotPltSection<br>
<br>
template <class ELFT><br>
GotSection<ELFT>::GotSection(<wbr>)<br>
- : OutputSectionBase<ELFT>(".got"<wbr>, SHT_PROGBITS, SHF_ALLOC | SHF_WRITE) {<br>
+ : OutputSectionBase(".got", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE) {<br>
if (Config->EMachine == EM_MIPS)<br>
this->Flags |= SHF_MIPS_GPREL;<br>
this->Addralign = Target->GotEntrySize;<br>
@@ -313,7 +312,7 @@ template <class ELFT> void GotSection<EL<br>
// Take into account MIPS GOT header.<br>
// See comment in the GotSection::writeTo.<br>
MipsPageEntries += 2;<br>
- for (const OutputSectionBase<ELFT> *OutSec : MipsOutSections) {<br>
+ for (const OutputSectionBase *OutSec : MipsOutSections) {<br>
// Calculate an upper bound of MIPS GOT entries required to store page<br>
// addresses of local symbols. We assume the worst case - each 64kb<br>
// page of the output section has at least one GOT relocation against it.<br>
@@ -408,7 +407,7 @@ template <class ELFT> void GotSection<EL<br>
<br>
template <class ELFT><br>
PltSection<ELFT>::PltSection(<wbr>)<br>
- : OutputSectionBase<ELFT>(".plt"<wbr>, SHT_PROGBITS, SHF_ALLOC | SHF_EXECINSTR) {<br>
+ : OutputSectionBase(".plt", SHT_PROGBITS, SHF_ALLOC | SHF_EXECINSTR) {<br>
this->Addralign = 16;<br>
}<br>
<br>
@@ -440,8 +439,7 @@ template <class ELFT> void PltSection<EL<br>
<br>
template <class ELFT><br>
RelocationSection<ELFT>::Relo<wbr>cationSection(StringRef Name, bool Sort)<br>
- : OutputSectionBase<ELFT>(Name, Config->Rela ? SHT_RELA : SHT_REL,<br>
- SHF_ALLOC),<br>
+ : OutputSectionBase(Name, Config->Rela ? SHT_RELA : SHT_REL, SHF_ALLOC),<br>
Sort(Sort) {<br>
this->Entsize = Config->Rela ? sizeof(Elf_Rela) : sizeof(Elf_Rel);<br>
this->Addralign = sizeof(uintX_t);<br>
@@ -504,7 +502,7 @@ template <class ELFT> void RelocationSec<br>
<br>
template <class ELFT><br>
HashTableSection<ELFT>::HashT<wbr>ableSection()<br>
- : OutputSectionBase<ELFT>(".hash<wbr>", SHT_HASH, SHF_ALLOC) {<br>
+ : OutputSectionBase(".hash", SHT_HASH, SHF_ALLOC) {<br>
this->Entsize = sizeof(Elf_Word);<br>
this->Addralign = sizeof(Elf_Word);<br>
}<br>
@@ -550,7 +548,7 @@ static uint32_t hashGnu(StringRef Name)<br>
<br>
template <class ELFT><br>
GnuHashTableSection<ELFT>::Gn<wbr>uHashTableSection()<br>
- : OutputSectionBase<ELFT>(".gnu.<wbr>hash", SHT_GNU_HASH, SHF_ALLOC) {<br>
+ : OutputSectionBase(".gnu.hash", SHT_GNU_HASH, SHF_ALLOC) {<br>
this->Entsize = ELFT::Is64Bits ? 0 : 4;<br>
this->Addralign = sizeof(uintX_t);<br>
}<br>
@@ -695,7 +693,7 @@ static unsigned getVerDefNum() { return<br>
<br>
template <class ELFT><br>
DynamicSection<ELFT>::Dynamic<wbr>Section()<br>
- : OutputSectionBase<ELFT>(".dyna<wbr>mic", SHT_DYNAMIC, SHF_ALLOC | SHF_WRITE) {<br>
+ : OutputSectionBase(".dynamic", SHT_DYNAMIC, SHF_ALLOC | SHF_WRITE) {<br>
this->Addralign = sizeof(uintX_t);<br>
this->Entsize = ELFT::Is64Bits ? 16 : 8;<br>
<br>
@@ -863,7 +861,7 @@ template <class ELFT> void DynamicSectio<br>
<br>
template <class ELFT><br>
EhFrameHeader<ELFT>::EhFrameH<wbr>eader()<br>
- : OutputSectionBase<ELFT>(".eh_f<wbr>rame_hdr", SHT_PROGBITS, SHF_ALLOC) {}<br>
+ : OutputSectionBase(".eh_frame_h<wbr>dr", SHT_PROGBITS, SHF_ALLOC) {}<br>
<br>
// .eh_frame_hdr contains a binary search table of pointers to FDEs.<br>
// Each entry of the search table consists of two values,<br>
@@ -925,7 +923,7 @@ template <class ELFT> static uint64_t ge<br>
<br>
template <class ELFT><br>
OutputSection<ELFT>::OutputSe<wbr>ction(StringRef Name, uint32_t Type, uintX_t Flags)<br>
- : OutputSectionBase<ELFT>(Name, Type, Flags) {<br>
+ : OutputSectionBase(Name, Type, Flags) {<br>
this->Entsize = getEntsize<ELFT>(Type);<br>
}<br>
<br>
@@ -956,7 +954,7 @@ template <class ELFT> void OutputSection<br>
}<br>
<br>
template <class ELFT><br>
-void OutputSection<ELFT>::addSectio<wbr>n(InputSectionBase<ELFT> *C) {<br>
+void OutputSection<ELFT>::addSectio<wbr>n(InputSectionData *C) {<br>
assert(C->Live);<br>
auto *S = cast<InputSection<ELFT>>(C);<br>
Sections.push_back(S);<br>
@@ -1085,7 +1083,7 @@ template <class ELFT> void OutputSection<br>
<br>
template <class ELFT><br>
EhOutputSection<ELFT>::EhOutp<wbr>utSection()<br>
- : OutputSectionBase<ELFT>(".eh_f<wbr>rame", SHT_PROGBITS, SHF_ALLOC) {}<br>
+ : OutputSectionBase(".eh_frame", SHT_PROGBITS, SHF_ALLOC) {}<br>
<br>
// Search for an existing CIE record or create a new one.<br>
// CIE records from input object files are uniquified by their contents<br>
@@ -1170,7 +1168,7 @@ void EhOutputSection<ELFT>::addSect<wbr>ionAu<br>
}<br>
<br>
template <class ELFT><br>
-void EhOutputSection<ELFT>::addSect<wbr>ion(InputSectionBase<ELFT> *C) {<br>
+void EhOutputSection<ELFT>::addSect<wbr>ion(InputSectionData *C) {<br>
auto *Sec = cast<EhInputSection<ELFT>>(C);<br>
Sec->OutSec = this;<br>
this->updateAlignment(Sec->Al<wbr>ignment);<br>
@@ -1290,7 +1288,7 @@ template <class ELFT> void EhOutputSecti<br>
template <class ELFT><br>
MergeOutputSection<ELFT>::Mer<wbr>geOutputSection(StringRef Name, uint32_t Type,<br>
uintX_t Flags, uintX_t Alignment)<br>
- : OutputSectionBase<ELFT>(Name, Type, Flags),<br>
+ : OutputSectionBase(Name, Type, Flags),<br>
Builder(StringTableBuilder::R<wbr>AW, Alignment) {}<br>
<br>
template <class ELFT> void MergeOutputSection<ELFT>::writ<wbr>eTo(uint8_t *Buf) {<br>
@@ -1298,7 +1296,7 @@ template <class ELFT> void MergeOutputSe<br>
}<br>
<br>
template <class ELFT><br>
-void MergeOutputSection<ELFT>::addS<wbr>ection(InputSectionBase<ELFT> *C) {<br>
+void MergeOutputSection<ELFT>::addS<wbr>ection(InputSectionData *C) {<br>
auto *Sec = cast<MergeInputSection<ELFT>>(<wbr>C);<br>
Sec->OutSec = this;<br>
this->updateAlignment(Sec->Al<wbr>ignment);<br>
@@ -1344,8 +1342,7 @@ template <class ELFT> void MergeOutputSe<br>
<br>
template <class ELFT><br>
StringTableSection<ELFT>::Str<wbr>ingTableSection(StringRef Name, bool Dynamic)<br>
- : OutputSectionBase<ELFT>(Name, SHT_STRTAB,<br>
- Dynamic ? (uintX_t)SHF_ALLOC : 0),<br>
+ : OutputSectionBase(Name, SHT_STRTAB, Dynamic ? (uintX_t)SHF_ALLOC : 0),<br>
Dynamic(Dynamic) {<br>
// ELF string tables start with a NUL byte, so 1.<br>
this->Size = 1;<br>
@@ -1400,9 +1397,9 @@ template <class ELFT> uint32_t DynamicRe<br>
template <class ELFT><br>
SymbolTableSection<ELFT>::Sym<wbr>bolTableSection(<br>
StringTableSection<ELFT> &StrTabSec)<br>
- : OutputSectionBase<ELFT>(StrTab<wbr>Sec.isDynamic() ? ".dynsym" : ".symtab",<br>
- StrTabSec.isDynamic() ? SHT_DYNSYM : SHT_SYMTAB,<br>
- StrTabSec.isDynamic() ? (uintX_t)SHF_ALLOC : 0),<br>
+ : OutputSectionBase(StrTabSec.is<wbr>Dynamic() ? ".dynsym" : ".symtab",<br>
+ StrTabSec.isDynamic() ? SHT_DYNSYM : SHT_SYMTAB,<br>
+ StrTabSec.isDynamic() ? (uintX_t)SHF_ALLOC : 0),<br>
StrTabSec(StrTabSec) {<br>
this->Entsize = sizeof(Elf_Sym);<br>
this->Addralign = sizeof(uintX_t);<br>
@@ -1501,7 +1498,7 @@ void SymbolTableSection<ELFT>::writ<wbr>eLoca<br>
ESym->st_shndx = SHN_ABS;<br>
ESym->st_value = Body.Value;<br>
} else {<br>
- const OutputSectionBase<ELFT> *OutSec = Section->OutSec;<br>
+ const OutputSectionBase *OutSec = Section->OutSec;<br>
ESym->st_shndx = OutSec->SectionIndex;<br>
ESym->st_value = OutSec->Addr + Section->getOffset(Body);<br>
}<br>
@@ -1531,7 +1528,7 @@ void SymbolTableSection<ELFT>::writ<wbr>eGlob<br>
ESym->setVisibility(Body->sym<wbr>bol()->Visibility);<br>
ESym->st_value = Body->getVA<ELFT>();<br>
<br>
- if (const OutputSectionBase<ELFT> *OutSec = getOutputSection(Body))<br>
+ if (const OutputSectionBase *OutSec = getOutputSection(Body))<br>
ESym->st_shndx = OutSec->SectionIndex;<br>
else if (isa<DefinedRegular<ELFT>>(Bod<wbr>y))<br>
ESym->st_shndx = SHN_ABS;<br>
@@ -1554,7 +1551,7 @@ void SymbolTableSection<ELFT>::writ<wbr>eGlob<br>
}<br>
<br>
template <class ELFT><br>
-const OutputSectionBase<ELFT> *<br>
+const OutputSectionBase *<br>
SymbolTableSection<ELFT>::get<wbr>OutputSection(SymbolBody *Sym) {<br>
switch (Sym->kind()) {<br>
case SymbolBody::DefinedSyntheticKi<wbr>nd:<br>
@@ -1581,7 +1578,7 @@ SymbolTableSection<ELFT>::getO<wbr>utputSecti<br>
<br>
template <class ELFT><br>
VersionDefinitionSection<ELFT<wbr>>::VersionDefinitionSection()<br>
- : OutputSectionBase<ELFT>(".gnu.<wbr>version_d", SHT_GNU_verdef, SHF_ALLOC) {<br>
+ : OutputSectionBase(".gnu.versio<wbr>n_d", SHT_GNU_verdef, SHF_ALLOC) {<br>
this->Addralign = sizeof(uint32_t);<br>
}<br>
<br>
@@ -1638,7 +1635,7 @@ void VersionDefinitionSection<ELFT><wbr>::wri<br>
<br>
template <class ELFT><br>
VersionTableSection<ELFT>::Ve<wbr>rsionTableSection()<br>
- : OutputSectionBase<ELFT>(".gnu.<wbr>version", SHT_GNU_versym, SHF_ALLOC) {<br>
+ : OutputSectionBase(".gnu.versio<wbr>n", SHT_GNU_versym, SHF_ALLOC) {<br>
this->Addralign = sizeof(uint16_t);<br>
}<br>
<br>
@@ -1661,7 +1658,7 @@ template <class ELFT> void VersionTableS<br>
<br>
template <class ELFT><br>
VersionNeedSection<ELFT>::Ver<wbr>sionNeedSection()<br>
- : OutputSectionBase<ELFT>(".gnu.<wbr>version_r", SHT_GNU_verneed, SHF_ALLOC) {<br>
+ : OutputSectionBase(".gnu.versio<wbr>n_r", SHT_GNU_verneed, SHF_ALLOC) {<br>
this->Addralign = sizeof(uint32_t);<br>
<br>
// Identifiers in verneed section start at 2 because 0 and 1 are reserved<br>
@@ -1764,7 +1761,7 @@ static SectionKey<ELFT::Is64Bits> create<br>
}<br>
<br>
template <class ELFT><br>
-std::pair<OutputSectionBase<E<wbr>LFT> *, bool><br>
+std::pair<OutputSectionBase *, bool><br>
OutputSectionFactory<ELFT>::c<wbr>reate(InputSectionBase<ELFT> *C,<br>
StringRef OutsecName) {<br>
SectionKey<ELFT::Is64Bits> Key = createKey(C, OutsecName);<br>
@@ -1772,11 +1769,11 @@ OutputSectionFactory<ELFT>::cr<wbr>eate(Input<br>
}<br>
<br>
template <class ELFT><br>
-std::pair<OutputSectionBase<E<wbr>LFT> *, bool><br>
+std::pair<OutputSectionBase *, bool><br>
OutputSectionFactory<ELFT>::c<wbr>reate(const SectionKey<ELFT::Is64Bits> &Key,<br>
InputSectionBase<ELFT> *C) {<br>
uintX_t Flags = getOutFlags(C);<br>
- OutputSectionBase<ELFT> *&Sec = Map[Key];<br>
+ OutputSectionBase *&Sec = Map[Key];<br>
if (Sec) {<br>
Sec->Flags |= Flags;<br>
return {Sec, false};<br>
@@ -1830,10 +1827,11 @@ template struct DenseMapInfo<SectionKey<<br>
<br>
namespace lld {<br>
namespace elf {<br>
-template class OutputSectionBase<ELF32LE>;<br>
-template class OutputSectionBase<ELF32BE>;<br>
-template class OutputSectionBase<ELF64LE>;<br>
-template class OutputSectionBase<ELF64BE>;<br>
+<br>
+template void OutputSectionBase::writeHeader<wbr>To<ELF32LE>(ELF32LE::Shdr *Shdr);<br>
+template void OutputSectionBase::writeHeader<wbr>To<ELF32BE>(ELF32BE::Shdr *Shdr);<br>
+template void OutputSectionBase::writeHeader<wbr>To<ELF64LE>(ELF64LE::Shdr *Shdr);<br>
+template void OutputSectionBase::writeHeader<wbr>To<ELF64BE>(ELF64BE::Shdr *Shdr);<br>
<br>
template class EhFrameHeader<ELF32LE>;<br>
template class EhFrameHeader<ELF32BE>;<br>
<br>
Modified: lld/trunk/ELF/OutputSections.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=286414&r1=286413&r2=286414&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/OutputSect<wbr>ions.h?rev=286414&r1=286413&r2<wbr>=286414&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/OutputSections.h (original)<br>
+++ lld/trunk/ELF/OutputSections.h Wed Nov 9 17:23:45 2016<br>
@@ -42,10 +42,8 @@ template <class ELFT> class DefinedRegul<br>
// input sections, others are created by the linker.<br>
// The writer creates multiple OutputSections and assign them unique,<br>
// non-overlapping file offsets and VAs.<br>
-template <class ELFT> class OutputSectionBase {<br>
+class OutputSectionBase {<br>
public:<br>
- typedef typename ELFT::uint uintX_t;<br>
- typedef typename ELFT::Shdr Elf_Shdr;<br>
enum Kind {<br>
Base,<br>
Dynamic,<br>
@@ -66,15 +64,15 @@ public:<br>
VersTable<br>
};<br>
<br>
- OutputSectionBase(StringRef Name, uint32_t Type, uintX_t Flags);<br>
- void setLMAOffset(uintX_t LMAOff) { LMAOffset = LMAOff; }<br>
- uintX_t getLMA() const { return Addr + LMAOffset; }<br>
- void writeHeaderTo(Elf_Shdr *SHdr);<br>
+ OutputSectionBase(StringRef Name, uint32_t Type, uint64_t Flags);<br>
+ void setLMAOffset(uint64_t LMAOff) { LMAOffset = LMAOff; }<br>
+ uint64_t getLMA() const { return Addr + LMAOffset; }<br>
+ template <typename ELFT> void writeHeaderTo(typename ELFT::Shdr *SHdr);<br>
StringRef getName() const { return Name; }<br>
<br>
- virtual void addSection(InputSectionBase<EL<wbr>FT> *C) {}<br>
+ virtual void addSection(InputSectionData *C) {}<br>
virtual Kind getKind() const { return Base; }<br>
- static bool classof(const OutputSectionBase<ELFT> *B) {<br>
+ static bool classof(const OutputSectionBase *B) {<br>
return B->getKind() == Base;<br>
}<br>
<br>
@@ -82,7 +80,7 @@ public:<br>
<br>
uint32_t getPhdrFlags() const;<br>
<br>
- void updateAlignment(uintX_t Alignment) {<br>
+ void updateAlignment(uint64_t Alignment) {<br>
if (Alignment > Addralign)<br>
Addralign = Alignment;<br>
}<br>
@@ -97,7 +95,7 @@ public:<br>
// between their file offsets should be equal to difference between their<br>
// virtual addresses. To compute some section offset we use the following<br>
// formula: Off = Off_first + VA - VA_first.<br>
- OutputSectionBase<ELFT> *FirstInPtLoad = nullptr;<br>
+ OutputSectionBase *FirstInPtLoad = nullptr;<br>
<br>
virtual void finalize() {}<br>
virtual void finalizePieces() {}<br>
@@ -108,21 +106,20 @@ public:<br>
StringRef Name;<br>
<br>
// The following fields correspond to Elf_Shdr members.<br>
- uintX_t Size = 0;<br>
- uintX_t Entsize = 0;<br>
- uintX_t Addralign = 0;<br>
- uintX_t Offset = 0;<br>
- uintX_t Flags = 0;<br>
- uintX_t LMAOffset = 0;<br>
- uintX_t Addr = 0;<br>
+ uint64_t Size = 0;<br>
+ uint64_t Entsize = 0;<br>
+ uint64_t Addralign = 0;<br>
+ uint64_t Offset = 0;<br>
+ uint64_t Flags = 0;<br>
+ uint64_t LMAOffset = 0;<br>
+ uint64_t Addr = 0;<br>
uint32_t ShName = 0;<br>
uint32_t Type = 0;<br>
uint32_t Info = 0;<br>
uint32_t Link = 0;<br>
};<br>
<br>
-template <class ELFT><br>
-class GdbIndexSection final : public OutputSectionBase<ELFT> {<br>
+template <class ELFT> class GdbIndexSection final : public OutputSectionBase {<br>
typedef typename ELFT::uint uintX_t;<br>
<br>
const unsigned OffsetTypeSize = 4;<br>
@@ -146,8 +143,7 @@ private:<br>
uint32_t CuTypesOffset;<br>
};<br>
<br>
-template <class ELFT> class GotSection final : public OutputSectionBase<ELFT> {<br>
- typedef OutputSectionBase<ELFT> Base;<br>
+template <class ELFT> class GotSection final : public OutputSectionBase {<br>
typedef typename ELFT::uint uintX_t;<br>
<br>
public:<br>
@@ -163,8 +159,10 @@ public:<br>
uintX_t getMipsGotOffset(const SymbolBody &B, uintX_t Addend) const;<br>
uintX_t getGlobalDynAddr(const SymbolBody &B) const;<br>
uintX_t getGlobalDynOffset(const SymbolBody &B) const;<br>
- typename Base::Kind getKind() const override { return Base::Got; }<br>
- static bool classof(const Base *B) { return B->getKind() == Base::Got; }<br>
+ Kind getKind() const override { return Got; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == Got;<br>
+ }<br>
<br>
// Returns the symbol which corresponds to the first entry of the global part<br>
// of GOT on MIPS platform. It is required to fill up MIPS-specific dynamic<br>
@@ -192,7 +190,7 @@ private:<br>
uint32_t TlsIndexOff = -1;<br>
uint32_t MipsPageEntries = 0;<br>
// Output sections referenced by MIPS GOT relocations.<br>
- llvm::SmallPtrSet<const OutputSectionBase<ELFT> *, 10> MipsOutSections;<br>
+ llvm::SmallPtrSet<const OutputSectionBase *, 10> MipsOutSections;<br>
llvm::DenseMap<uintX_t, size_t> MipsLocalGotPos;<br>
<br>
// MIPS ABI requires to create unique GOT entry for each Symbol/Addend<br>
@@ -213,10 +211,8 @@ private:<br>
void writeMipsGot(uint8_t *Buf);<br>
};<br>
<br>
-template <class ELFT><br>
-class GotPltSection final : public OutputSectionBase<ELFT> {<br>
+template <class ELFT> class GotPltSection final : public OutputSectionBase {<br>
typedef typename ELFT::uint uintX_t;<br>
- typedef OutputSectionBase<ELFT> Base;<br>
<br>
public:<br>
GotPltSection();<br>
@@ -224,15 +220,16 @@ public:<br>
void writeTo(uint8_t *Buf) override;<br>
void addEntry(SymbolBody &Sym);<br>
bool empty() const;<br>
- typename Base::Kind getKind() const override { return Base::GotPlt; }<br>
- static bool classof(const Base *B) { return B->getKind() == Base::GotPlt; }<br>
+ Kind getKind() const override { return GotPlt; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == GotPlt;<br>
+ }<br>
<br>
private:<br>
std::vector<const SymbolBody *> Entries;<br>
};<br>
<br>
-template <class ELFT> class PltSection final : public OutputSectionBase<ELFT> {<br>
- typedef OutputSectionBase<ELFT> Base;<br>
+template <class ELFT> class PltSection final : public OutputSectionBase {<br>
typedef typename ELFT::uint uintX_t;<br>
<br>
public:<br>
@@ -241,8 +238,10 @@ public:<br>
void writeTo(uint8_t *Buf) override;<br>
void addEntry(SymbolBody &Sym);<br>
bool empty() const { return Entries.empty(); }<br>
- typename Base::Kind getKind() const override { return Base::Plt; }<br>
- static bool classof(const Base *B) { return B->getKind() == Base::Plt; }<br>
+ Kind getKind() const override { return Plt; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == Plt;<br>
+ }<br>
<br>
private:<br>
std::vector<std::pair<const SymbolBody *, unsigned>> Entries;<br>
@@ -258,7 +257,7 @@ public:<br>
: Type(Type), Sym(Sym), InputSec(InputSec), OffsetInSec(OffsetInSec),<br>
UseSymVA(UseSymVA), Addend(Addend) {}<br>
<br>
- DynamicReloc(uint32_t Type, const OutputSectionBase<ELFT> *OutputSec,<br>
+ DynamicReloc(uint32_t Type, const OutputSectionBase *OutputSec,<br>
uintX_t OffsetInSec, bool UseSymVA, SymbolBody *Sym,<br>
uintX_t Addend)<br>
: Type(Type), Sym(Sym), OutputSec(OutputSec), OffsetInSec(OffsetInSec),<br>
@@ -267,14 +266,14 @@ public:<br>
uintX_t getOffset() const;<br>
uintX_t getAddend() const;<br>
uint32_t getSymIndex() const;<br>
- const OutputSectionBase<ELFT> *getOutputSec() const { return OutputSec; }<br>
+ const OutputSectionBase *getOutputSec() const { return OutputSec; }<br>
<br>
uint32_t Type;<br>
<br>
private:<br>
SymbolBody *Sym;<br>
const InputSectionBase<ELFT> *InputSec = nullptr;<br>
- const OutputSectionBase<ELFT> *OutputSec = nullptr;<br>
+ const OutputSectionBase *OutputSec = nullptr;<br>
uintX_t OffsetInSec;<br>
bool UseSymVA;<br>
uintX_t Addend;<br>
@@ -286,8 +285,8 @@ struct SymbolTableEntry {<br>
};<br>
<br>
template <class ELFT><br>
-class SymbolTableSection final : public OutputSectionBase<ELFT> {<br>
- typedef OutputSectionBase<ELFT> Base;<br>
+class SymbolTableSection final : public OutputSectionBase {<br>
+ typedef OutputSectionBase Base;<br>
<br>
public:<br>
typedef typename ELFT::Shdr Elf_Shdr;<br>
@@ -313,7 +312,7 @@ private:<br>
void writeLocalSymbols(uint8_t *&Buf);<br>
void writeGlobalSymbols(uint8_t *Buf);<br>
<br>
- const OutputSectionBase<ELFT> *getOutputSection(SymbolBody *Sym);<br>
+ const OutputSectionBase *getOutputSection(SymbolBody *Sym);<br>
<br>
// A vector of symbols and their string table offsets.<br>
std::vector<SymbolTableEntry> Symbols;<br>
@@ -328,17 +327,18 @@ private:<br>
// The section shall contain an array of Elf_Verdef structures, optionally<br>
// followed by an array of Elf_Verdaux structures.<br>
template <class ELFT><br>
-class VersionDefinitionSection final : public OutputSectionBase<ELFT> {<br>
+class VersionDefinitionSection final : public OutputSectionBase {<br>
typedef typename ELFT::Verdef Elf_Verdef;<br>
typedef typename ELFT::Verdaux Elf_Verdaux;<br>
- typedef OutputSectionBase<ELFT> Base;<br>
<br>
public:<br>
VersionDefinitionSection();<br>
void finalize() override;<br>
void writeTo(uint8_t *Buf) override;<br>
- typename Base::Kind getKind() const override { return Base::VersDef; }<br>
- static bool classof(const Base *B) { return B->getKind() == Base::VersDef; }<br>
+ Kind getKind() const override { return VersDef; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == VersDef;<br>
+ }<br>
<br>
private:<br>
void writeOne(uint8_t *Buf, uint32_t Index, StringRef Name, size_t NameOff);<br>
@@ -353,16 +353,17 @@ private:<br>
// The values 0 and 1 are reserved. All other values are used for versions in<br>
// the own object or in any of the dependencies.<br>
template <class ELFT><br>
-class VersionTableSection final : public OutputSectionBase<ELFT> {<br>
- typedef OutputSectionBase<ELFT> Base;<br>
+class VersionTableSection final : public OutputSectionBase {<br>
typedef typename ELFT::Versym Elf_Versym;<br>
<br>
public:<br>
VersionTableSection();<br>
void finalize() override;<br>
void writeTo(uint8_t *Buf) override;<br>
- typename Base::Kind getKind() const override { return Base::VersTable; }<br>
- static bool classof(const Base *B) { return B->getKind() == Base::VersTable; }<br>
+ Kind getKind() const override { return VersTable; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == VersTable;<br>
+ }<br>
};<br>
<br>
// The .gnu.version_r section defines the version identifiers used by<br>
@@ -371,8 +372,7 @@ public:<br>
// a reference to a linked list of Elf_Vernaux data structures which define the<br>
// mapping from version identifiers to version names.<br>
template <class ELFT><br>
-class VersionNeedSection final : public OutputSectionBase<ELFT> {<br>
- typedef OutputSectionBase<ELFT> Base;<br>
+class VersionNeedSection final : public OutputSectionBase {<br>
typedef typename ELFT::Verneed Elf_Verneed;<br>
typedef typename ELFT::Vernaux Elf_Vernaux;<br>
<br>
@@ -389,16 +389,16 @@ public:<br>
void finalize() override;<br>
void writeTo(uint8_t *Buf) override;<br>
size_t getNeedNum() const { return Needed.size(); }<br>
- typename Base::Kind getKind() const override { return Base::VersNeed; }<br>
- static bool classof(const Base *B) { return B->getKind() == Base::VersNeed; }<br>
+ Kind getKind() const override { return VersNeed; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == VersNeed;<br>
+ }<br>
};<br>
<br>
-template <class ELFT><br>
-class RelocationSection final : public OutputSectionBase<ELFT> {<br>
+template <class ELFT> class RelocationSection final : public OutputSectionBase {<br>
typedef typename ELFT::Rel Elf_Rel;<br>
typedef typename ELFT::Rela Elf_Rela;<br>
typedef typename ELFT::uint uintX_t;<br>
- typedef OutputSectionBase<ELFT> Base;<br>
<br>
public:<br>
RelocationSection(StringRef Name, bool Sort);<br>
@@ -407,9 +407,11 @@ public:<br>
void finalize() override;<br>
void writeTo(uint8_t *Buf) override;<br>
bool hasRelocs() const { return !Relocs.empty(); }<br>
- typename Base::Kind getKind() const override { return Base::Reloc; }<br>
+ Kind getKind() const override { return Reloc; }<br>
size_t getRelativeRelocCount() const { return NumRelativeRelocs; }<br>
- static bool classof(const Base *B) { return B->getKind() == Base::Reloc; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == Reloc;<br>
+ }<br>
<br>
private:<br>
bool Sort;<br>
@@ -417,9 +419,7 @@ private:<br>
std::vector<DynamicReloc<ELFT<wbr>>> Relocs;<br>
};<br>
<br>
-template <class ELFT><br>
-class OutputSection final : public OutputSectionBase<ELFT> {<br>
- typedef OutputSectionBase<ELFT> Base;<br>
+template <class ELFT> class OutputSection final : public OutputSectionBase {<br>
<br>
public:<br>
typedef typename ELFT::Shdr Elf_Shdr;<br>
@@ -428,33 +428,36 @@ public:<br>
typedef typename ELFT::Rela Elf_Rela;<br>
typedef typename ELFT::uint uintX_t;<br>
OutputSection(StringRef Name, uint32_t Type, uintX_t Flags);<br>
- void addSection(InputSectionBase<EL<wbr>FT> *C) override;<br>
+ void addSection(InputSectionData *C) override;<br>
void sortInitFini();<br>
void sortCtorsDtors();<br>
void writeTo(uint8_t *Buf) override;<br>
void finalize() override;<br>
void assignOffsets() override;<br>
- typename Base::Kind getKind() const override { return Base::Regular; }<br>
- static bool classof(const Base *B) { return B->getKind() == Base::Regular; }<br>
+ Kind getKind() const override { return Regular; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == Regular;<br>
+ }<br>
std::vector<InputSection<ELFT<wbr>> *> Sections;<br>
};<br>
<br>
template <class ELFT><br>
-class MergeOutputSection final : public OutputSectionBase<ELFT> {<br>
+class MergeOutputSection final : public OutputSectionBase {<br>
typedef typename ELFT::uint uintX_t;<br>
- typedef OutputSectionBase<ELFT> Base;<br>
<br>
public:<br>
MergeOutputSection(StringRef Name, uint32_t Type, uintX_t Flags,<br>
uintX_t Alignment);<br>
- void addSection(InputSectionBase<EL<wbr>FT> *S) override;<br>
+ void addSection(InputSectionData *S) override;<br>
void writeTo(uint8_t *Buf) override;<br>
unsigned getOffset(llvm::CachedHashStri<wbr>ngRef Val);<br>
void finalize() override;<br>
void finalizePieces() override;<br>
bool shouldTailMerge() const;<br>
- typename Base::Kind getKind() const override { return Base::Merge; }<br>
- static bool classof(const Base *B) { return B->getKind() == Base::Merge; }<br>
+ Kind getKind() const override { return Merge; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == Merge;<br>
+ }<br>
<br>
private:<br>
llvm::StringTableBuilder Builder;<br>
@@ -467,13 +470,11 @@ struct CieRecord {<br>
};<br>
<br>
// Output section for .eh_frame.<br>
-template <class ELFT><br>
-class EhOutputSection final : public OutputSectionBase<ELFT> {<br>
+template <class ELFT> class EhOutputSection final : public OutputSectionBase {<br>
typedef typename ELFT::uint uintX_t;<br>
typedef typename ELFT::Shdr Elf_Shdr;<br>
typedef typename ELFT::Rel Elf_Rel;<br>
typedef typename ELFT::Rela Elf_Rela;<br>
- typedef OutputSectionBase<ELFT> Base;<br>
<br>
public:<br>
EhOutputSection();<br>
@@ -481,9 +482,11 @@ public:<br>
void finalize() override;<br>
bool empty() const { return Sections.empty(); }<br>
<br>
- void addSection(InputSectionBase<EL<wbr>FT> *S) override;<br>
- typename Base::Kind getKind() const override { return Base::EHFrame; }<br>
- static bool classof(const Base *B) { return B->getKind() == Base::EHFrame; }<br>
+ void addSection(InputSectionData *S) override;<br>
+ Kind getKind() const override { return EHFrame; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == EHFrame;<br>
+ }<br>
<br>
size_t NumFdes = 0;<br>
<br>
@@ -509,8 +512,7 @@ private:<br>
};<br>
<br>
template <class ELFT><br>
-class StringTableSection final : public OutputSectionBase<ELFT> {<br>
- typedef OutputSectionBase<ELFT> Base;<br>
+class StringTableSection final : public OutputSectionBase {<br>
<br>
public:<br>
typedef typename ELFT::uint uintX_t;<br>
@@ -518,8 +520,10 @@ public:<br>
unsigned addString(StringRef S, bool HashIt = true);<br>
void writeTo(uint8_t *Buf) override;<br>
bool isDynamic() const { return Dynamic; }<br>
- typename Base::Kind getKind() const override { return Base::StrTable; }<br>
- static bool classof(const Base *B) { return B->getKind() == Base::StrTable; }<br>
+ Kind getKind() const override { return StrTable; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == StrTable;<br>
+ }<br>
<br>
private:<br>
const bool Dynamic;<br>
@@ -527,27 +531,26 @@ private:<br>
std::vector<StringRef> Strings;<br>
};<br>
<br>
-template <class ELFT><br>
-class HashTableSection final : public OutputSectionBase<ELFT> {<br>
+template <class ELFT> class HashTableSection final : public OutputSectionBase {<br>
typedef typename ELFT::Word Elf_Word;<br>
- typedef OutputSectionBase<ELFT> Base;<br>
<br>
public:<br>
HashTableSection();<br>
void finalize() override;<br>
void writeTo(uint8_t *Buf) override;<br>
- typename Base::Kind getKind() const override { return Base::HashTable; }<br>
- static bool classof(const Base *B) { return B->getKind() == Base::HashTable; }<br>
+ Kind getKind() const override { return HashTable; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == HashTable;<br>
+ }<br>
};<br>
<br>
// Outputs GNU Hash section. For detailed explanation see:<br>
// <a href="https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections" rel="noreferrer" target="_blank">https://blogs.oracle.com/ali/e<wbr>ntry/gnu_hash_elf_sections</a><br>
template <class ELFT><br>
-class GnuHashTableSection final : public OutputSectionBase<ELFT> {<br>
+class GnuHashTableSection final : public OutputSectionBase {<br>
typedef typename ELFT::Off Elf_Off;<br>
typedef typename ELFT::Word Elf_Word;<br>
typedef typename ELFT::uint uintX_t;<br>
- typedef OutputSectionBase<ELFT> Base;<br>
<br>
public:<br>
GnuHashTableSection();<br>
@@ -557,9 +560,9 @@ public:<br>
// Adds symbols to the hash table.<br>
// Sorts the input to satisfy GNU hash section requirements.<br>
void addSymbols(std::vector<SymbolT<wbr>ableEntry> &Symbols);<br>
- typename Base::Kind getKind() const override { return Base::GnuHashTable; }<br>
- static bool classof(const Base *B) {<br>
- return B->getKind() == Base::GnuHashTable;<br>
+ Kind getKind() const override { return GnuHashTable; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == GnuHashTable;<br>
}<br>
<br>
private:<br>
@@ -583,9 +586,7 @@ private:<br>
unsigned Shift2;<br>
};<br>
<br>
-template <class ELFT><br>
-class DynamicSection final : public OutputSectionBase<ELFT> {<br>
- typedef OutputSectionBase<ELFT> Base;<br>
+template <class ELFT> class DynamicSection final : public OutputSectionBase {<br>
typedef typename ELFT::Dyn Elf_Dyn;<br>
typedef typename ELFT::Rel Elf_Rel;<br>
typedef typename ELFT::Rela Elf_Rela;<br>
@@ -600,12 +601,12 @@ class DynamicSection final : public Outp<br>
struct Entry {<br>
int32_t Tag;<br>
union {<br>
- OutputSectionBase<ELFT> *OutSec;<br>
+ OutputSectionBase *OutSec;<br>
uint64_t Val;<br>
const SymbolBody *Sym;<br>
};<br>
enum KindT { SecAddr, SecSize, SymAddr, PlainInt } Kind;<br>
- Entry(int32_t Tag, OutputSectionBase<ELFT> *OutSec, KindT Kind = SecAddr)<br>
+ Entry(int32_t Tag, OutputSectionBase *OutSec, KindT Kind = SecAddr)<br>
: Tag(Tag), OutSec(OutSec), Kind(Kind) {}<br>
Entry(int32_t Tag, uint64_t Val) : Tag(Tag), Val(Val), Kind(PlainInt) {}<br>
Entry(int32_t Tag, const SymbolBody *Sym)<br>
@@ -621,8 +622,10 @@ public:<br>
DynamicSection();<br>
void finalize() override;<br>
void writeTo(uint8_t *Buf) override;<br>
- typename Base::Kind getKind() const override { return Base::Dynamic; }<br>
- static bool classof(const Base *B) { return B->getKind() == Base::Dynamic; }<br>
+ Kind getKind() const override { return Dynamic; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == Dynamic;<br>
+ }<br>
<br>
private:<br>
void addEntries();<br>
@@ -638,19 +641,17 @@ private:<br>
// Detailed info about internals can be found in Ian Lance Taylor's blog:<br>
// <a href="http://www.airs.com/blog/archives/460" rel="noreferrer" target="_blank">http://www.airs.com/blog/archi<wbr>ves/460</a> (".eh_frame")<br>
// <a href="http://www.airs.com/blog/archives/462" rel="noreferrer" target="_blank">http://www.airs.com/blog/archi<wbr>ves/462</a> (".eh_frame_hdr")<br>
-template <class ELFT><br>
-class EhFrameHeader final : public OutputSectionBase<ELFT> {<br>
+template <class ELFT> class EhFrameHeader final : public OutputSectionBase {<br>
typedef typename ELFT::uint uintX_t;<br>
- typedef OutputSectionBase<ELFT> Base;<br>
<br>
public:<br>
EhFrameHeader();<br>
void finalize() override;<br>
void writeTo(uint8_t *Buf) override;<br>
void addFde(uint32_t Pc, uint32_t FdeVA);<br>
- typename Base::Kind getKind() const override { return Base::EHFrameHdr; }<br>
- static bool classof(const Base *B) {<br>
- return B->getKind() == Base::EHFrameHdr;<br>
+ Kind getKind() const override { return EHFrameHdr; }<br>
+ static bool classof(const OutputSectionBase *B) {<br>
+ return B->getKind() == EHFrameHdr;<br>
}<br>
<br>
private:<br>
@@ -680,7 +681,7 @@ template <class ELFT> struct Out {<br>
static HashTableSection<ELFT> *HashTab;<br>
static OutputSection<ELFT> *Bss;<br>
static OutputSection<ELFT> *MipsRldMap;<br>
- static OutputSectionBase<ELFT> *Opd;<br>
+ static OutputSectionBase *Opd;<br>
static uint8_t *OpdBuf;<br>
static PltSection<ELFT> *Plt;<br>
static RelocationSection<ELFT> *RelaDyn;<br>
@@ -694,12 +695,12 @@ template <class ELFT> struct Out {<br>
static VersionTableSection<ELFT> *VerSym;<br>
static VersionNeedSection<ELFT> *VerNeed;<br>
static Elf_Phdr *TlsPhdr;<br>
- static OutputSectionBase<ELFT> *DebugInfo;<br>
- static OutputSectionBase<ELFT> *ElfHeader;<br>
- static OutputSectionBase<ELFT> *ProgramHeaders;<br>
- static OutputSectionBase<ELFT> *PreinitArray;<br>
- static OutputSectionBase<ELFT> *InitArray;<br>
- static OutputSectionBase<ELFT> *FiniArray;<br>
+ static OutputSectionBase *DebugInfo;<br>
+ static OutputSectionBase *ElfHeader;<br>
+ static OutputSectionBase *ProgramHeaders;<br>
+ static OutputSectionBase *PreinitArray;<br>
+ static OutputSectionBase *InitArray;<br>
+ static OutputSectionBase *FiniArray;<br>
};<br>
<br>
template <bool Is64Bits> struct SectionKey {<br>
@@ -720,13 +721,13 @@ template <class ELFT> class OutputSectio<br>
typedef typename elf::SectionKey<ELFT::Is64Bits<wbr>> Key;<br>
<br>
public:<br>
- std::pair<OutputSectionBase<EL<wbr>FT> *, bool> create(InputSectionBase<ELFT> *C,<br>
- StringRef OutsecName);<br>
- std::pair<OutputSectionBase<EL<wbr>FT> *, bool><br>
+ std::pair<OutputSectionBase *, bool> create(InputSectionBase<ELFT> *C,<br>
+ StringRef OutsecName);<br>
+ std::pair<OutputSectionBase *, bool><br>
create(const SectionKey<ELFT::Is64Bits> &Key, InputSectionBase<ELFT> *C);<br>
<br>
private:<br>
- llvm::SmallDenseMap<Key, OutputSectionBase<ELFT> *> Map;<br>
+ llvm::SmallDenseMap<Key, OutputSectionBase *> Map;<br>
};<br>
<br>
template <class ELFT> uint64_t getHeaderSize() {<br>
@@ -746,7 +747,7 @@ template <class ELFT> GotSection<ELFT> *<br>
template <class ELFT> HashTableSection<ELFT> *Out<ELFT>::HashTab;<br>
template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Bss;<br>
template <class ELFT> OutputSection<ELFT> *Out<ELFT>::MipsRldMap;<br>
-template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::Opd;<br>
+template <class ELFT> OutputSectionBase *Out<ELFT>::Opd;<br>
template <class ELFT> uint8_t *Out<ELFT>::OpdBuf;<br>
template <class ELFT> PltSection<ELFT> *Out<ELFT>::Plt;<br>
template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaDyn;<br>
@@ -760,12 +761,12 @@ template <class ELFT> VersionDefinitionS<br>
template <class ELFT> VersionTableSection<ELFT> *Out<ELFT>::VerSym;<br>
template <class ELFT> VersionNeedSection<ELFT> *Out<ELFT>::VerNeed;<br>
template <class ELFT> typename ELFT::Phdr *Out<ELFT>::TlsPhdr;<br>
-template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::DebugInfo;<br>
-template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ElfHeader;<br>
-template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ProgramHeaders;<br>
-template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::PreinitArray;<br>
-template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::InitArray;<br>
-template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::FiniArray;<br>
+template <class ELFT> OutputSectionBase *Out<ELFT>::DebugInfo;<br>
+template <class ELFT> OutputSectionBase *Out<ELFT>::ElfHeader;<br>
+template <class ELFT> OutputSectionBase *Out<ELFT>::ProgramHeaders;<br>
+template <class ELFT> OutputSectionBase *Out<ELFT>::PreinitArray;<br>
+template <class ELFT> OutputSectionBase *Out<ELFT>::InitArray;<br>
+template <class ELFT> OutputSectionBase *Out<ELFT>::FiniArray;<br>
} // namespace elf<br>
} // namespace lld<br>
<br>
<br>
Modified: lld/trunk/ELF/SymbolTable.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=286414&r1=286413&r2=286414&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/SymbolTabl<wbr>e.cpp?rev=286414&r1=286413&r2=<wbr>286414&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/SymbolTable.cpp (original)<br>
+++ lld/trunk/ELF/SymbolTable.cpp Wed Nov 9 17:23:45 2016<br>
@@ -429,8 +429,7 @@ Symbol *SymbolTable<ELFT>::addRegular<wbr>(St<br>
}<br>
<br>
template <typename ELFT><br>
-Symbol *SymbolTable<ELFT>::addSynthet<wbr>ic(StringRef N,<br>
- OutputSectionBase<ELFT> *Section,<br>
+Symbol *SymbolTable<ELFT>::addSynthet<wbr>ic(StringRef N, OutputSectionBase *Section,<br>
uintX_t Value, uint8_t StOther) {<br>
Symbol *S;<br>
bool WasInserted;<br>
<br>
Modified: lld/trunk/ELF/SymbolTable.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=286414&r1=286413&r2=286414&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/SymbolTabl<wbr>e.h?rev=286414&r1=286413&r2=28<wbr>6414&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/SymbolTable.h (original)<br>
+++ lld/trunk/ELF/SymbolTable.h Wed Nov 9 17:23:45 2016<br>
@@ -19,7 +19,7 @@<br>
namespace lld {<br>
namespace elf {<br>
class Lazy;<br>
-template <class ELFT> class OutputSectionBase;<br>
+class OutputSectionBase;<br>
struct Symbol;<br>
<br>
typedef llvm::CachedHashStringRef SymName;<br>
@@ -67,8 +67,8 @@ public:<br>
Symbol *addRegular(StringRef Name, uint8_t StOther,<br>
InputSectionBase<ELFT> *Section, uint8_t Binding,<br>
uint8_t Type, uintX_t Value);<br>
- Symbol *addSynthetic(StringRef N, OutputSectionBase<ELFT> *Section,<br>
- uintX_t Value, uint8_t StOther);<br>
+ Symbol *addSynthetic(StringRef N, OutputSectionBase *Section, uintX_t Value,<br>
+ uint8_t StOther);<br>
void addShared(SharedFile<ELFT> *F, StringRef Name, const Elf_Sym &Sym,<br>
const typename ELFT::Verdef *Verdef);<br>
<br>
<br>
Modified: lld/trunk/ELF/Symbols.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=286414&r1=286413&r2=286414&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/Symbols.cp<wbr>p?rev=286414&r1=286413&r2=2864<wbr>14&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Symbols.cpp (original)<br>
+++ lld/trunk/ELF/Symbols.cpp Wed Nov 9 17:23:45 2016<br>
@@ -33,7 +33,7 @@ static typename ELFT::uint getSymVA(cons<br>
switch (Body.kind()) {<br>
case SymbolBody::DefinedSyntheticKi<wbr>nd: {<br>
auto &D = cast<DefinedSynthetic<ELFT>>(B<wbr>ody);<br>
- const OutputSectionBase<ELFT> *Sec = D.Section;<br>
+ const OutputSectionBase *Sec = D.Section;<br>
if (!Sec)<br>
return D.Value;<br>
if (D.Value == DefinedSynthetic<ELFT>::Sectio<wbr>nEnd)<br>
@@ -216,7 +216,7 @@ Undefined::Undefined(uint32_t NameOffset<br>
<br>
template <typename ELFT><br>
DefinedSynthetic<ELFT>::Defin<wbr>edSynthetic(StringRef N, uintX_t Value,<br>
- OutputSectionBase<ELFT> *Section)<br>
+ OutputSectionBase *Section)<br>
: Defined(SymbolBody::DefinedSyn<wbr>theticKind, N, STV_HIDDEN, 0 /* Type */),<br>
Value(Value), Section(Section) {}<br>
<br>
<br>
Modified: lld/trunk/ELF/Symbols.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=286414&r1=286413&r2=286414&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/Symbols.h?<wbr>rev=286414&r1=286413&r2=286414<wbr>&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Symbols.h (original)<br>
+++ lld/trunk/ELF/Symbols.h Wed Nov 9 17:23:45 2016<br>
@@ -31,7 +31,7 @@ class LazyObjectFile;<br>
class SymbolBody;<br>
template <class ELFT> class ObjectFile;<br>
template <class ELFT> class OutputSection;<br>
-template <class ELFT> class OutputSectionBase;<br>
+class OutputSectionBase;<br>
template <class ELFT> class SharedFile;<br>
<br>
struct Symbol;<br>
@@ -249,8 +249,7 @@ InputSectionBase<ELFT> *DefinedRegular<E<br>
template <class ELFT> class DefinedSynthetic : public Defined {<br>
public:<br>
typedef typename ELFT::uint uintX_t;<br>
- DefinedSynthetic(StringRef N, uintX_t Value,<br>
- OutputSectionBase<ELFT> *Section);<br>
+ DefinedSynthetic(StringRef N, uintX_t Value, OutputSectionBase *Section);<br>
<br>
static bool classof(const SymbolBody *S) {<br>
return S->kind() == SymbolBody::DefinedSyntheticKi<wbr>nd;<br>
@@ -261,7 +260,7 @@ public:<br>
static const uintX_t SectionEnd = uintX_t(-1);<br>
<br>
uintX_t Value;<br>
- const OutputSectionBase<ELFT> *Section;<br>
+ const OutputSectionBase *Section;<br>
};<br>
<br>
class Undefined : public SymbolBody {<br>
<br>
Modified: lld/trunk/ELF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=286414&r1=286413&r2=286414&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/Writer.cpp<wbr>?rev=286414&r1=286413&r2=28641<wbr>4&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Writer.cpp (original)<br>
+++ lld/trunk/ELF/Writer.cpp Wed Nov 9 17:23:45 2016<br>
@@ -77,13 +77,13 @@ private:<br>
<br>
std::unique_ptr<FileOutputBuf<wbr>fer> Buffer;<br>
<br>
- std::vector<OutputSectionBase<<wbr>ELFT> *> OutputSections;<br>
+ std::vector<OutputSectionBase *> OutputSections;<br>
OutputSectionFactory<ELFT> Factory;<br>
<br>
void addRelIpltSymbols();<br>
void addStartEndSymbols();<br>
- void addStartStopSymbols(OutputSect<wbr>ionBase<ELFT> *Sec);<br>
- OutputSectionBase<ELFT> *findSection(StringRef Name);<br>
+ void addStartStopSymbols(OutputSect<wbr>ionBase *Sec);<br>
+ OutputSectionBase *findSection(StringRef Name);<br>
<br>
std::vector<Phdr> Phdrs;<br>
<br>
@@ -221,9 +221,9 @@ template <class ELFT> void Writer<ELFT>:<br>
Out<ELFT>::VerSym = make<VersionTableSection<ELFT><wbr>>();<br>
Out<ELFT>::VerNeed = make<VersionNeedSection<ELFT>><wbr>();<br>
<br>
- Out<ELFT>::ElfHeader = make<OutputSectionBase<ELFT>>(<wbr>"", 0, SHF_ALLOC);<br>
+ Out<ELFT>::ElfHeader = make<OutputSectionBase>("", 0, SHF_ALLOC);<br>
Out<ELFT>::ElfHeader->Size = sizeof(Elf_Ehdr);<br>
- Out<ELFT>::ProgramHeaders = make<OutputSectionBase<ELFT>>(<wbr>"", 0, SHF_ALLOC);<br>
+ Out<ELFT>::ProgramHeaders = make<OutputSectionBase>("", 0, SHF_ALLOC);<br>
Out<ELFT>::ProgramHeaders->up<wbr>dateAlignment(sizeof(uintX_t))<wbr>;<br>
<br>
if (needsInterpSection<ELFT>()) {<br>
@@ -411,11 +411,10 @@ static int getPPC64SectionRank(StringRef<br>
.Default(1);<br>
}<br>
<br>
-template <class ELFT><br>
-bool elf::isRelroSection(const OutputSectionBase<ELFT> *Sec) {<br>
+template <class ELFT> bool elf::isRelroSection(const OutputSectionBase *Sec) {<br>
if (!Config->ZRelro)<br>
return false;<br>
- typename ELFT::uint Flags = Sec->Flags;<br>
+ uint64_t Flags = Sec->Flags;<br>
if (!(Flags & SHF_ALLOC) || !(Flags & SHF_WRITE))<br>
return false;<br>
if (Flags & SHF_TLS)<br>
@@ -434,8 +433,8 @@ bool elf::isRelroSection(const OutputSec<br>
}<br>
<br>
template <class ELFT><br>
-static bool compareSectionsNonScript(const OutputSectionBase<ELFT> *A,<br>
- const OutputSectionBase<ELFT> *B) {<br>
+static bool compareSectionsNonScript(const OutputSectionBase *A,<br>
+ const OutputSectionBase *B) {<br>
// Put .interp first because some loaders want to see that section<br>
// on the first page of the executable file when loaded into memory.<br>
bool AIsInterp = A->getName() == ".interp";<br>
@@ -496,8 +495,8 @@ static bool compareSectionsNonScript(con<br>
return BIsNoBits;<br>
<br>
// We place RelRo section before plain r/w ones.<br>
- bool AIsRelRo = isRelroSection(A);<br>
- bool BIsRelRo = isRelroSection(B);<br>
+ bool AIsRelRo = isRelroSection<ELFT>(A);<br>
+ bool BIsRelRo = isRelroSection<ELFT>(B);<br>
if (AIsRelRo != BIsRelRo)<br>
return AIsRelRo;<br>
<br>
@@ -512,8 +511,8 @@ static bool compareSectionsNonScript(con<br>
<br>
// Output section ordering is determined by this function.<br>
template <class ELFT><br>
-static bool compareSections(const OutputSectionBase<ELFT> *A,<br>
- const OutputSectionBase<ELFT> *B) {<br>
+static bool compareSections(const OutputSectionBase *A,<br>
+ const OutputSectionBase *B) {<br>
// For now, put sections mentioned in a linker script first.<br>
int AIndex = Script<ELFT>::X->getSectionInd<wbr>ex(A->getName());<br>
int BIndex = Script<ELFT>::X->getSectionInd<wbr>ex(B->getName());<br>
@@ -525,7 +524,7 @@ static bool compareSections(const Output<br>
if (AInScript)<br>
return AIndex < BIndex;<br>
<br>
- return compareSectionsNonScript(A, B);<br>
+ return compareSectionsNonScript<ELFT><wbr>(A, B);<br>
}<br>
<br>
// Program header entry<br>
@@ -535,7 +534,7 @@ PhdrEntry<ELFT>::PhdrEntry(uns<wbr>igned Type<br>
H.p_flags = Flags;<br>
}<br>
<br>
-template <class ELFT> void PhdrEntry<ELFT>::add(OutputSec<wbr>tionBase<ELFT> *Sec) {<br>
+template <class ELFT> void PhdrEntry<ELFT>::add(OutputSec<wbr>tionBase *Sec) {<br>
Last = Sec;<br>
if (!First)<br>
First = Sec;<br>
@@ -545,9 +544,9 @@ template <class ELFT> void PhdrEntry<ELF<br>
}<br>
<br>
template <class ELFT><br>
-static Symbol *<br>
-addOptionalSynthetic(StringRe<wbr>f Name, OutputSectionBase<ELFT> *Sec,<br>
- typename ELFT::uint Val, uint8_t StOther = STV_HIDDEN) {<br>
+static Symbol *addOptionalSynthetic(StringRe<wbr>f Name, OutputSectionBase *Sec,<br>
+ typename ELFT::uint Val,<br>
+ uint8_t StOther = STV_HIDDEN) {<br>
SymbolBody *S = Symtab<ELFT>::X->find(Name);<br>
if (!S)<br>
return nullptr;<br>
@@ -566,11 +565,11 @@ template <class ELFT> void Writer<ELFT>:<br>
if (Out<ELFT>::DynSymTab || !Out<ELFT>::RelaPlt)<br>
return;<br>
StringRef S = Config->Rela ? "__rela_iplt_start" : "__rel_iplt_start";<br>
- addOptionalSynthetic(S, Out<ELFT>::RelaPlt, 0);<br>
+ addOptionalSynthetic<ELFT>(S, Out<ELFT>::RelaPlt, 0);<br>
<br>
S = Config->Rela ? "__rela_iplt_end" : "__rel_iplt_end";<br>
- addOptionalSynthetic(S, Out<ELFT>::RelaPlt,<br>
- DefinedSynthetic<ELFT>::Secti<wbr>onEnd);<br>
+ addOptionalSynthetic<ELFT>(S, Out<ELFT>::RelaPlt,<br>
+ DefinedSynthetic<ELFT>::Secti<wbr>onEnd);<br>
}<br>
<br>
// The linker is expected to define some symbols depending on<br>
@@ -587,7 +586,7 @@ template <class ELFT> void Writer<ELFT>:<br>
// On MIPS O32 ABI, _gp_disp is a magic symbol designates offset between<br>
// start of function and 'gp' pointer into GOT.<br>
Symbol *Sym =<br>
- addOptionalSynthetic("_gp_disp<wbr>", Out<ELFT>::Got, MipsGPOffset);<br>
+ addOptionalSynthetic<ELFT>("_g<wbr>p_disp", Out<ELFT>::Got, MipsGPOffset);<br>
if (Sym)<br>
ElfSym<ELFT>::MipsGpDisp = Sym->body();<br>
<br>
@@ -595,7 +594,7 @@ template <class ELFT> void Writer<ELFT>:<br>
// pointer. This symbol is used in the code generated by .cpload pseudo-op<br>
// in case of using -mno-shared option.<br>
// <a href="https://sourceware.org/ml/binutils/2004-12/msg00094.html" rel="noreferrer" target="_blank">https://sourceware.org/ml/binu<wbr>tils/2004-12/msg00094.html</a><br>
- addOptionalSynthetic("__gnu_lo<wbr>cal_gp", Out<ELFT>::Got, MipsGPOffset);<br>
+ addOptionalSynthetic<ELFT>("__<wbr>gnu_local_gp", Out<ELFT>::Got, MipsGPOffset);<br>
}<br>
<br>
// In the assembly for 32 bit x86 the _GLOBAL_OFFSET_TABLE_ symbol<br>
@@ -649,13 +648,13 @@ template <class ELFT> void Writer<ELFT>:<br>
<br>
// Sort input sections by section name suffixes for<br>
// __attribute__((init_priority(N<wbr>))).<br>
-template <class ELFT> static void sortInitFini(OutputSectionBase<wbr><ELFT> *S) {<br>
+template <class ELFT> static void sortInitFini(OutputSectionBase *S) {<br>
if (S)<br>
reinterpret_cast<OutputSectio<wbr>n<ELFT> *>(S)->sortInitFini();<br>
}<br>
<br>
// Sort input sections by the special rule for .ctors and .dtors.<br>
-template <class ELFT> static void sortCtorsDtors(OutputSectionBa<wbr>se<ELFT> *S) {<br>
+template <class ELFT> static void sortCtorsDtors(OutputSectionBa<wbr>se *S) {<br>
if (S)<br>
reinterpret_cast<OutputSectio<wbr>n<ELFT> *>(S)->sortCtorsDtors();<br>
}<br>
@@ -691,7 +690,7 @@ void Writer<ELFT>::addInputSec(Inpu<wbr>tSect<br>
reportDiscarded(IS);<br>
return;<br>
}<br>
- OutputSectionBase<ELFT> *Sec;<br>
+ OutputSectionBase *Sec;<br>
bool IsNew;<br>
StringRef OutsecName = getOutputSectionName(IS->Name)<wbr>;<br>
std::tie(Sec, IsNew) = Factory.create(IS, OutsecName);<br>
@@ -704,18 +703,18 @@ template <class ELFT> void Writer<ELFT>:<br>
for (InputSectionBase<ELFT> *IS : Symtab<ELFT>::X->Sections)<br>
addInputSec(IS);<br>
<br>
- sortInitFini(findSection(".ini<wbr>t_array"));<br>
- sortInitFini(findSection(".fin<wbr>i_array"));<br>
- sortCtorsDtors(findSection(".c<wbr>tors"));<br>
- sortCtorsDtors(findSection(".d<wbr>tors"));<br>
+ sortInitFini<ELFT>(findSection<wbr>(".init_array"));<br>
+ sortInitFini<ELFT>(findSection<wbr>(".fini_array"));<br>
+ sortCtorsDtors<ELFT>(findSecti<wbr>on(".ctors"));<br>
+ sortCtorsDtors<ELFT>(findSecti<wbr>on(".dtors"));<br>
<br>
- for (OutputSectionBase<ELFT> *Sec : OutputSections)<br>
+ for (OutputSectionBase *Sec : OutputSections)<br>
Sec->assignOffsets();<br>
}<br>
<br>
template <class ELFT><br>
-static bool canSharePtLoad(const OutputSectionBase<ELFT> &S1,<br>
- const OutputSectionBase<ELFT> &S2) {<br>
+static bool canSharePtLoad(const OutputSectionBase &S1,<br>
+ const OutputSectionBase &S2) {<br>
if (!(S1.Flags & SHF_ALLOC) || !(S2.Flags & SHF_ALLOC))<br>
return false;<br>
<br>
@@ -767,15 +766,14 @@ template <class ELFT> void Writer<ELFT>:<br>
auto I = OutputSections.begin();<br>
auto E = OutputSections.end();<br>
auto NonScriptI =<br>
- std::find_if(OutputSections.be<wbr>gin(), E, [](OutputSectionBase<ELFT> *S) {<br>
+ std::find_if(OutputSections.be<wbr>gin(), E, [](OutputSectionBase *S) {<br>
return Script<ELFT>::X->getSectionInd<wbr>ex(S->getName()) == INT_MAX;<br>
});<br>
while (NonScriptI != E) {<br>
- auto BestPos =<br>
- std::max_element(I, NonScriptI, [&](OutputSectionBase<ELFT> *&A,<br>
- OutputSectionBase<ELFT> *&B) {<br>
- bool ACanSharePtLoad = canSharePtLoad(**NonScriptI, *A);<br>
- bool BCanSharePtLoad = canSharePtLoad(**NonScriptI, *B);<br>
+ auto BestPos = std::max_element(<br>
+ I, NonScriptI, [&](OutputSectionBase *&A, OutputSectionBase *&B) {<br>
+ bool ACanSharePtLoad = canSharePtLoad<ELFT>(**NonScri<wbr>ptI, *A);<br>
+ bool BCanSharePtLoad = canSharePtLoad<ELFT>(**NonScri<wbr>ptI, *B);<br>
if (ACanSharePtLoad != BCanSharePtLoad)<br>
return BCanSharePtLoad;<br>
<br>
@@ -812,7 +810,7 @@ template <class ELFT> void Writer<ELFT>:<br>
// addresses of each section by section name. Add such symbols.<br>
if (!Config->Relocatable) {<br>
addStartEndSymbols();<br>
- for (OutputSectionBase<ELFT> *Sec : OutputSections)<br>
+ for (OutputSectionBase *Sec : OutputSections)<br>
addStartStopSymbols(Sec);<br>
}<br>
<br>
@@ -865,7 +863,7 @@ template <class ELFT> void Writer<ELFT>:<br>
sortSections();<br>
<br>
unsigned I = 1;<br>
- for (OutputSectionBase<ELFT> *Sec : OutputSections) {<br>
+ for (OutputSectionBase *Sec : OutputSections) {<br>
Sec->SectionIndex = I++;<br>
Sec->ShName = Out<ELFT>::ShStrTab->addString<wbr>(Sec->getName());<br>
}<br>
@@ -878,7 +876,7 @@ template <class ELFT> void Writer<ELFT>:<br>
// Fill other section headers. The dynamic table is finalized<br>
// at the end because some tags like RELSZ depend on result<br>
// of finalizing other sections.<br>
- for (OutputSectionBase<ELFT> *Sec : OutputSections)<br>
+ for (OutputSectionBase *Sec : OutputSections)<br>
if (Sec != Out<ELFT>::Dynamic)<br>
Sec->finalize();<br>
<br>
@@ -887,7 +885,7 @@ template <class ELFT> void Writer<ELFT>:<br>
<br>
// Now that all output offsets are fixed. Finalize mergeable sections<br>
// to fix their maps from input offsets to output offsets.<br>
- for (OutputSectionBase<ELFT> *Sec : OutputSections)<br>
+ for (OutputSectionBase *Sec : OutputSections)<br>
Sec->finalizePieces();<br>
}<br>
<br>
@@ -907,7 +905,7 @@ template <class ELFT> bool Writer<ELFT>:<br>
<br>
// This function add Out<ELFT>::* sections to OutputSections.<br>
template <class ELFT> void Writer<ELFT>::addPredefinedSec<wbr>tions() {<br>
- auto Add = [&](OutputSectionBase<ELFT> *OS) {<br>
+ auto Add = [&](OutputSectionBase *OS) {<br>
if (OS)<br>
OutputSections.push_back(OS);<br>
};<br>
@@ -958,11 +956,11 @@ template <class ELFT> void Writer<ELFT>:<br>
// The linker is expected to define SECNAME_start and SECNAME_end<br>
// symbols for a few sections. This function defines them.<br>
template <class ELFT> void Writer<ELFT>::addStartEndSymbo<wbr>ls() {<br>
- auto Define = [&](StringRef Start, StringRef End,<br>
- OutputSectionBase<ELFT> *OS) {<br>
+ auto Define = [&](StringRef Start, StringRef End, OutputSectionBase *OS) {<br>
// These symbols resolve to the image base if the section does not exist.<br>
- addOptionalSynthetic(Start, OS, 0);<br>
- addOptionalSynthetic(End, OS, OS ? DefinedSynthetic<ELFT>::Sectio<wbr>nEnd : 0);<br>
+ addOptionalSynthetic<ELFT>(Sta<wbr>rt, OS, 0);<br>
+ addOptionalSynthetic<ELFT>(End<wbr>, OS,<br>
+ OS ? DefinedSynthetic<ELFT>::Sectio<wbr>nEnd : 0);<br>
};<br>
<br>
Define("__preinit_array_start<wbr>", "__preinit_array_end",<br>
@@ -970,7 +968,7 @@ template <class ELFT> void Writer<ELFT>:<br>
Define("__init_array_start", "__init_array_end", Out<ELFT>::InitArray);<br>
Define("__fini_array_start", "__fini_array_end", Out<ELFT>::FiniArray);<br>
<br>
- if (OutputSectionBase<ELFT> *Sec = findSection(".ARM.exidx"))<br>
+ if (OutputSectionBase *Sec = findSection(".ARM.exidx"))<br>
Define("__exidx_start", "__exidx_end", Sec);<br>
}<br>
<br>
@@ -980,24 +978,24 @@ template <class ELFT> void Writer<ELFT>:<br>
// respectively. This is not requested by the ELF standard, but GNU ld and<br>
// gold provide the feature, and used by many programs.<br>
template <class ELFT><br>
-void Writer<ELFT>::addStartStopSymb<wbr>ols(OutputSectionBase<ELFT> *Sec) {<br>
+void Writer<ELFT>::addStartStopSymb<wbr>ols(OutputSectionBase *Sec) {<br>
StringRef S = Sec->getName();<br>
if (!isValidCIdentifier(S))<br>
return;<br>
- addOptionalSynthetic(Saver.sav<wbr>e("__start_" + S), Sec, 0, STV_DEFAULT);<br>
- addOptionalSynthetic(Saver.sav<wbr>e("__stop_" + S), Sec,<br>
- DefinedSynthetic<ELFT>::Secti<wbr>onEnd, STV_DEFAULT);<br>
+ addOptionalSynthetic<ELFT>(Sav<wbr>er.save("__start_" + S), Sec, 0, STV_DEFAULT);<br>
+ addOptionalSynthetic<ELFT>(Sav<wbr>er.save("__stop_" + S), Sec,<br>
+ DefinedSynthetic<ELFT>::Secti<wbr>onEnd, STV_DEFAULT);<br>
}<br>
<br>
template <class ELFT><br>
-OutputSectionBase<ELFT> *Writer<ELFT>::findSection(Str<wbr>ingRef Name) {<br>
- for (OutputSectionBase<ELFT> *Sec : OutputSections)<br>
+OutputSectionBase *Writer<ELFT>::findSection(Str<wbr>ingRef Name) {<br>
+ for (OutputSectionBase *Sec : OutputSections)<br>
if (Sec->getName() == Name)<br>
return Sec;<br>
return nullptr;<br>
}<br>
<br>
-template <class ELFT> static bool needsPtLoad(OutputSectionBase<<wbr>ELFT> *Sec) {<br>
+template <class ELFT> static bool needsPtLoad(OutputSectionBase *Sec) {<br>
if (!(Sec->Flags & SHF_ALLOC))<br>
return false;<br>
<br>
@@ -1034,7 +1032,7 @@ template <class ELFT> std::vector<PhdrEn<br>
Hdr.add(Out<ELFT>::ProgramHea<wbr>ders);<br>
<br>
// PT_INTERP must be the second entry if exists.<br>
- if (OutputSectionBase<ELFT> *Sec = findSection(".interp")) {<br>
+ if (OutputSectionBase *Sec = findSection(".interp")) {<br>
Phdr &Hdr = *AddHdr(PT_INTERP, Sec->getPhdrFlags());<br>
Hdr.add(Sec);<br>
}<br>
@@ -1051,7 +1049,7 @@ template <class ELFT> std::vector<PhdrEn<br>
Phdr RelRo(PT_GNU_RELRO, PF_R);<br>
Phdr Note(PT_NOTE, PF_R);<br>
Phdr ARMExidx(PT_ARM_EXIDX, PF_R);<br>
- for (OutputSectionBase<ELFT> *Sec : OutputSections) {<br>
+ for (OutputSectionBase *Sec : OutputSections) {<br>
if (!(Sec->Flags & SHF_ALLOC))<br>
break;<br>
<br>
@@ -1061,7 +1059,7 @@ template <class ELFT> std::vector<PhdrEn<br>
if (Sec->Flags & SHF_TLS)<br>
TlsHdr.add(Sec);<br>
<br>
- if (!needsPtLoad(Sec))<br>
+ if (!needsPtLoad<ELFT>(Sec))<br>
continue;<br>
<br>
// Segments are contiguous memory regions that has the same attributes<br>
@@ -1077,7 +1075,7 @@ template <class ELFT> std::vector<PhdrEn<br>
<br>
Load->add(Sec);<br>
<br>
- if (isRelroSection(Sec))<br>
+ if (isRelroSection<ELFT>(Sec))<br>
RelRo.add(Sec);<br>
if (Sec->Type == SHT_NOTE)<br>
Note.add(Sec);<br>
@@ -1109,7 +1107,7 @@ template <class ELFT> std::vector<PhdrEn<br>
// PT_OPENBSD_RANDOMIZE specifies the location and size of a part of the<br>
// memory image of the program that must be filled with random data before any<br>
// code in the object is executed.<br>
- if (OutputSectionBase<ELFT> *Sec = findSection(".openbsd.randomda<wbr>ta")) {<br>
+ if (OutputSectionBase *Sec = findSection(".openbsd.randomda<wbr>ta")) {<br>
Phdr &Hdr = *AddHdr(PT_OPENBSD_RANDOMIZE, Sec->getPhdrFlags());<br>
Hdr.add(Sec);<br>
}<br>
@@ -1154,8 +1152,8 @@ template <class ELFT> void Writer<ELFT>:<br>
auto I = std::find(OutputSections.begin<wbr>(), End, P.Last);<br>
if (I == End || (I + 1) == End)<br>
continue;<br>
- OutputSectionBase<ELFT> *Sec = *(I + 1);<br>
- if (needsPtLoad(Sec))<br>
+ OutputSectionBase *Sec = *(I + 1);<br>
+ if (needsPtLoad<ELFT>(Sec))<br>
Sec->PageAlign = true;<br>
}<br>
}<br>
@@ -1175,7 +1173,7 @@ template <class ELFT> void Writer<ELFT>:<br>
template <class ELFT> void Writer<ELFT>::assignAddresses(<wbr>) {<br>
uintX_t VA = Config->ImageBase + getHeaderSize<ELFT>();<br>
uintX_t ThreadBssOffset = 0;<br>
- for (OutputSectionBase<ELFT> *Sec : OutputSections) {<br>
+ for (OutputSectionBase *Sec : OutputSections) {<br>
uintX_t Alignment = Sec->Addralign;<br>
if (Sec->PageAlign)<br>
Alignment = std::max<uintX_t>(Alignment, Config->MaxPageSize);<br>
@@ -1185,7 +1183,7 @@ template <class ELFT> void Writer<ELFT>:<br>
VA = I->second;<br>
<br>
// We only assign VAs to allocated sections.<br>
- if (needsPtLoad(Sec)) {<br>
+ if (needsPtLoad<ELFT>(Sec)) {<br>
VA = alignTo(VA, Alignment);<br>
Sec->Addr = VA;<br>
VA += Sec->Size;<br>
@@ -1203,13 +1201,13 @@ template <class ELFT> void Writer<ELFT>:<br>
// virtual address (modulo the page size) so that the loader can load<br>
// executables without any address adjustment.<br>
template <class ELFT, class uintX_t><br>
-static uintX_t getFileAlignment(uintX_t Off, OutputSectionBase<ELFT> *Sec) {<br>
+static uintX_t getFileAlignment(uintX_t Off, OutputSectionBase *Sec) {<br>
uintX_t Alignment = Sec->Addralign;<br>
if (Sec->PageAlign)<br>
Alignment = std::max<uintX_t>(Alignment, Config->MaxPageSize);<br>
Off = alignTo(Off, Alignment);<br>
<br>
- OutputSectionBase<ELFT> *First = Sec->FirstInPtLoad;<br>
+ OutputSectionBase *First = Sec->FirstInPtLoad;<br>
// If the section is not in a PT_LOAD, we have no other constraint.<br>
if (!First)<br>
return Off;<br>
@@ -1222,7 +1220,7 @@ static uintX_t getFileAlignment(uintX_t<br>
}<br>
<br>
template <class ELFT, class uintX_t><br>
-void setOffset(OutputSectionBase<EL<wbr>FT> *Sec, uintX_t &Off) {<br>
+void setOffset(OutputSectionBase *Sec, uintX_t &Off) {<br>
if (Sec->Type == SHT_NOBITS) {<br>
Sec->Offset = Off;<br>
return;<br>
@@ -1235,20 +1233,20 @@ void setOffset(OutputSectionBase<EL<wbr>FT> *<br>
<br>
template <class ELFT> void Writer<ELFT>::assignFileOffset<wbr>sBinary() {<br>
uintX_t Off = 0;<br>
- for (OutputSectionBase<ELFT> *Sec : OutputSections)<br>
+ for (OutputSectionBase *Sec : OutputSections)<br>
if (Sec->Flags & SHF_ALLOC)<br>
- setOffset(Sec, Off);<br>
+ setOffset<ELFT>(Sec, Off);<br>
FileSize = alignTo(Off, sizeof(uintX_t));<br>
}<br>
<br>
// Assign file offsets to output sections.<br>
template <class ELFT> void Writer<ELFT>::assignFileOffset<wbr>s() {<br>
uintX_t Off = 0;<br>
- setOffset(Out<ELFT>::ElfHeader<wbr>, Off);<br>
- setOffset(Out<ELFT>::ProgramHe<wbr>aders, Off);<br>
+ setOffset<ELFT>(Out<ELFT>::Elf<wbr>Header, Off);<br>
+ setOffset<ELFT>(Out<ELFT>::Pro<wbr>gramHeaders, Off);<br>
<br>
- for (OutputSectionBase<ELFT> *Sec : OutputSections)<br>
- setOffset(Sec, Off);<br>
+ for (OutputSectionBase *Sec : OutputSections)<br>
+ setOffset<ELFT>(Sec, Off);<br>
<br>
SectionHeaderOff = alignTo(Off, sizeof(uintX_t));<br>
FileSize = SectionHeaderOff + (OutputSections.size() + 1) * sizeof(Elf_Shdr);<br>
@@ -1259,8 +1257,8 @@ template <class ELFT> void Writer<ELFT>:<br>
template <class ELFT> void Writer<ELFT>::setPhdrs() {<br>
for (Phdr &P : Phdrs) {<br>
Elf_Phdr &H = P.H;<br>
- OutputSectionBase<ELFT> *First = P.First;<br>
- OutputSectionBase<ELFT> *Last = P.Last;<br>
+ OutputSectionBase *First = P.First;<br>
+ OutputSectionBase *Last = P.Last;<br>
if (First) {<br>
H.p_filesz = Last->Offset - First->Offset;<br>
if (Last->Type != SHT_NOBITS)<br>
@@ -1382,8 +1380,8 @@ template <class ELFT> void Writer<ELFT>:<br>
<br>
// Write the section header table. Note that the first table entry is null.<br>
auto *SHdrs = reinterpret_cast<Elf_Shdr *>(Buf + EHdr->e_shoff);<br>
- for (OutputSectionBase<ELFT> *Sec : OutputSections)<br>
- Sec->writeHeaderTo(++SHdrs);<br>
+ for (OutputSectionBase *Sec : OutputSections)<br>
+ Sec->writeHeaderTo<ELFT>(++SHd<wbr>rs);<br>
}<br>
<br>
template <class ELFT> void Writer<ELFT>::openFile() {<br>
@@ -1398,7 +1396,7 @@ template <class ELFT> void Writer<ELFT>:<br>
<br>
template <class ELFT> void Writer<ELFT>::writeSectionsBin<wbr>ary() {<br>
uint8_t *Buf = Buffer->getBufferStart();<br>
- for (OutputSectionBase<ELFT> *Sec : OutputSections)<br>
+ for (OutputSectionBase *Sec : OutputSections)<br>
if (Sec->Flags & SHF_ALLOC)<br>
Sec->writeTo(Buf + Sec->Offset);<br>
}<br>
@@ -1477,11 +1475,11 @@ template <class ELFT> void Writer<ELFT>:<br>
Out<ELFT>::Opd->writeTo(Buf + Out<ELFT>::Opd->Offset);<br>
}<br>
<br>
- for (OutputSectionBase<ELFT> *Sec : OutputSections)<br>
+ for (OutputSectionBase *Sec : OutputSections)<br>
if (Sec != Out<ELFT>::Opd && Sec != Out<ELFT>::EhFrameHdr)<br>
Sec->writeTo(Buf + Sec->Offset);<br>
<br>
- OutputSectionBase<ELFT> *ARMExidx = findSection(".ARM.exidx");<br>
+ OutputSectionBase *ARMExidx = findSection(".ARM.exidx");<br>
if (!Config->Relocatable)<br>
if (auto *OS = dyn_cast_or_null<OutputSection<wbr><ELFT>>(ARMExidx))<br>
sortARMExidx(Buf + OS->Offset, OS->Addr, OS->Size);<br>
@@ -1512,10 +1510,10 @@ template struct elf::PhdrEntry<ELF32BE>;<br>
template struct elf::PhdrEntry<ELF64LE>;<br>
template struct elf::PhdrEntry<ELF64BE>;<br>
<br>
-template bool elf::isRelroSection<ELF32LE>(c<wbr>onst OutputSectionBase<ELF32LE> *);<br>
-template bool elf::isRelroSection<ELF32BE>(c<wbr>onst OutputSectionBase<ELF32BE> *);<br>
-template bool elf::isRelroSection<ELF64LE>(c<wbr>onst OutputSectionBase<ELF64LE> *);<br>
-template bool elf::isRelroSection<ELF64BE>(c<wbr>onst OutputSectionBase<ELF64BE> *);<br>
+template bool elf::isRelroSection<ELF32LE>(c<wbr>onst OutputSectionBase *);<br>
+template bool elf::isRelroSection<ELF32BE>(c<wbr>onst OutputSectionBase *);<br>
+template bool elf::isRelroSection<ELF64LE>(c<wbr>onst OutputSectionBase *);<br>
+template bool elf::isRelroSection<ELF64BE>(c<wbr>onst OutputSectionBase *);<br>
<br>
template void elf::reportDiscarded<ELF32LE>(<wbr>InputSectionBase<ELF32LE> *);<br>
template void elf::reportDiscarded<ELF32BE>(<wbr>InputSectionBase<ELF32BE> *);<br>
<br>
Modified: lld/trunk/ELF/Writer.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.h?rev=286414&r1=286413&r2=286414&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/Writer.h?r<wbr>ev=286414&r1=286413&r2=286414&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Writer.h (original)<br>
+++ lld/trunk/ELF/Writer.h Wed Nov 9 17:23:45 2016<br>
@@ -17,24 +17,24 @@<br>
namespace lld {<br>
namespace elf {<br>
class InputFile;<br>
-template <class ELFT> class OutputSectionBase;<br>
+class OutputSectionBase;<br>
template <class ELFT> class InputSectionBase;<br>
template <class ELFT> class ObjectFile;<br>
template <class ELFT> class SymbolTable;<br>
template <class ELFT> void writeResult();<br>
template <class ELFT> void markLive();<br>
-template <class ELFT> bool isRelroSection(const OutputSectionBase<ELFT> *Sec);<br>
+template <class ELFT> bool isRelroSection(const OutputSectionBase *Sec);<br>
<br>
// This describes a program header entry.<br>
// Each contains type, access flags and range of output sections that will be<br>
// placed in it.<br>
template <class ELFT> struct PhdrEntry {<br>
PhdrEntry(unsigned Type, unsigned Flags);<br>
- void add(OutputSectionBase<ELFT> *Sec);<br>
+ void add(OutputSectionBase *Sec);<br>
<br>
typename ELFT::Phdr H = {};<br>
- OutputSectionBase<ELFT> *First = nullptr;<br>
- OutputSectionBase<ELFT> *Last = nullptr;<br>
+ OutputSectionBase *First = nullptr;<br>
+ OutputSectionBase *Last = nullptr;<br>
bool HasLMA = false;<br>
};<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div></div></div>
<br>______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>