<div dir="ltr">Awesome! I really like this change. :)</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 24, 2017 at 7:07 AM, 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: Fri Feb 24 09:07:30 2017<br>
New Revision: 296127<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=296127&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=296127&view=rev</a><br>
Log:<br>
Merge OutputSectionBase and OutputSection. NFC.<br>
<br>
Now that all special sections are SyntheticSections, we only need one<br>
OutputSection class.<br>
<br>
Modified:<br>
    lld/trunk/ELF/InputSection.cpp<br>
    lld/trunk/ELF/InputSection.h<br>
    lld/trunk/ELF/LinkerScript.cpp<br>
    lld/trunk/ELF/LinkerScript.h<br>
    lld/trunk/ELF/MapFile.cpp<br>
    lld/trunk/ELF/MapFile.h<br>
    lld/trunk/ELF/OutputSections.<wbr>cpp<br>
    lld/trunk/ELF/OutputSections.h<br>
    lld/trunk/ELF/Relocations.cpp<br>
    lld/trunk/ELF/Relocations.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/<wbr>SyntheticSections.cpp<br>
    lld/trunk/ELF/<wbr>SyntheticSections.h<br>
    lld/trunk/ELF/Target.cpp<br>
    lld/trunk/ELF/Thunks.h<br>
    lld/trunk/ELF/Writer.cpp<br>
    lld/trunk/ELF/Writer.h<br>
<br>
Modified: lld/trunk/ELF/InputSection.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>InputSection.cpp?rev=296127&<wbr>r1=296126&r2=296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/InputSection.cpp (original)<br>
+++ lld/trunk/ELF/InputSection.cpp Fri Feb 24 09:07:30 2017<br>
@@ -118,7 +118,7 @@ uint64_t InputSectionBase::getOffset(<wbr>uin<br>
 }<br>
<br>
 template <class ELFT><br>
-OutputSectionBase *InputSectionBase::<wbr>getOutputSection() const {<br>
+OutputSection *InputSectionBase::<wbr>getOutputSection() const {<br>
   if (auto *MS = dyn_cast<MergeInputSection<<wbr>ELFT>>(this))<br>
     return MS->MergeSec ? MS->MergeSec->OutSec : nullptr;<br>
   if (auto *EH = dyn_cast<EhInputSection<ELFT>><wbr>(this))<br>
@@ -827,10 +827,10 @@ template InputSectionBase *InputSectionB<br>
 template InputSectionBase *InputSectionBase::<wbr>getLinkOrderDep<ELF64LE>() const;<br>
 template InputSectionBase *InputSectionBase::<wbr>getLinkOrderDep<ELF64BE>() const;<br>
<br>
-template OutputSectionBase *InputSectionBase::<wbr>getOutputSection<ELF32LE>() const;<br>
-template OutputSectionBase *InputSectionBase::<wbr>getOutputSection<ELF32BE>() const;<br>
-template OutputSectionBase *InputSectionBase::<wbr>getOutputSection<ELF64LE>() const;<br>
-template OutputSectionBase *InputSectionBase::<wbr>getOutputSection<ELF64BE>() const;<br>
+template OutputSection *InputSectionBase::<wbr>getOutputSection<ELF32LE>() const;<br>
+template OutputSection *InputSectionBase::<wbr>getOutputSection<ELF32BE>() const;<br>
+template OutputSection *InputSectionBase::<wbr>getOutputSection<ELF64LE>() const;<br>
+template OutputSection *InputSectionBase::<wbr>getOutputSection<ELF64BE>() const;<br>
<br>
 template InputSectionBase *InputSection::<wbr>getRelocatedSection<ELF32LE>()<wbr>;<br>
 template InputSectionBase *InputSection::<wbr>getRelocatedSection<ELF32BE>()<wbr>;<br>
<br>
Modified: lld/trunk/ELF/InputSection.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>InputSection.h?rev=296127&r1=<wbr>296126&r2=296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/InputSection.h (original)<br>
+++ lld/trunk/ELF/InputSection.h Fri Feb 24 09:07:30 2017<br>
@@ -31,8 +31,7 @@ template <class ELFT> class DefinedRegul<br>
 template <class ELFT> class EhFrameSection;<br>
 template <class ELFT> class MergeSyntheticSection;<br>
 template <class ELFT> class ObjectFile;<br>
-template <class ELFT> class OutputSection;<br>
-class OutputSectionBase;<br>
+class OutputSection;<br>
<br>
 // This corresponds to a section of an input file.<br>
 class InputSectionBase {<br>
@@ -78,7 +77,7 @@ public:<br>
                    uint64_t Entsize, uint32_t Link, uint32_t Info,<br>
                    uint64_t Addralign, ArrayRef<uint8_t> Data, StringRef Name,<br>
                    Kind SectionKind);<br>
-  OutputSectionBase *OutSec = nullptr;<br>
+  OutputSection *OutSec = nullptr;<br>
<br>
   // Relocations that refer to this section.<br>
   const void *FirstRelocation = nullptr;<br>
@@ -110,7 +109,7 @@ public:<br>
   // Returns the size of this section (even if this is a common or BSS.)<br>
   template <class ELFT> size_t getSize() const;<br>
<br>
-  template <class ELFT> OutputSectionBase *getOutputSection() const;<br>
+  template <class ELFT> OutputSection *getOutputSection() const;<br>
<br>
   template <class ELFT> ObjectFile<ELFT> *getFile() const;<br>
<br>
<br>
Modified: lld/trunk/ELF/LinkerScript.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>LinkerScript.cpp?rev=296127&<wbr>r1=296126&r2=296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/LinkerScript.cpp (original)<br>
+++ lld/trunk/ELF/LinkerScript.cpp Fri Feb 24 09:07:30 2017<br>
@@ -72,7 +72,7 @@ template <class ELFT> static SymbolBody<br>
 template <class ELFT> static SymbolBody *addSynthetic(SymbolAssignment *Cmd) {<br>
   Symbol *Sym;<br>
   uint8_t Visibility = Cmd->Hidden ? STV_HIDDEN : STV_DEFAULT;<br>
-  const OutputSectionBase *Sec =<br>
+  const OutputSection *Sec =<br>
       ScriptConfig->HasSections ? nullptr : Cmd->Expression.Section();<br>
   std::tie(Sym, std::ignore) = Symtab<ELFT>::X->insert(<br>
       Cmd->Name, /*Type*/ 0, Visibility, /*CanOmitFromDynSym*/ false,<br>
@@ -397,7 +397,7 @@ void LinkerScript<ELFT>::<wbr>addOrphanSectio<br>
       Factory.addInputSec(S, getOutputSectionName(S->Name))<wbr>;<br>
 }<br>
<br>
-template <class ELFT> static bool isTbss(OutputSectionBase *Sec) {<br>
+template <class ELFT> static bool isTbss(OutputSection *Sec) {<br>
   return (Sec->Flags & SHF_TLS) && Sec->Type == SHT_NOBITS;<br>
 }<br>
<br>
@@ -438,16 +438,11 @@ template <class ELFT> void LinkerScript<<br>
 template <class ELFT> void LinkerScript<ELFT>::flush() {<br>
   if (!CurOutSec || !AlreadyOutputOS.insert(<wbr>CurOutSec).second)<br>
     return;<br>
-  if (auto *OutSec = dyn_cast<OutputSection<ELFT>>(<wbr>CurOutSec)) {<br>
-    for (InputSection *I : OutSec->Sections)<br>
-      output(I);<br>
-  } else {<br>
-    Dot += CurOutSec->Size;<br>
-  }<br>
+  for (InputSection *I : CurOutSec->Sections)<br>
+    output(I);<br>
 }<br>
<br>
-template <class ELFT><br>
-void LinkerScript<ELFT>::switchTo(<wbr>OutputSectionBase *Sec) {<br>
+template <class ELFT> void LinkerScript<ELFT>::switchTo(<wbr>OutputSection *Sec) {<br>
   if (CurOutSec == Sec)<br>
     return;<br>
   if (AlreadyOutputOS.count(Sec))<br>
@@ -512,12 +507,12 @@ template <class ELFT> void LinkerScript<<br>
 }<br>
<br>
 template <class ELFT><br>
-static OutputSectionBase *<br>
-findSection(StringRef Name, const std::vector<OutputSectionBase *> &Sections) {<br>
+static OutputSection *<br>
+findSection(StringRef Name, const std::vector<OutputSection *> &Sections) {<br>
   auto End = Sections.end();<br>
-  auto HasName = [=](OutputSectionBase *Sec) { return Sec->Name == Name; };<br>
+  auto HasName = [=](OutputSection *Sec) { return Sec->Name == Name; };<br>
   auto I = std::find_if(Sections.begin(), End, HasName);<br>
-  std::vector<OutputSectionBase *> Ret;<br>
+  std::vector<OutputSection *> Ret;<br>
   if (I == End)<br>
     return nullptr;<br>
   assert(std::find_if(I + 1, End, HasName) == End);<br>
@@ -529,7 +524,7 @@ findSection(StringRef Name, const std::v<br>
 // returned. Otherwise, a nullptr is returned.<br>
 template <class ELFT><br>
 MemoryRegion *LinkerScript<ELFT>::<wbr>findMemoryRegion(<wbr>OutputSectionCommand *Cmd,<br>
-                                                   OutputSectionBase *Sec) {<br>
+                                                   OutputSection *Sec) {<br>
   // If a memory region name was specified in the output section command,<br>
   // then try to find that region first.<br>
   if (!Cmd->MemoryRegionName.empty(<wbr>)) {<br>
@@ -568,7 +563,7 @@ void LinkerScript<ELFT>::<wbr>assignOffsets(O<br>
     uintX_t D = Dot;<br>
     LMAOffset = [=] { return Cmd->LMAExpr(D) - D; };<br>
   }<br>
-  OutputSectionBase *Sec = findSection<ELFT>(Cmd->Name, *OutputSections);<br>
+  OutputSection *Sec = findSection<ELFT>(Cmd->Name, *OutputSections);<br>
   if (!Sec)<br>
     return;<br>
<br>
@@ -634,8 +629,7 @@ template <class ELFT> void LinkerScript<<br>
     auto *Cmd = dyn_cast<OutputSectionCommand><wbr>(Base.get());<br>
     if (!Cmd)<br>
       continue;<br>
-    if (OutputSectionBase *Sec =<br>
-            findSection<ELFT>(Cmd->Name, *OutputSections)) {<br>
+    if (OutputSection *Sec = findSection<ELFT>(Cmd->Name, *OutputSections)) {<br>
       Flags = Sec->Flags;<br>
       Type = Sec->Type;<br>
       continue;<br>
@@ -644,7 +638,7 @@ template <class ELFT> void LinkerScript<<br>
     if (isAllSectionDescription(*Cmd)<wbr>)<br>
       continue;<br>
<br>
-    auto *OutSec = make<OutputSection<ELFT>>(Cmd-<wbr>>Name, Type, Flags);<br>
+    auto *OutSec = make<OutputSection>(Cmd->Name, Type, Flags);<br>
     OutputSections->push_back(<wbr>OutSec);<br>
   }<br>
 }<br>
@@ -751,7 +745,7 @@ template <class ELFT> void LinkerScript<<br>
       ++CmdIndex;<br>
   }<br>
<br>
-  for (OutputSectionBase *Sec : *OutputSections) {<br>
+  for (OutputSection *Sec : *OutputSections) {<br>
     StringRef Name = Sec->Name;<br>
<br>
     // Find the last spot where we can insert a command and still get the<br>
@@ -794,7 +788,7 @@ void LinkerScript<ELFT>::<wbr>assignAddresses<br>
   // To handle that, create a dummy aether section that fills the void before<br>
   // the linker scripts switches to another section. It has an index of one<br>
   // which will map to whatever the first actual section is.<br>
-  auto *Aether = make<OutputSectionBase>("", 0, SHF_ALLOC);<br>
+  auto *Aether = make<OutputSection>("", 0, SHF_ALLOC);<br>
   Aether->SectionIndex = 1;<br>
   switchTo(Aether);<br>
<br>
@@ -814,7 +808,7 @@ void LinkerScript<ELFT>::<wbr>assignAddresses<br>
   }<br>
<br>
   uintX_t MinVA = std::numeric_limits<uintX_t>::<wbr>max();<br>
-  for (OutputSectionBase *Sec : *OutputSections) {<br>
+  for (OutputSection *Sec : *OutputSections) {<br>
     if (Sec->Flags & SHF_ALLOC)<br>
       MinVA = std::min<uint64_t>(MinVA, Sec->Addr);<br>
     else<br>
@@ -846,7 +840,7 @@ template <class ELFT> std::vector<PhdrEn<br>
   }<br>
<br>
   // Add output sections to program headers.<br>
-  for (OutputSectionBase *Sec : *OutputSections) {<br>
+  for (OutputSection *Sec : *OutputSections) {<br>
     if (!(Sec->Flags & SHF_ALLOC))<br>
       break;<br>
<br>
@@ -936,11 +930,11 @@ template <class ELFT> bool LinkerScript<<br>
 }<br>
<br>
 template <class ELFT><br>
-const OutputSectionBase *LinkerScript<ELFT>::<wbr>getOutputSection(const Twine &Loc,<br>
-                                                              StringRef Name) {<br>
-  static OutputSectionBase FakeSec("", 0, 0);<br>
+const OutputSection *LinkerScript<ELFT>::<wbr>getOutputSection(const Twine &Loc,<br>
+                                                          StringRef Name) {<br>
+  static OutputSection FakeSec("", 0, 0);<br>
<br>
-  for (OutputSectionBase *Sec : *OutputSections)<br>
+  for (OutputSection *Sec : *OutputSections)<br>
     if (Sec->Name == Name)<br>
       return Sec;<br>
<br>
@@ -956,7 +950,7 @@ const OutputSectionBase *LinkerScript<EL<br>
 // be empty. That is why this function is different from getOutputSection().<br>
 template <class ELFT><br>
 uint64_t LinkerScript<ELFT>::<wbr>getOutputSectionSize(StringRef Name) {<br>
-  for (OutputSectionBase *Sec : *OutputSections)<br>
+  for (OutputSection *Sec : *OutputSections)<br>
     if (Sec->Name == Name)<br>
       return Sec->Size;<br>
   return 0;<br>
@@ -988,7 +982,7 @@ template <class ELFT> bool LinkerScript<<br>
 // specific section but isn't absolute at the same time, so we try<br>
 // to find suitable section for it as well.<br>
 template <class ELFT><br>
-const OutputSectionBase *LinkerScript<ELFT>::<wbr>getSymbolSection(StringRef S) {<br>
+const OutputSection *LinkerScript<ELFT>::<wbr>getSymbolSection(StringRef S) {<br>
   if (SymbolBody *Sym = Symtab<ELFT>::X->find(S))<br>
     return SymbolTableSection<ELFT>::<wbr>getOutputSection(Sym);<br>
   return CurOutSec;<br>
@@ -1646,7 +1640,7 @@ Expr ScriptParser::readExpr() {<br>
 static Expr combine(StringRef Op, Expr L, Expr R) {<br>
   auto IsAbs = [=] { return L.IsAbsolute() && R.IsAbsolute(); };<br>
   auto GetOutSec = [=] {<br>
-    const OutputSectionBase *S = L.Section();<br>
+    const OutputSection *S = L.Section();<br>
     return S ? S : R.Section();<br>
   };<br>
<br>
<br>
Modified: lld/trunk/ELF/LinkerScript.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>LinkerScript.h?rev=296127&r1=<wbr>296126&r2=296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/LinkerScript.h (original)<br>
+++ lld/trunk/ELF/LinkerScript.h Fri Feb 24 09:07:30 2017<br>
@@ -33,7 +33,7 @@ class ScriptParser;<br>
 class SymbolBody;<br>
 class InputSectionBase;<br>
 class InputSection;<br>
-class OutputSectionBase;<br>
+class OutputSection;<br>
 template <class ELFT> class OutputSectionFactory;<br>
 class InputSectionBase;<br>
<br>
@@ -47,13 +47,13 @@ struct Expr {<br>
<br>
   // If expression is section-relative the function below is used<br>
   // to get the output section pointer.<br>
-  std::function<const OutputSectionBase *()> Section;<br>
+  std::function<const OutputSection *()> Section;<br>
<br>
   uint64_t operator()(uint64_t Dot) const { return Val(Dot); }<br>
   operator bool() const { return (bool)Val; }<br>
<br>
   Expr(std::function<uint64_t(<wbr>uint64_t)> Val, std::function<bool()> IsAbsolute,<br>
-       std::function<const OutputSectionBase *()> Section)<br>
+       std::function<const OutputSection *()> Section)<br>
       : Val(Val), IsAbsolute(IsAbsolute), Section(Section) {}<br>
   template <typename T><br>
   Expr(T V) : Expr(V, [] { return true; }, [] { return nullptr; }) {}<br>
@@ -213,9 +213,9 @@ public:<br>
   virtual uint64_t getSymbolValue(const Twine &Loc, StringRef S) = 0;<br>
   virtual bool isDefined(StringRef S) = 0;<br>
   virtual bool isAbsolute(StringRef S) = 0;<br>
-  virtual const OutputSectionBase *getSymbolSection(StringRef S) = 0;<br>
-  virtual const OutputSectionBase *getOutputSection(const Twine &Loc,<br>
-                                                    StringRef S) = 0;<br>
+  virtual const OutputSection *getSymbolSection(StringRef S) = 0;<br>
+  virtual const OutputSection *getOutputSection(const Twine &Loc,<br>
+                                                StringRef S) = 0;<br>
   virtual uint64_t getOutputSectionSize(StringRef S) = 0;<br>
 };<br>
<br>
@@ -268,12 +268,11 @@ public:<br>
   uint64_t getSymbolValue(const Twine &Loc, StringRef S) override;<br>
   bool isDefined(StringRef S) override;<br>
   bool isAbsolute(StringRef S) override;<br>
-  const OutputSectionBase *getSymbolSection(StringRef S) override;<br>
-  const OutputSectionBase *getOutputSection(const Twine &Loc,<br>
-                                            StringRef S) override;<br>
+  const OutputSection *getSymbolSection(StringRef S) override;<br>
+  const OutputSection *getOutputSection(const Twine &Loc, StringRef S) override;<br>
   uint64_t getOutputSectionSize(StringRef S) override;<br>
<br>
-  std::vector<OutputSectionBase *> *OutputSections;<br>
+  std::vector<OutputSection *> *OutputSections;<br>
<br>
   int getSectionIndex(StringRef Name);<br>
<br>
@@ -294,19 +293,18 @@ private:<br>
   std::vector<size_t> getPhdrIndices(StringRef SectionName);<br>
   size_t getPhdrIndex(const Twine &Loc, StringRef PhdrName);<br>
<br>
-  MemoryRegion *findMemoryRegion(<wbr>OutputSectionCommand *Cmd,<br>
-                                 OutputSectionBase *Sec);<br>
+  MemoryRegion *findMemoryRegion(<wbr>OutputSectionCommand *Cmd, OutputSection *Sec);<br>
<br>
   uintX_t Dot;<br>
   std::function<uint64_t()> LMAOffset;<br>
-  OutputSectionBase *CurOutSec = nullptr;<br>
+  OutputSection *CurOutSec = nullptr;<br>
   MemoryRegion *CurMemRegion = nullptr;<br>
   uintX_t ThreadBssOffset = 0;<br>
-  void switchTo(OutputSectionBase *Sec);<br>
+  void switchTo(OutputSection *Sec);<br>
   void flush();<br>
   void output(InputSection *Sec);<br>
   void process(BaseCommand &Base);<br>
-  llvm::DenseSet<<wbr>OutputSectionBase *> AlreadyOutputOS;<br>
+  llvm::DenseSet<OutputSection *> AlreadyOutputOS;<br>
   llvm::DenseSet<<wbr>InputSectionBase *> AlreadyOutputIS;<br>
 };<br>
<br>
<br>
Modified: lld/trunk/ELF/MapFile.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MapFile.cpp?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/MapFile.<wbr>cpp?rev=296127&r1=296126&r2=<wbr>296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/MapFile.cpp (original)<br>
+++ lld/trunk/ELF/MapFile.cpp Fri Feb 24 09:07:30 2017<br>
@@ -95,26 +95,25 @@ static void writeInputSection(raw_fd_ost<br>
<br>
 template <class ELFT><br>
 static void writeMapFile2(raw_fd_ostream &OS,<br>
-                          ArrayRef<OutputSectionBase *> OutputSections) {<br>
+                          ArrayRef<OutputSection *> OutputSections) {<br>
   int Width = ELFT::Is64Bits ? 16 : 8;<br>
<br>
   OS << left_justify("Address", Width) << ' ' << left_justify("Size", Width)<br>
      << " Align Out     In      File    Symbol\n";<br>
<br>
-  for (OutputSectionBase *Sec : OutputSections) {<br>
+  for (OutputSection *Sec : OutputSections) {<br>
     writeOutSecLine(OS, Width, Sec->Addr, Sec->Size, Sec->Addralign, Sec->Name);<br>
     OS << '\n';<br>
<br>
     StringRef PrevName = "";<br>
-    Sec->forEachInputSection([&](<wbr>InputSectionBase *S) {<br>
-      if (const auto *IS = dyn_cast<InputSection>(S))<br>
-        writeInputSection<ELFT>(OS, IS, PrevName);<br>
-    });<br>
+    for (InputSection *IS : Sec->Sections) {<br>
+      writeInputSection<ELFT>(OS, IS, PrevName);<br>
+    }<br>
   }<br>
 }<br>
<br>
 template <class ELFT><br>
-void elf::writeMapFile(ArrayRef<<wbr>OutputSectionBase *> OutputSections) {<br>
+void elf::writeMapFile(ArrayRef<<wbr>OutputSection *> OutputSections) {<br>
   if (Config->MapFile.empty())<br>
     return;<br>
<br>
@@ -126,7 +125,7 @@ void elf::writeMapFile(ArrayRef<<wbr>OutputSe<br>
     writeMapFile2<ELFT>(OS, OutputSections);<br>
 }<br>
<br>
-template void elf::writeMapFile<ELF32LE>(<wbr>ArrayRef<OutputSectionBase *>);<br>
-template void elf::writeMapFile<ELF32BE>(<wbr>ArrayRef<OutputSectionBase *>);<br>
-template void elf::writeMapFile<ELF64LE>(<wbr>ArrayRef<OutputSectionBase *>);<br>
-template void elf::writeMapFile<ELF64BE>(<wbr>ArrayRef<OutputSectionBase *>);<br>
+template void elf::writeMapFile<ELF32LE>(<wbr>ArrayRef<OutputSection *>);<br>
+template void elf::writeMapFile<ELF32BE>(<wbr>ArrayRef<OutputSection *>);<br>
+template void elf::writeMapFile<ELF64LE>(<wbr>ArrayRef<OutputSection *>);<br>
+template void elf::writeMapFile<ELF64BE>(<wbr>ArrayRef<OutputSection *>);<br>
<br>
Modified: lld/trunk/ELF/MapFile.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MapFile.h?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/MapFile.<wbr>h?rev=296127&r1=296126&r2=<wbr>296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/MapFile.h (original)<br>
+++ lld/trunk/ELF/MapFile.h Fri Feb 24 09:07:30 2017<br>
@@ -15,7 +15,7 @@<br>
 namespace lld {<br>
 namespace elf {<br>
 template <class ELFT><br>
-void writeMapFile(llvm::ArrayRef<<wbr>OutputSectionBase *> OutputSections);<br>
+void writeMapFile(llvm::ArrayRef<<wbr>OutputSection *> OutputSections);<br>
 }<br>
 }<br>
<br>
<br>
Modified: lld/trunk/ELF/OutputSections.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>OutputSections.cpp?rev=296127&<wbr>r1=296126&r2=296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/OutputSections.<wbr>cpp (original)<br>
+++ lld/trunk/ELF/OutputSections.<wbr>cpp Fri Feb 24 09:07:30 2017<br>
@@ -30,15 +30,7 @@ using namespace llvm::ELF;<br>
 using namespace lld;<br>
 using namespace lld::elf;<br>
<br>
-OutputSectionBase::<wbr>OutputSectionBase(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>
-uint32_t OutputSectionBase::<wbr>getPhdrFlags() const {<br>
+uint32_t OutputSection::getPhdrFlags() const {<br>
   uint32_t Ret = PF_R;<br>
   if (Flags & SHF_WRITE)<br>
     Ret |= PF_W;<br>
@@ -48,7 +40,7 @@ uint32_t OutputSectionBase::<wbr>getPhdrFlags<br>
 }<br>
<br>
 template <class ELFT><br>
-void OutputSectionBase::<wbr>writeHeaderTo(typename ELFT::Shdr *Shdr) {<br>
+void OutputSection::writeHeaderTo(<wbr>typename ELFT::Shdr *Shdr) {<br>
   Shdr->sh_entsize = Entsize;<br>
   Shdr->sh_addralign = Addralign;<br>
   Shdr->sh_type = Type;<br>
@@ -78,10 +70,24 @@ template <class ELFT> static uint64_t ge<br>
   }<br>
 }<br>
<br>
-template <class ELFT><br>
-OutputSection<ELFT>::<wbr>OutputSection(StringRef Name, uint32_t Type, uintX_t Flags)<br>
-    : OutputSectionBase(Name, Type, Flags) {<br>
-  this->Entsize = getEntsize<ELFT>(Type);<br>
+OutputSection::OutputSection(<wbr>StringRef Name, uint32_t Type, uint64_t Flags)<br>
+    : Name(Name), Addralign(1), Flags(Flags), Type(Type) {<br>
+  switch (Config->EKind) {<br>
+  case ELFNoneKind:<br>
+    llvm_unreachable("unknown kind");<br>
+  case ELF32LEKind:<br>
+    this->Entsize = getEntsize<ELF32LE>(Type);<br>
+    break;<br>
+  case ELF32BEKind:<br>
+    this->Entsize = getEntsize<ELF32BE>(Type);<br>
+    break;<br>
+  case ELF64LEKind:<br>
+    this->Entsize = getEntsize<ELF64LE>(Type);<br>
+    break;<br>
+  case ELF64BEKind:<br>
+    this->Entsize = getEntsize<ELF64BE>(Type);<br>
+    break;<br>
+  }<br>
 }<br>
<br>
 template <typename ELFT><br>
@@ -92,18 +98,18 @@ static bool compareByFilePosition(InputS<br>
     return false;<br>
   auto *LA = cast<InputSection>(A->template getLinkOrderDep<ELFT>());<br>
   auto *LB = cast<InputSection>(B->template getLinkOrderDep<ELFT>());<br>
-  OutputSectionBase *AOut = LA->OutSec;<br>
-  OutputSectionBase *BOut = LB->OutSec;<br>
+  OutputSection *AOut = LA->OutSec;<br>
+  OutputSection *BOut = LB->OutSec;<br>
   if (AOut != BOut)<br>
     return AOut->SectionIndex < BOut->SectionIndex;<br>
   return LA->OutSecOff < LB->OutSecOff;<br>
 }<br>
<br>
-template <class ELFT> void OutputSection<ELFT>::finalize(<wbr>) {<br>
+template <class ELFT> void OutputSection::finalize() {<br>
   if ((this->Flags & SHF_LINK_ORDER) && !this->Sections.empty()) {<br>
     std::sort(Sections.begin(), Sections.end(), compareByFilePosition<ELFT>);<br>
     Size = 0;<br>
-    assignOffsets();<br>
+    assignOffsets<ELFT>();<br>
<br>
     // We must preserve the link order dependency of sections with the<br>
     // SHF_LINK_ORDER flag. The dependency is indicated by the sh_link field. We<br>
@@ -128,8 +134,7 @@ template <class ELFT> void OutputSection<br>
   this->Info = S->OutSec->SectionIndex;<br>
 }<br>
<br>
-template <class ELFT><br>
-void OutputSection<ELFT>::<wbr>addSection(InputSectionBase *C) {<br>
+void OutputSection::addSection(<wbr>InputSectionBase *C) {<br>
   assert(C->Live);<br>
   auto *S = cast<InputSection>(C);<br>
   Sections.push_back(S);<br>
@@ -141,17 +146,10 @@ void OutputSection<ELFT>::<wbr>addSection(Inp<br>
     this->Entsize = S->Entsize;<br>
 }<br>
<br>
-template <class ELFT><br>
-void OutputSection<ELFT>::<wbr>forEachInputSection(<br>
-    std::function<void(<wbr>InputSectionBase *)> F) {<br>
-  for (InputSection *S : Sections)<br>
-    F(S);<br>
-}<br>
-<br>
 // This function is called after we sort input sections<br>
 // and scan relocations to setup sections' offsets.<br>
-template <class ELFT> void OutputSection<ELFT>::<wbr>assignOffsets() {<br>
-  uintX_t Off = this->Size;<br>
+template <class ELFT> void OutputSection::assignOffsets() {<br>
+  uint64_t Off = this->Size;<br>
   for (InputSection *S : Sections) {<br>
     Off = alignTo(Off, S->Alignment);<br>
     S->OutSecOff = Off;<br>
@@ -160,8 +158,7 @@ template <class ELFT> void OutputSection<br>
   this->Size = Off;<br>
 }<br>
<br>
-template <class ELFT><br>
-void OutputSection<ELFT>::sort(std:<wbr>:function<int(InputSectionBase *S)> Order) {<br>
+void OutputSection::sort(std::<wbr>function<int(InputSectionBase *S)> Order) {<br>
   typedef std::pair<unsigned, InputSection *> Pair;<br>
   auto Comp = [](const Pair &A, const Pair &B) { return A.first < B.first; };<br>
<br>
@@ -180,7 +177,7 @@ void OutputSection<ELFT>::sort(std:<wbr>:func<br>
 // because the compiler keeps the original initialization order in a<br>
 // translation unit and we need to respect that.<br>
 // For more detail, read the section of the GCC's manual about init_priority.<br>
-template <class ELFT> void OutputSection<ELFT>::<wbr>sortInitFini() {<br>
+void OutputSection::sortInitFini() {<br>
   // Sort sections by priority.<br>
   sort([](InputSectionBase *S) { return getPriority(S->Name); });<br>
 }<br>
@@ -239,7 +236,7 @@ static bool compCtors(const InputSection<br>
 // Sorts input sections by the special rules for .ctors and .dtors.<br>
 // Unfortunately, the rules are different from the one for .{init,fini}_array.<br>
 // Read the comment above.<br>
-template <class ELFT> void OutputSection<ELFT>::<wbr>sortCtorsDtors() {<br>
+void OutputSection::sortCtorsDtors(<wbr>) {<br>
   std::stable_sort(Sections.<wbr>begin(), Sections.end(), compCtors);<br>
 }<br>
<br>
@@ -254,7 +251,7 @@ void fill(uint8_t *Buf, size_t Size, uin<br>
   memcpy(Buf + I, V, Size - I);<br>
 }<br>
<br>
-template <class ELFT> void OutputSection<ELFT>::writeTo(<wbr>uint8_t *Buf) {<br>
+template <class ELFT> void OutputSection::writeTo(uint8_t *Buf) {<br>
   Loc = Buf;<br>
   if (uint32_t Filler = Script<ELFT>::X->getFiller(<wbr>this->Name))<br>
     fill(Buf, this->Size, Filler);<br>
@@ -331,7 +328,7 @@ static SectionKey createKey(InputSection<br>
<br>
 template <class ELFT><br>
 OutputSectionFactory<ELFT>::<wbr>OutputSectionFactory(<br>
-    std::vector<OutputSectionBase *> &OutputSections)<br>
+    std::vector<OutputSection *> &OutputSections)<br>
     : OutputSections(OutputSections) {}<br>
<br>
 static uint64_t getIncompatibleFlags(uint64_t Flags) {<br>
@@ -367,7 +364,7 @@ void OutputSectionFactory<ELFT>::<wbr>addInpu<br>
<br>
   SectionKey Key = createKey<ELFT>(IS, OutsecName);<br>
   uintX_t Flags = getOutFlags<ELFT>(IS);<br>
-  OutputSectionBase *&Sec = Map[Key];<br>
+  OutputSection *&Sec = Map[Key];<br>
   if (Sec) {<br>
     if (getIncompatibleFlags(Sec-><wbr>Flags) != getIncompatibleFlags(IS-><wbr>Flags))<br>
       error("Section has flags incompatible with others with the same name " +<br>
@@ -386,7 +383,7 @@ void OutputSectionFactory<ELFT>::<wbr>addInpu<br>
       In<ELFT>::EhFrame->addSection(<wbr>IS);<br>
       return;<br>
     }<br>
-    Sec = make<OutputSection<ELFT>>(Key.<wbr>Name, Type, Flags);<br>
+    Sec = make<OutputSection>(Key.Name, Type, Flags);<br>
     OutputSections.push_back(Sec);<br>
   }<br>
<br>
@@ -416,15 +413,25 @@ bool DenseMapInfo<SectionKey>::<wbr>isEqual(c<br>
 namespace lld {<br>
 namespace elf {<br>
<br>
-template void OutputSectionBase::<wbr>writeHeaderTo<ELF32LE>(<wbr>ELF32LE::Shdr *Shdr);<br>
-template void OutputSectionBase::<wbr>writeHeaderTo<ELF32BE>(<wbr>ELF32BE::Shdr *Shdr);<br>
-template void OutputSectionBase::<wbr>writeHeaderTo<ELF64LE>(<wbr>ELF64LE::Shdr *Shdr);<br>
-template void OutputSectionBase::<wbr>writeHeaderTo<ELF64BE>(<wbr>ELF64BE::Shdr *Shdr);<br>
-<br>
-template class OutputSection<ELF32LE>;<br>
-template class OutputSection<ELF32BE>;<br>
-template class OutputSection<ELF64LE>;<br>
-template class OutputSection<ELF64BE>;<br>
+template void OutputSection::writeHeaderTo<<wbr>ELF32LE>(ELF32LE::Shdr *Shdr);<br>
+template void OutputSection::writeHeaderTo<<wbr>ELF32BE>(ELF32BE::Shdr *Shdr);<br>
+template void OutputSection::writeHeaderTo<<wbr>ELF64LE>(ELF64LE::Shdr *Shdr);<br>
+template void OutputSection::writeHeaderTo<<wbr>ELF64BE>(ELF64BE::Shdr *Shdr);<br>
+<br>
+template void OutputSection::assignOffsets<<wbr>ELF32LE>();<br>
+template void OutputSection::assignOffsets<<wbr>ELF32BE>();<br>
+template void OutputSection::assignOffsets<<wbr>ELF64LE>();<br>
+template void OutputSection::assignOffsets<<wbr>ELF64BE>();<br>
+<br>
+template void OutputSection::finalize<<wbr>ELF32LE>();<br>
+template void OutputSection::finalize<<wbr>ELF32BE>();<br>
+template void OutputSection::finalize<<wbr>ELF64LE>();<br>
+template void OutputSection::finalize<<wbr>ELF64BE>();<br>
+<br>
+template void OutputSection::writeTo<<wbr>ELF32LE>(uint8_t *Buf);<br>
+template void OutputSection::writeTo<<wbr>ELF32BE>(uint8_t *Buf);<br>
+template void OutputSection::writeTo<<wbr>ELF64LE>(uint8_t *Buf);<br>
+template void OutputSection::writeTo<<wbr>ELF64BE>(uint8_t *Buf);<br>
<br>
 template class OutputSectionFactory<ELF32LE>;<br>
 template class OutputSectionFactory<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=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>OutputSections.h?rev=296127&<wbr>r1=296126&r2=296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/OutputSections.h (original)<br>
+++ lld/trunk/ELF/OutputSections.h Fri Feb 24 09:07:30 2017<br>
@@ -27,34 +27,23 @@ template <class ELFT> class EhInputSecti<br>
 class InputSection;<br>
 class InputSectionBase;<br>
 template <class ELFT> class MergeInputSection;<br>
-template <class ELFT> class OutputSection;<br>
+class OutputSection;<br>
 template <class ELFT> class ObjectFile;<br>
 template <class ELFT> class SharedFile;<br>
 template <class ELFT> class SharedSymbol;<br>
 template <class ELFT> class DefinedRegular;<br>
<br>
 // This represents a section in an output file.<br>
-// Different sub classes represent different types of sections. Some contain<br>
-// input sections, others are created by the linker.<br>
+// It is composed of multiple InputSections.<br>
 // The writer creates multiple OutputSections and assign them unique,<br>
 // non-overlapping file offsets and VAs.<br>
-class OutputSectionBase {<br>
+class OutputSection final {<br>
 public:<br>
-  enum Kind {<br>
-    Base,<br>
-    Regular,<br>
-  };<br>
+  OutputSection(StringRef Name, uint32_t Type, uint64_t Flags);<br>
<br>
-  OutputSectionBase(StringRef Name, uint32_t Type, uint64_t Flags);<br>
   uint64_t getLMA() const { return Addr + LMAOffset; }<br>
   template <typename ELFT> void writeHeaderTo(typename ELFT::Shdr *SHdr);<br>
<br>
-  virtual void addSection(InputSectionBase *C) {}<br>
-  virtual Kind getKind() const { return Base; }<br>
-  static bool classof(const OutputSectionBase *B) {<br>
-    return B->getKind() == Base;<br>
-  }<br>
-<br>
   unsigned SectionIndex;<br>
<br>
   uint32_t getPhdrFlags() const;<br>
@@ -74,13 +63,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 *FirstInPtLoad = nullptr;<br>
-<br>
-  virtual void finalize() {}<br>
-  virtual void forEachInputSection(std::<wbr>function<void(InputSectionBase *)> F) {}<br>
-  virtual void assignOffsets() {}<br>
-  virtual void writeTo(uint8_t *Buf) {}<br>
-  virtual ~OutputSectionBase() = default;<br>
+  OutputSection *FirstInPtLoad = nullptr;<br>
<br>
   StringRef Name;<br>
<br>
@@ -96,29 +79,14 @@ public:<br>
   uint32_t Type = 0;<br>
   uint32_t Info = 0;<br>
   uint32_t Link = 0;<br>
-};<br>
-<br>
-template <class ELFT> class OutputSection final : public OutputSectionBase {<br>
<br>
-public:<br>
-  typedef typename ELFT::Shdr Elf_Shdr;<br>
-  typedef typename ELFT::Sym Elf_Sym;<br>
-  typedef typename ELFT::Rel Elf_Rel;<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 *C) override;<br>
+  void addSection(InputSectionBase *C);<br>
   void sort(std::function<int(<wbr>InputSectionBase *S)> Order);<br>
   void sortInitFini();<br>
   void sortCtorsDtors();<br>
-  void writeTo(uint8_t *Buf) override;<br>
-  void finalize() override;<br>
-  void forEachInputSection(std::<wbr>function<void(InputSectionBase *)> F) override;<br>
-  void assignOffsets() override;<br>
-  Kind getKind() const override { return Regular; }<br>
-  static bool classof(const OutputSectionBase *B) {<br>
-    return B->getKind() == Regular;<br>
-  }<br>
+  template <class ELFT> void writeTo(uint8_t *Buf);<br>
+  template <class ELFT> void finalize();<br>
+  template <class ELFT> void assignOffsets();<br>
   std::vector<InputSection *> Sections;<br>
<br>
   // Location in the output buffer.<br>
@@ -133,17 +101,17 @@ template <class ELFT> struct Out {<br>
   typedef typename ELFT::Phdr Elf_Phdr;<br>
<br>
   static uint8_t First;<br>
-  static OutputSection<ELFT> *Bss;<br>
-  static OutputSection<ELFT> *BssRelRo;<br>
-  static OutputSectionBase *Opd;<br>
+  static OutputSection *Bss;<br>
+  static OutputSection *BssRelRo;<br>
+  static OutputSection *Opd;<br>
   static uint8_t *OpdBuf;<br>
   static PhdrEntry *TlsPhdr;<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>
+  static OutputSection *DebugInfo;<br>
+  static OutputSection *ElfHeader;<br>
+  static OutputSection *ProgramHeaders;<br>
+  static OutputSection *PreinitArray;<br>
+  static OutputSection *InitArray;<br>
+  static OutputSection *FiniArray;<br>
 };<br>
<br>
 struct SectionKey {<br>
@@ -174,13 +142,13 @@ template <class ELFT> class OutputSectio<br>
   typedef typename ELFT::uint uintX_t;<br>
<br>
 public:<br>
-  OutputSectionFactory(std::<wbr>vector<OutputSectionBase *> &OutputSections);<br>
+  OutputSectionFactory(std::<wbr>vector<OutputSection *> &OutputSections);<br>
   ~OutputSectionFactory();<br>
   void addInputSec(InputSectionBase *IS, StringRef OutsecName);<br>
<br>
 private:<br>
-  llvm::SmallDenseMap<<wbr>SectionKey, OutputSectionBase *> Map;<br>
-  std::vector<OutputSectionBase *> &OutputSections;<br>
+  llvm::SmallDenseMap<<wbr>SectionKey, OutputSection *> Map;<br>
+  std::vector<OutputSection *> &OutputSections;<br>
 };<br>
<br>
 template <class ELFT> uint64_t getHeaderSize() {<br>
@@ -190,17 +158,17 @@ template <class ELFT> uint64_t getHeader<br>
 }<br>
<br>
 template <class ELFT> uint8_t Out<ELFT>::First;<br>
-template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Bss;<br>
-template <class ELFT> OutputSection<ELFT> *Out<ELFT>::BssRelRo;<br>
-template <class ELFT> OutputSectionBase *Out<ELFT>::Opd;<br>
+template <class ELFT> OutputSection *Out<ELFT>::Bss;<br>
+template <class ELFT> OutputSection *Out<ELFT>::BssRelRo;<br>
+template <class ELFT> OutputSection *Out<ELFT>::Opd;<br>
 template <class ELFT> uint8_t *Out<ELFT>::OpdBuf;<br>
 template <class ELFT> PhdrEntry *Out<ELFT>::TlsPhdr;<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>
+template <class ELFT> OutputSection *Out<ELFT>::DebugInfo;<br>
+template <class ELFT> OutputSection *Out<ELFT>::ElfHeader;<br>
+template <class ELFT> OutputSection *Out<ELFT>::ProgramHeaders;<br>
+template <class ELFT> OutputSection *Out<ELFT>::PreinitArray;<br>
+template <class ELFT> OutputSection *Out<ELFT>::InitArray;<br>
+template <class ELFT> OutputSection *Out<ELFT>::FiniArray;<br>
 } // namespace elf<br>
 } // namespace lld<br>
<br>
<br>
Modified: lld/trunk/ELF/Relocations.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>Relocations.cpp?rev=296127&r1=<wbr>296126&r2=296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Relocations.cpp (original)<br>
+++ lld/trunk/ELF/Relocations.cpp Fri Feb 24 09:07:30 2017<br>
@@ -485,7 +485,7 @@ template <class ELFT> static void addCop<br>
   // See if this symbol is in a read-only segment. If so, preserve the symbol's<br>
   // memory protection by reserving space in the .<a href="http://bss.rel.ro" rel="noreferrer" target="_blank">bss.rel.ro</a> section.<br>
   bool IsReadOnly = isReadOnly(SS);<br>
-  OutputSection<ELFT> *OSec = IsReadOnly ? Out<ELFT>::BssRelRo : Out<ELFT>::Bss;<br>
+  OutputSection *OSec = IsReadOnly ? Out<ELFT>::BssRelRo : Out<ELFT>::Bss;<br>
<br>
   // Create a SyntheticSection in Out to hold the .bss and the Copy Reloc.<br>
   auto *ISec =<br>
@@ -866,7 +866,7 @@ template <class ELFT> void scanRelocatio<br>
 // offsets.<br>
 // This may invalidate any output section offsets stored outside of InputSection<br>
 template <class ELFT><br>
-static void mergeThunks(OutputSection<<wbr>ELFT> *OS,<br>
+static void mergeThunks(OutputSection *OS,<br>
                         std::vector<ThunkSection<ELFT> *> &Thunks) {<br>
   // Order Thunks in ascending OutSecOff<br>
   auto ThunkCmp = [](const ThunkSection<ELFT> *A, const ThunkSection<ELFT> *B) {<br>
@@ -893,7 +893,7 @@ static void mergeThunks(OutputSection<EL<br>
              Thunks.end(), std::back_inserter(Tmp), MergeCmp);<br>
   OS->Sections = std::move(Tmp);<br>
   OS->Size = 0;<br>
-  OS->assignOffsets();<br>
+  OS->assignOffsets<ELFT>();<br>
 }<br>
<br>
 // Process all relocations from the InputSections that have been assigned<br>
@@ -907,14 +907,13 @@ static void mergeThunks(OutputSection<EL<br>
 // FIXME: All Thunks are assumed to be in range of the relocation. Range<br>
 // extension Thunks are not yet supported.<br>
 template <class ELFT><br>
-void createThunks(ArrayRef<<wbr>OutputSectionBase *> OutputSections) {<br>
+void createThunks(ArrayRef<<wbr>OutputSection *> OutputSections) {<br>
   // Track Symbols that already have a Thunk<br>
   DenseMap<SymbolBody *, Thunk<ELFT> *> ThunkedSymbols;<br>
   // Track InputSections that have a ThunkSection placed in front<br>
   DenseMap<InputSection *, ThunkSection<ELFT> *> ThunkedSections;<br>
   // Track the ThunksSections that need to be inserted into an OutputSection<br>
-  std::map<OutputSection<ELFT> *, std::vector<ThunkSection<ELFT> *>><br>
-      ThunkSections;<br>
+  std::map<OutputSection *, std::vector<ThunkSection<ELFT> *>> ThunkSections;<br>
<br>
   // Find or create a Thunk for Body for relocation Type<br>
   auto GetThunk = [&](SymbolBody &Body, uint32_t Type) {<br>
@@ -925,11 +924,11 @@ void createThunks(ArrayRef<<wbr>OutputSection<br>
   };<br>
<br>
   // Find or create a ThunkSection to be placed immediately before IS<br>
-  auto GetISThunkSec = [&](InputSection *IS, OutputSection<ELFT> *OS) {<br>
+  auto GetISThunkSec = [&](InputSection *IS, OutputSection *OS) {<br>
     ThunkSection<ELFT> *TS = ThunkedSections.lookup(IS);<br>
     if (TS)<br>
       return TS;<br>
-    auto *TOS = cast<OutputSection<ELFT>>(IS-><wbr>OutSec);<br>
+    auto *TOS = cast<OutputSection>(IS-><wbr>OutSec);<br>
     TS = make<ThunkSection<ELFT>>(TOS, IS->OutSecOff);<br>
     ThunkSections[OS].push_back(<wbr>TS);<br>
     ThunkedSections[IS] = TS;<br>
@@ -937,7 +936,7 @@ void createThunks(ArrayRef<<wbr>OutputSection<br>
   };<br>
   // Find or create a ThunkSection to be placed as last executable section in<br>
   // OS.<br>
-  auto GetOSThunkSec = [&](ThunkSection<ELFT> *&TS, OutputSection<ELFT> *OS) {<br>
+  auto GetOSThunkSec = [&](ThunkSection<ELFT> *&TS, OutputSection *OS) {<br>
     if (TS == nullptr) {<br>
       uint32_t Off = 0;<br>
       for (auto *IS : OS->Sections) {<br>
@@ -956,8 +955,8 @@ void createThunks(ArrayRef<<wbr>OutputSection<br>
   // We separate the creation of ThunkSections from the insertion of the<br>
   // ThunkSections back into the OutputSection as ThunkSections are not always<br>
   // inserted into the same OutputSection as the caller.<br>
-  for (OutputSectionBase *Base : OutputSections) {<br>
-    auto *OS = dyn_cast<OutputSection<ELFT>>(<wbr>Base);<br>
+  for (OutputSection *Base : OutputSections) {<br>
+    auto *OS = dyn_cast<OutputSection>(Base);<br>
     if (OS == nullptr)<br>
       continue;<br>
<br>
@@ -997,9 +996,9 @@ template void scanRelocations<ELF32BE>(I<br>
 template void scanRelocations<ELF64LE>(<wbr>InputSectionBase &);<br>
 template void scanRelocations<ELF64BE>(<wbr>InputSectionBase &);<br>
<br>
-template void createThunks<ELF32LE>(<wbr>ArrayRef<OutputSectionBase *>);<br>
-template void createThunks<ELF32BE>(<wbr>ArrayRef<OutputSectionBase *>);<br>
-template void createThunks<ELF64LE>(<wbr>ArrayRef<OutputSectionBase *>);<br>
-template void createThunks<ELF64BE>(<wbr>ArrayRef<OutputSectionBase *>);<br>
+template void createThunks<ELF32LE>(<wbr>ArrayRef<OutputSection *>);<br>
+template void createThunks<ELF32BE>(<wbr>ArrayRef<OutputSection *>);<br>
+template void createThunks<ELF64LE>(<wbr>ArrayRef<OutputSection *>);<br>
+template void createThunks<ELF64BE>(<wbr>ArrayRef<OutputSection *>);<br>
 }<br>
 }<br>
<br>
Modified: lld/trunk/ELF/Relocations.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.h?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>Relocations.h?rev=296127&r1=<wbr>296126&r2=296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Relocations.h (original)<br>
+++ lld/trunk/ELF/Relocations.h Fri Feb 24 09:07:30 2017<br>
@@ -17,7 +17,7 @@ namespace elf {<br>
 class SymbolBody;<br>
 class InputSection;<br>
 class InputSectionBase;<br>
-class OutputSectionBase;<br>
+class OutputSection;<br>
<br>
 // List of target-independent relocation types. Relocations read<br>
 // from files are converted to these types so that the main code<br>
@@ -112,7 +112,7 @@ struct Relocation {<br>
 template <class ELFT> void scanRelocations(<wbr>InputSectionBase &);<br>
<br>
 template <class ELFT><br>
-void createThunks(ArrayRef<<wbr>OutputSectionBase *> OutputSections);<br>
+void createThunks(ArrayRef<<wbr>OutputSection *> OutputSections);<br>
<br>
 // Return a int64_t to make sure we get the sign extension out of the way as<br>
 // early as possible.<br>
<br>
Modified: lld/trunk/ELF/SymbolTable.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>SymbolTable.cpp?rev=296127&r1=<wbr>296126&r2=296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/SymbolTable.cpp (original)<br>
+++ lld/trunk/ELF/SymbolTable.cpp Fri Feb 24 09:07:30 2017<br>
@@ -397,7 +397,7 @@ SymbolTable<ELFT>::addRegular(<wbr>StringRef<br>
<br>
 template <typename ELFT><br>
 Symbol *SymbolTable<ELFT>::<wbr>addSynthetic(StringRef N,<br>
-                                        const OutputSectionBase *Section,<br>
+                                        const OutputSection *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=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>SymbolTable.h?rev=296127&r1=<wbr>296126&r2=296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/SymbolTable.h (original)<br>
+++ lld/trunk/ELF/SymbolTable.h Fri Feb 24 09:07:30 2017<br>
@@ -19,7 +19,6 @@<br>
 namespace lld {<br>
 namespace elf {<br>
 class Lazy;<br>
-class OutputSectionBase;<br>
 struct Symbol;<br>
<br>
 // SymbolTable is a bucket of all known symbols, including defined,<br>
@@ -62,8 +61,8 @@ public:<br>
                      uintX_t Value, uintX_t Size, uint8_t Binding,<br>
                      InputSectionBase *Section, InputFile *File);<br>
<br>
-  Symbol *addSynthetic(StringRef N, const OutputSectionBase *Section,<br>
-                       uintX_t Value, uint8_t StOther);<br>
+  Symbol *addSynthetic(StringRef N, const OutputSection *Section, uintX_t Value,<br>
+                       uint8_t StOther);<br>
<br>
   void addShared(SharedFile<ELFT> *F, StringRef Name, const Elf_Sym &Sym,<br>
                  const typename ELFT::Verdef *Verdef);<br>
<br>
Modified: lld/trunk/ELF/Symbols.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Symbols.<wbr>cpp?rev=296127&r1=296126&r2=<wbr>296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Symbols.cpp (original)<br>
+++ lld/trunk/ELF/Symbols.cpp Fri Feb 24 09:07:30 2017<br>
@@ -35,7 +35,7 @@ static typename ELFT::uint getSymVA(cons<br>
   switch (Body.kind()) {<br>
   case SymbolBody::<wbr>DefinedSyntheticKind: {<br>
     auto &D = cast<DefinedSynthetic>(Body);<br>
-    const OutputSectionBase *Sec = D.Section;<br>
+    const OutputSection *Sec = D.Section;<br>
     if (!Sec)<br>
       return D.Value;<br>
     if (D.Value == uintX_t(-1))<br>
@@ -62,7 +62,7 @@ static typename ELFT::uint getSymVA(cons<br>
       Offset += Addend;<br>
       Addend = 0;<br>
     }<br>
-    const OutputSectionBase *OutSec = IS->getOutputSection<ELFT>();<br>
+    const OutputSection *OutSec = IS->getOutputSection<ELFT>();<br>
     uintX_t VA = (OutSec ? OutSec->Addr : 0) + IS->getOffset<ELFT>(Offset);<br>
     if (D.isTls() && !Config->Relocatable) {<br>
       if (!Out<ELFT>::TlsPhdr)<br>
<br>
Modified: lld/trunk/ELF/Symbols.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Symbols.<wbr>h?rev=296127&r1=296126&r2=<wbr>296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Symbols.h (original)<br>
+++ lld/trunk/ELF/Symbols.h Fri Feb 24 09:07:30 2017<br>
@@ -30,8 +30,7 @@ class BitcodeFile;<br>
 class InputFile;<br>
 class LazyObjectFile;<br>
 template <class ELFT> class ObjectFile;<br>
-template <class ELFT> class OutputSection;<br>
-class OutputSectionBase;<br>
+class OutputSection;<br>
 template <class ELFT> class SharedFile;<br>
<br>
 struct Symbol;<br>
@@ -219,8 +218,7 @@ template <class ELFT> InputSectionBase *<br>
 // If Section is null, this symbol is relative to the image base.<br>
 class DefinedSynthetic : public Defined {<br>
 public:<br>
-  DefinedSynthetic(StringRef Name, uint64_t Value,<br>
-                   const OutputSectionBase *Section)<br>
+  DefinedSynthetic(StringRef Name, uint64_t Value, const OutputSection *Section)<br>
       : Defined(SymbolBody::<wbr>DefinedSyntheticKind, Name, /*IsLocal=*/false,<br>
                 llvm::ELF::STV_HIDDEN, 0 /* Type */),<br>
         Value(Value), Section(Section) {}<br>
@@ -230,7 +228,7 @@ public:<br>
   }<br>
<br>
   uint64_t Value;<br>
-  const OutputSectionBase *Section;<br>
+  const OutputSection *Section;<br>
 };<br>
<br>
 class Undefined : public SymbolBody {<br>
<br>
Modified: lld/trunk/ELF/<wbr>SyntheticSections.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>SyntheticSections.cpp?rev=<wbr>296127&r1=296126&r2=296127&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/<wbr>SyntheticSections.cpp (original)<br>
+++ lld/trunk/ELF/<wbr>SyntheticSections.cpp Fri Feb 24 09:07:30 2017<br>
@@ -769,7 +769,7 @@ template <class ELFT><br>
 typename MipsGotSection<ELFT>::uintX_t<br>
 MipsGotSection<ELFT>::<wbr>getPageEntryOffset(const SymbolBody &B,<br>
                                          int64_t Addend) const {<br>
-  const OutputSectionBase *OutSec =<br>
+  const OutputSection *OutSec =<br>
       cast<DefinedRegular<ELFT>>(&B)<br>
           ->Section->template getOutputSection<ELFT>();<br>
   uintX_t SecAddr = getMipsPageAddr(OutSec->Addr);<br>
@@ -827,7 +827,7 @@ unsigned MipsGotSection<ELFT>::<wbr>getLocalE<br>
<br>
 template <class ELFT> void MipsGotSection<ELFT>::<wbr>finalize() {<br>
   PageEntriesNum = 0;<br>
-  for (std::pair<const OutputSectionBase *, size_t> &P : PageIndexMap) {<br>
+  for (std::pair<const OutputSection *, size_t> &P : PageIndexMap) {<br>
     // For each output section referenced by GOT page relocations calculate<br>
     // and save into PageIndexMap an upper bound of MIPS GOT entries required<br>
     // to store page addresses of local symbols. We assume the worst case -<br>
@@ -877,7 +877,7 @@ template <class ELFT> void MipsGotSectio<br>
   P[1] = uintX_t(1) << (ELFT::Is64Bits ? 63 : 31);<br>
   Buf += HeaderEntriesNum * sizeof(uintX_t);<br>
   // Write 'page address' entries to the local part of the GOT.<br>
-  for (std::pair<const OutputSectionBase *, size_t> &L : PageIndexMap) {<br>
+  for (std::pair<const OutputSection *, size_t> &L : PageIndexMap) {<br>
     size_t PageCount = getMipsPageCount(L.first-><wbr>Size);<br>
     uintX_t FirstPageAddr = getMipsPageAddr(L.first->Addr)<wbr>;<br>
     for (size_t PI = 0; PI < PageCount; ++PI) {<br>
@@ -1381,7 +1381,7 @@ void SymbolTableSection<ELFT>::<wbr>writeLoca<br>
       ESym->st_shndx = SHN_ABS;<br>
       ESym->st_value = Body.Value;<br>
     } else {<br>
-      const OutputSectionBase *OutSec = Section->getOutputSection<<wbr>ELFT>();<br>
+      const OutputSection *OutSec = Section->getOutputSection<<wbr>ELFT>();<br>
       ESym->st_shndx = OutSec->SectionIndex;<br>
       ESym->st_value = OutSec->Addr + Section->getOffset(Body);<br>
     }<br>
@@ -1412,7 +1412,7 @@ void SymbolTableSection<ELFT>::<wbr>writeGlob<br>
     ESym->setVisibility(Body-><wbr>symbol()->Visibility);<br>
     ESym->st_value = Body->getVA<ELFT>();<br>
<br>
-    if (const OutputSectionBase *OutSec = getOutputSection(Body)) {<br>
+    if (const OutputSection *OutSec = getOutputSection(Body)) {<br>
       ESym->st_shndx = OutSec->SectionIndex;<br>
     } else if (isa<DefinedRegular<ELFT>>(<wbr>Body)) {<br>
       ESym->st_shndx = SHN_ABS;<br>
@@ -1439,7 +1439,7 @@ void SymbolTableSection<ELFT>::<wbr>writeGlob<br>
 }<br>
<br>
 template <class ELFT><br>
-const OutputSectionBase *<br>
+const OutputSection *<br>
 SymbolTableSection<ELFT>::<wbr>getOutputSection(SymbolBody *Sym) {<br>
   switch (Sym->kind()) {<br>
   case SymbolBody::<wbr>DefinedSyntheticKind:<br>
@@ -2173,7 +2173,7 @@ ARMExidxSentinelSection<ELFT>:<wbr>:ARMExidxS<br>
 template <class ELFT><br>
 void ARMExidxSentinelSection<ELFT>:<wbr>:writeTo(uint8_t *Buf) {<br>
   // Get the InputSection before us, we are by definition last<br>
-  auto RI = cast<OutputSection<ELFT>>(<wbr>this->OutSec)->Sections.<wbr>rbegin();<br>
+  auto RI = cast<OutputSection>(this-><wbr>OutSec)->Sections.rbegin();<br>
   InputSection *LE = *(++RI);<br>
   InputSection *LC = cast<InputSection>(LE-><wbr>template getLinkOrderDep<ELFT>());<br>
   uint64_t S = LC->OutSec->Addr +<br>
@@ -2184,7 +2184,7 @@ void ARMExidxSentinelSection<ELFT>:<wbr>:writ<br>
 }<br>
<br>
 template <class ELFT><br>
-ThunkSection<ELFT>::<wbr>ThunkSection(OutputSectionBase *OS, uint64_t Off)<br>
+ThunkSection<ELFT>::<wbr>ThunkSection(OutputSection *OS, uint64_t Off)<br>
     : SyntheticSection<ELFT>(SHF_<wbr>ALLOC | SHF_EXECINSTR, SHT_PROGBITS,<br>
                              sizeof(typename ELFT::uint), ".text.thunk") {<br>
   this->OutSec = OS;<br>
<br>
Modified: lld/trunk/ELF/<wbr>SyntheticSections.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>SyntheticSections.h?rev=<wbr>296127&r1=296126&r2=296127&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/<wbr>SyntheticSections.h (original)<br>
+++ lld/trunk/ELF/<wbr>SyntheticSections.h Fri Feb 24 09:07:30 2017<br>
@@ -249,7 +249,7 @@ private:<br>
   uint32_t PageEntriesNum = 0;<br>
   // Map output sections referenced by MIPS GOT relocations<br>
   // to the first index of "Page" entries allocated for this section.<br>
-  llvm::SmallMapVector<const OutputSectionBase *, size_t, 16> PageIndexMap;<br>
+  llvm::SmallMapVector<const OutputSection *, size_t, 16> PageIndexMap;<br>
<br>
   typedef std::pair<const SymbolBody *, uintX_t> GotEntry;<br>
   typedef std::vector<GotEntry> GotEntries;<br>
@@ -364,13 +364,13 @@ class DynamicSection final : public Synt<br>
   struct Entry {<br>
     int32_t Tag;<br>
     union {<br>
-      OutputSectionBase *OutSec;<br>
+      OutputSection *OutSec;<br>
       InputSection *InSec;<br>
       uint64_t Val;<br>
       const SymbolBody *Sym;<br>
     };<br>
     enum KindT { SecAddr, SecSize, SymAddr, PlainInt, InSecAddr } Kind;<br>
-    Entry(int32_t Tag, OutputSectionBase *OutSec, KindT Kind = SecAddr)<br>
+    Entry(int32_t Tag, OutputSection *OutSec, KindT Kind = SecAddr)<br>
         : Tag(Tag), OutSec(OutSec), Kind(Kind) {}<br>
     Entry(int32_t Tag, InputSection *Sec)<br>
         : Tag(Tag), InSec(Sec), Kind(InSecAddr) {}<br>
@@ -443,7 +443,7 @@ public:<br>
<br>
   ArrayRef<SymbolTableEntry> getSymbols() const { return Symbols; }<br>
<br>
-  static const OutputSectionBase *getOutputSection(SymbolBody *Sym);<br>
+  static const OutputSection *getOutputSection(SymbolBody *Sym);<br>
<br>
 private:<br>
   void writeLocalSymbols(uint8_t *&Buf);<br>
@@ -777,7 +777,7 @@ public:<br>
 template <class ELFT> class ThunkSection : public SyntheticSection<ELFT> {<br>
 public:<br>
   // ThunkSection in OS, with desired OutSecOff of Off<br>
-  ThunkSection(OutputSectionBase *OS, uint64_t Off);<br>
+  ThunkSection(OutputSection *OS, uint64_t Off);<br>
<br>
   // Add a newly created Thunk to this container:<br>
   // Thunk is given offset from start of this InputSection<br>
<br>
Modified: lld/trunk/ELF/Target.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Target.<wbr>cpp?rev=296127&r1=296126&r2=<wbr>296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Target.cpp (original)<br>
+++ lld/trunk/ELF/Target.cpp Fri Feb 24 09:07:30 2017<br>
@@ -65,7 +65,7 @@ template <class ELFT> static std::string<br>
     if (!IS || !IS->OutSec)<br>
       continue;<br>
<br>
-    uint8_t *ISLoc = cast<OutputSection<ELFT>>(IS-><wbr>OutSec)->Loc + IS->OutSecOff;<br>
+    uint8_t *ISLoc = cast<OutputSection>(IS-><wbr>OutSec)->Loc + IS->OutSecOff;<br>
     if (ISLoc <= Loc && Loc < ISLoc + IS->template getSize<ELFT>())<br>
       return IS->template getLocation<ELFT>(Loc - ISLoc) + ": ";<br>
   }<br>
<br>
Modified: lld/trunk/ELF/Thunks.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Thunks.h?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Thunks.<wbr>h?rev=296127&r1=296126&r2=<wbr>296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Thunks.h (original)<br>
+++ lld/trunk/ELF/Thunks.h Fri Feb 24 09:07:30 2017<br>
@@ -16,7 +16,6 @@ namespace lld {<br>
 namespace elf {<br>
 class SymbolBody;<br>
 template <class ELFT> class ThunkSection;<br>
-class OutputSectionBase;<br>
 // Class to describe an instance of a Thunk.<br>
 // A Thunk is a code-sequence inserted by the linker in between a caller and<br>
 // the callee. The relocation to the callee is redirected to the Thunk, which<br>
<br>
Modified: lld/trunk/ELF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Writer.<wbr>cpp?rev=296127&r1=296126&r2=<wbr>296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Writer.cpp (original)<br>
+++ lld/trunk/ELF/Writer.cpp Fri Feb 24 09:07:30 2017<br>
@@ -77,14 +77,14 @@ private:<br>
<br>
   std::unique_ptr<<wbr>FileOutputBuffer> Buffer;<br>
<br>
-  std::vector<OutputSectionBase *> OutputSections;<br>
+  std::vector<OutputSection *> OutputSections;<br>
   OutputSectionFactory<ELFT> Factory{OutputSections};<br>
<br>
   void addRelIpltSymbols();<br>
   void addStartEndSymbols();<br>
-  void addStartStopSymbols(<wbr>OutputSectionBase *Sec);<br>
+  void addStartStopSymbols(<wbr>OutputSection *Sec);<br>
   uintX_t getEntryAddr();<br>
-  OutputSectionBase *findSection(StringRef Name);<br>
+  OutputSection *findSection(StringRef Name);<br>
<br>
   std::vector<PhdrEntry> Phdrs;<br>
<br>
@@ -313,18 +313,18 @@ template <class ELFT> void Writer<ELFT>:<br>
<br>
   // Create singleton output sections.<br>
   Out<ELFT>::Bss =<br>
-      make<OutputSection<ELFT>>(".<wbr>bss", SHT_NOBITS, SHF_ALLOC | SHF_WRITE);<br>
-  Out<ELFT>::BssRelRo = make<OutputSection<ELFT>>(".<a href="http://bss.rel.ro" rel="noreferrer" target="_blank">bs<wbr>s.rel.ro</a>", SHT_NOBITS,<br>
-                                                  SHF_ALLOC | SHF_WRITE);<br>
+      make<OutputSection>(".bss", SHT_NOBITS, SHF_ALLOC | SHF_WRITE);<br>
+  Out<ELFT>::BssRelRo =<br>
+      make<OutputSection>(".<a href="http://bss.rel.ro" rel="noreferrer" target="_blank">bss.rel.<wbr>ro</a>", SHT_NOBITS, SHF_ALLOC | SHF_WRITE);<br>
   In<ELFT>::DynStrTab = make<StringTableSection<ELFT>><wbr>(".dynstr", true);<br>
   In<ELFT>::Dynamic = make<DynamicSection<ELFT>>();<br>
   In<ELFT>::RelaDyn = make<RelocationSection<ELFT>>(<br>
       Config->Rela ? ".rela.dyn" : ".rel.dyn", Config->ZCombreloc);<br>
   In<ELFT>::ShStrTab = make<StringTableSection<ELFT>><wbr>(".shstrtab", false);<br>
<br>
-  Out<ELFT>::ElfHeader = make<OutputSectionBase>("", 0, SHF_ALLOC);<br>
+  Out<ELFT>::ElfHeader = make<OutputSection>("", 0, SHF_ALLOC);<br>
   Out<ELFT>::ElfHeader->Size = sizeof(Elf_Ehdr);<br>
-  Out<ELFT>::ProgramHeaders = make<OutputSectionBase>("", 0, SHF_ALLOC);<br>
+  Out<ELFT>::ProgramHeaders = make<OutputSection>("", 0, SHF_ALLOC);<br>
   Out<ELFT>::ProgramHeaders-><wbr>updateAlignment(sizeof(uintX_<wbr>t));<br>
<br>
   if (needsInterpSection<ELFT>()) {<br>
@@ -529,13 +529,10 @@ template <class ELFT> void Writer<ELFT>:<br>
 template <class ELFT> void Writer<ELFT>::<wbr>addSectionSymbols() {<br>
   // Create one STT_SECTION symbol for each output section we might<br>
   // have a relocation with.<br>
-  for (OutputSectionBase *Sec : OutputSections) {<br>
-    InputSectionBase *First = nullptr;<br>
-    Sec->forEachInputSection([&](<wbr>InputSectionBase *D) {<br>
-      if (!First)<br>
-        First = D;<br>
-    });<br>
-    auto *IS = dyn_cast_or_null<InputSection><wbr>(First);<br>
+  for (OutputSection *Sec : OutputSections) {<br>
+    InputSection *IS = nullptr;<br>
+    if (!Sec->Sections.empty())<br>
+      IS = Sec->Sections[0];<br>
     if (!IS || isa<SyntheticSection<ELFT>>(<wbr>IS) || IS->Type == SHT_REL ||<br>
         IS->Type == SHT_RELA)<br>
       continue;<br>
@@ -565,7 +562,7 @@ static int getPPC64SectionRank(StringRef<br>
<br>
 // All sections with SHF_MIPS_GPREL flag should be grouped together<br>
 // because data in these sections is addressable with a gp relative address.<br>
-static int getMipsSectionRank(const OutputSectionBase *S) {<br>
+static int getMipsSectionRank(const OutputSection *S) {<br>
   if ((S->Flags & SHF_MIPS_GPREL) == 0)<br>
     return 0;<br>
   if (S->Name == ".got")<br>
@@ -579,7 +576,7 @@ static int getMipsSectionRank(const Outp<br>
 //<br>
 // This function returns true if a section needs to be put into a<br>
 // PT_GNU_RELRO segment.<br>
-template <class ELFT> bool elf::isRelroSection(const OutputSectionBase *Sec) {<br>
+template <class ELFT> bool elf::isRelroSection(const OutputSection *Sec) {<br>
   if (!Config->ZRelro)<br>
     return false;<br>
<br>
@@ -609,8 +606,8 @@ template <class ELFT> bool elf::isRelroS<br>
 }<br>
<br>
 template <class ELFT><br>
-static bool compareSectionsNonScript(const OutputSectionBase *A,<br>
-                                     const OutputSectionBase *B) {<br>
+static bool compareSectionsNonScript(const OutputSection *A,<br>
+                                     const OutputSection *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->Name == ".interp";<br>
@@ -707,8 +704,7 @@ static bool compareSectionsNonScript(con<br>
<br>
 // Output section ordering is determined by this function.<br>
 template <class ELFT><br>
-static bool compareSections(const OutputSectionBase *A,<br>
-                            const OutputSectionBase *B) {<br>
+static bool compareSections(const OutputSection *A, const OutputSection *B) {<br>
   // For now, put sections mentioned in a linker script first.<br>
   int AIndex = Script<ELFT>::X-><wbr>getSectionIndex(A->Name);<br>
   int BIndex = Script<ELFT>::X-><wbr>getSectionIndex(B->Name);<br>
@@ -729,7 +725,7 @@ PhdrEntry::PhdrEntry(unsigned Type, unsi<br>
   p_flags = Flags;<br>
 }<br>
<br>
-void PhdrEntry::add(<wbr>OutputSectionBase *Sec) {<br>
+void PhdrEntry::add(OutputSection *Sec) {<br>
   Last = Sec;<br>
   if (!First)<br>
     First = Sec;<br>
@@ -740,7 +736,7 @@ void PhdrEntry::add(<wbr>OutputSectionBase *S<br>
<br>
 template <class ELFT><br>
 static DefinedSynthetic *<br>
-addOptionalSynthetic(<wbr>StringRef Name, OutputSectionBase *Sec,<br>
+addOptionalSynthetic(<wbr>StringRef Name, OutputSection *Sec,<br>
                      typename ELFT::uint Val, uint8_t StOther = STV_HIDDEN) {<br>
   if (SymbolBody *S = Symtab<ELFT>::X->find(Name))<br>
     if (!S->isInCurrentDSO())<br>
@@ -862,20 +858,20 @@ template <class ELFT> void Writer<ELFT>:<br>
<br>
 // Sort input sections by section name suffixes for<br>
 // __attribute__((init_priority(<wbr>N))).<br>
-template <class ELFT> static void sortInitFini(OutputSectionBase *S) {<br>
+template <class ELFT> static void sortInitFini(OutputSection *S) {<br>
   if (S)<br>
-    reinterpret_cast<<wbr>OutputSection<ELFT> *>(S)->sortInitFini();<br>
+    reinterpret_cast<OutputSection *>(S)->sortInitFini();<br>
 }<br>
<br>
 // Sort input sections by the special rule for .ctors and .dtors.<br>
-template <class ELFT> static void sortCtorsDtors(<wbr>OutputSectionBase *S) {<br>
+template <class ELFT> static void sortCtorsDtors(OutputSection *S) {<br>
   if (S)<br>
-    reinterpret_cast<<wbr>OutputSection<ELFT> *>(S)->sortCtorsDtors();<br>
+    reinterpret_cast<OutputSection *>(S)->sortCtorsDtors();<br>
 }<br>
<br>
 // Sort input sections using the list provided by --symbol-ordering-file.<br>
 template <class ELFT><br>
-static void sortBySymbolsOrder(ArrayRef<<wbr>OutputSectionBase *> OutputSections) {<br>
+static void sortBySymbolsOrder(ArrayRef<<wbr>OutputSection *> OutputSections) {<br>
   if (Config->SymbolOrderingFile.<wbr>empty())<br>
     return;<br>
<br>
@@ -900,8 +896,8 @@ static void sortBySymbolsOrder(ArrayRef<<br>
   }<br>
<br>
   // Sort sections by priority.<br>
-  for (OutputSectionBase *Base : OutputSections)<br>
-    if (auto *Sec = dyn_cast<OutputSection<ELFT>>(<wbr>Base))<br>
+  for (OutputSection *Base : OutputSections)<br>
+    if (auto *Sec = dyn_cast<OutputSection>(Base))<br>
       Sec->sort([&](InputSectionBase *S) { return SectionOrder.lookup(S); });<br>
 }<br>
<br>
@@ -933,13 +929,12 @@ template <class ELFT> void Writer<ELFT>:<br>
   sortCtorsDtors<ELFT>(<wbr>findSection(".ctors"));<br>
   sortCtorsDtors<ELFT>(<wbr>findSection(".dtors"));<br>
<br>
-  for (OutputSectionBase *Sec : OutputSections)<br>
-    Sec->assignOffsets();<br>
+  for (OutputSection *Sec : OutputSections)<br>
+    Sec->assignOffsets<ELFT>();<br>
 }<br>
<br>
 template <class ELFT><br>
-static bool canSharePtLoad(const OutputSectionBase &S1,<br>
-                           const OutputSectionBase &S2) {<br>
+static bool canSharePtLoad(const OutputSection &S1, const OutputSection &S2) {<br>
   if (!(S1.Flags & SHF_ALLOC) || !(S2.Flags & SHF_ALLOC))<br>
     return false;<br>
<br>
@@ -995,12 +990,12 @@ template <class ELFT> void Writer<ELFT>:<br>
   auto I = OutputSections.begin();<br>
   auto E = OutputSections.end();<br>
   auto NonScriptI =<br>
-      std::find_if(OutputSections.<wbr>begin(), E, [](OutputSectionBase *S) {<br>
+      std::find_if(OutputSections.<wbr>begin(), E, [](OutputSection *S) {<br>
         return Script<ELFT>::X-><wbr>getSectionIndex(S->Name) == INT_MAX;<br>
       });<br>
   while (NonScriptI != E) {<br>
     auto BestPos = std::max_element(<br>
-        I, NonScriptI, [&](OutputSectionBase *&A, OutputSectionBase *&B) {<br>
+        I, NonScriptI, [&](OutputSection *&A, OutputSection *&B) {<br>
           bool ACanSharePtLoad = canSharePtLoad<ELFT>(**<wbr>NonScriptI, *A);<br>
           bool BCanSharePtLoad = canSharePtLoad<ELFT>(**<wbr>NonScriptI, *B);<br>
           if (ACanSharePtLoad != BCanSharePtLoad)<br>
@@ -1036,7 +1031,7 @@ finalizeSynthetic(const std::vector<Synt<br>
     if (SS && SS->OutSec && !SS->empty()) {<br>
       SS->finalize();<br>
       SS->OutSec->Size = 0;<br>
-      SS->OutSec->assignOffsets();<br>
+      SS->OutSec->template assignOffsets<ELFT>();<br>
     }<br>
 }<br>
<br>
@@ -1045,7 +1040,7 @@ finalizeSynthetic(const std::vector<Synt<br>
 // required to be in output. For example we don't need dynamic section content<br>
 // sometimes. This function filters out such unused sections from output.<br>
 template <class ELFT><br>
-static void removeUnusedSyntheticSections(<wbr>std::vector<OutputSectionBase *> &V) {<br>
+static void removeUnusedSyntheticSections(<wbr>std::vector<OutputSection *> &V) {<br>
   // All input synthetic sections that can be empty are placed after<br>
   // all regular ones. We iterate over them all and exit at first<br>
   // non-synthetic.<br>
@@ -1056,7 +1051,7 @@ static void removeUnusedSyntheticSection<br>
     if (!SS->empty() || !SS->OutSec)<br>
       continue;<br>
<br>
-    OutputSection<ELFT> *OutSec = cast<OutputSection<ELFT>>(SS-><wbr>OutSec);<br>
+    OutputSection *OutSec = cast<OutputSection>(SS-><wbr>OutSec);<br>
     OutSec->Sections.erase(<br>
         std::find(OutSec->Sections.<wbr>begin(), OutSec->Sections.end(), SS));<br>
     // If there is no other sections in output section, remove it from output.<br>
@@ -1077,7 +1072,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 *Sec : OutputSections)<br>
+    for (OutputSection *Sec : OutputSections)<br>
       addStartStopSymbols(Sec);<br>
   }<br>
<br>
@@ -1140,7 +1135,7 @@ template <class ELFT> void Writer<ELFT>:<br>
   Out<ELFT>::ElfHeader-><wbr>SectionIndex = 1;<br>
<br>
   unsigned I = 1;<br>
-  for (OutputSectionBase *Sec : OutputSections) {<br>
+  for (OutputSection *Sec : OutputSections) {<br>
     Sec->SectionIndex = I++;<br>
     Sec->ShName = In<ELFT>::ShStrTab->addString(<wbr>Sec->Name);<br>
   }<br>
@@ -1164,8 +1159,8 @@ 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 *Sec : OutputSections)<br>
-    Sec->finalize();<br>
+  for (OutputSection *Sec : OutputSections)<br>
+    Sec->finalize<ELFT>();<br>
<br>
   // Dynamic section must be the last one in this list and dynamic<br>
   // symbol table section (DynSymTab) must be the first one.<br>
@@ -1182,9 +1177,9 @@ template <class ELFT> void Writer<ELFT>:<br>
<br>
 template <class ELFT> void Writer<ELFT>::<wbr>addPredefinedSections() {<br>
   // Add BSS sections.<br>
-  auto Add = [=](OutputSection<ELFT> *Sec) {<br>
+  auto Add = [=](OutputSection *Sec) {<br>
     if (!Sec->Sections.empty()) {<br>
-      Sec->assignOffsets();<br>
+      Sec->assignOffsets<ELFT>();<br>
       OutputSections.push_back(Sec);<br>
     }<br>
   };<br>
@@ -1193,7 +1188,7 @@ template <class ELFT> void Writer<ELFT>:<br>
<br>
   // ARM ABI requires .ARM.exidx to be terminated by some piece of data.<br>
   // We have the terminater synthetic section class. Add that at the end.<br>
-  auto *OS = dyn_cast_or_null<<wbr>OutputSection<ELFT>>(<wbr>findSection(".ARM.exidx"));<br>
+  auto *OS = dyn_cast_or_null<<wbr>OutputSection>(findSection(".<wbr>ARM.exidx"));<br>
   if (OS && !OS->Sections.empty() && !Config->Relocatable)<br>
     OS->addSection(make<<wbr>ARMExidxSentinelSection<ELFT>><wbr>());<br>
 }<br>
@@ -1201,7 +1196,7 @@ 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>::<wbr>addStartEndSymbols() {<br>
-  auto Define = [&](StringRef Start, StringRef End, OutputSectionBase *OS) {<br>
+  auto Define = [&](StringRef Start, StringRef End, OutputSection *OS) {<br>
     // These symbols resolve to the image base if the section does not exist.<br>
     // A special value -1 indicates end of the section.<br>
     addOptionalSynthetic<ELFT>(<wbr>Start, OS, 0);<br>
@@ -1213,7 +1208,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 *Sec = findSection(".ARM.exidx"))<br>
+  if (OutputSection *Sec = findSection(".ARM.exidx"))<br>
     Define("__exidx_start", "__exidx_end", Sec);<br>
 }<br>
<br>
@@ -1223,7 +1218,7 @@ 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>::<wbr>addStartStopSymbols(<wbr>OutputSectionBase *Sec) {<br>
+void Writer<ELFT>::<wbr>addStartStopSymbols(<wbr>OutputSection *Sec) {<br>
   StringRef S = Sec->Name;<br>
   if (!isValidCIdentifier(S))<br>
     return;<br>
@@ -1231,15 +1226,14 @@ void Writer<ELFT>::<wbr>addStartStopSymbols(O<br>
   addOptionalSynthetic<ELFT>(<wbr>Saver.save("__stop_" + S), Sec, -1, STV_DEFAULT);<br>
 }<br>
<br>
-template <class ELFT><br>
-OutputSectionBase *Writer<ELFT>::findSection(<wbr>StringRef Name) {<br>
-  for (OutputSectionBase *Sec : OutputSections)<br>
+template <class ELFT> OutputSection *Writer<ELFT>::findSection(<wbr>StringRef Name) {<br>
+  for (OutputSection *Sec : OutputSections)<br>
     if (Sec->Name == Name)<br>
       return Sec;<br>
   return nullptr;<br>
 }<br>
<br>
-template <class ELFT> static bool needsPtLoad(OutputSectionBase *Sec) {<br>
+template <class ELFT> static bool needsPtLoad(OutputSection *Sec) {<br>
   if (!(Sec->Flags & SHF_ALLOC))<br>
     return false;<br>
<br>
@@ -1277,13 +1271,13 @@ template <class ELFT> std::vector<PhdrEn<br>
   AddHdr(PT_PHDR, PF_R)->add(Out<ELFT>::<wbr>ProgramHeaders);<br>
<br>
   // PT_INTERP must be the second entry if exists.<br>
-  if (OutputSectionBase *Sec = findSection(".interp"))<br>
+  if (OutputSection *Sec = findSection(".interp"))<br>
     AddHdr(PT_INTERP, Sec->getPhdrFlags())->add(Sec)<wbr>;<br>
<br>
   // Add the first PT_LOAD segment for regular output sections.<br>
   uintX_t Flags = computeFlags<ELFT>(PF_R);<br>
   PhdrEntry *Load = AddHdr(PT_LOAD, Flags);<br>
-  for (OutputSectionBase *Sec : OutputSections) {<br>
+  for (OutputSection *Sec : OutputSections) {<br>
     if (!(Sec->Flags & SHF_ALLOC))<br>
       break;<br>
     if (!needsPtLoad<ELFT>(Sec))<br>
@@ -1305,7 +1299,7 @@ template <class ELFT> std::vector<PhdrEn<br>
<br>
   // Add a TLS segment if any.<br>
   PhdrEntry TlsHdr(PT_TLS, PF_R);<br>
-  for (OutputSectionBase *Sec : OutputSections)<br>
+  for (OutputSection *Sec : OutputSections)<br>
     if (Sec->Flags & SHF_TLS)<br>
       TlsHdr.add(Sec);<br>
   if (TlsHdr.First)<br>
@@ -1319,7 +1313,7 @@ template <class ELFT> std::vector<PhdrEn<br>
   // PT_GNU_RELRO includes all sections that should be marked as<br>
   // read-only by dynamic linker after proccessing relocations.<br>
   PhdrEntry RelRo(PT_GNU_RELRO, PF_R);<br>
-  for (OutputSectionBase *Sec : OutputSections)<br>
+  for (OutputSection *Sec : OutputSections)<br>
     if (needsPtLoad<ELFT>(Sec) && isRelroSection<ELFT>(Sec))<br>
       RelRo.add(Sec);<br>
   if (RelRo.First)<br>
@@ -1333,7 +1327,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 *Sec = findSection(".openbsd.<wbr>randomdata"))<br>
+  if (OutputSection *Sec = findSection(".openbsd.<wbr>randomdata"))<br>
     AddHdr(PT_OPENBSD_RANDOMIZE, Sec->getPhdrFlags())->add(Sec)<wbr>;<br>
<br>
   // PT_GNU_STACK is a special section to tell the loader to make the<br>
@@ -1356,7 +1350,7 @@ template <class ELFT> std::vector<PhdrEn<br>
<br>
   // Create one PT_NOTE per a group of contiguous .note sections.<br>
   PhdrEntry *Note = nullptr;<br>
-  for (OutputSectionBase *Sec : OutputSections) {<br>
+  for (OutputSection *Sec : OutputSections) {<br>
     if (Sec->Type == SHT_NOTE) {<br>
       if (!Note || Script<ELFT>::X->hasLMA(Sec-><wbr>Name))<br>
         Note = AddHdr(PT_NOTE, PF_R);<br>
@@ -1374,7 +1368,7 @@ void Writer<ELFT>::addPtArmExid(<wbr>std::vec<br>
     return;<br>
   auto I = std::find_if(<br>
       OutputSections.begin(), OutputSections.end(),<br>
-      [](OutputSectionBase *Sec) { return Sec->Type == SHT_ARM_EXIDX; });<br>
+      [](OutputSection *Sec) { return Sec->Type == SHT_ARM_EXIDX; });<br>
   if (I == OutputSections.end())<br>
     return;<br>
<br>
@@ -1403,7 +1397,7 @@ template <class ELFT> void Writer<ELFT>:<br>
     auto I = std::find(OutputSections.<wbr>begin(), End, P.Last);<br>
     if (I == End || (I + 1) == End)<br>
       continue;<br>
-    OutputSectionBase *Sec = *(I + 1);<br>
+    OutputSection *Sec = *(I + 1);<br>
     if (needsPtLoad<ELFT>(Sec))<br>
       Sec->PageAlign = true;<br>
   }<br>
@@ -1411,7 +1405,7 @@ template <class ELFT> void Writer<ELFT>:<br>
<br>
 template <class ELFT><br>
 bool elf::allocateHeaders(std::<wbr>vector<PhdrEntry> &Phdrs,<br>
-                          ArrayRef<OutputSectionBase *> OutputSections,<br>
+                          ArrayRef<OutputSection *> OutputSections,<br>
                           uint64_t Min) {<br>
   auto FirstPTLoad =<br>
       std::find_if(Phdrs.begin(), Phdrs.end(),<br>
@@ -1440,7 +1434,7 @@ bool elf::allocateHeaders(std::<wbr>vector<Ph<br>
     return true;<br>
<br>
   if (FirstPTLoad->First)<br>
-    for (OutputSectionBase *Sec : OutputSections)<br>
+    for (OutputSection *Sec : OutputSections)<br>
       if (Sec->FirstInPtLoad == FirstPTLoad->First)<br>
         Sec->FirstInPtLoad = Out<ELFT>::ElfHeader;<br>
   FirstPTLoad->First = Out<ELFT>::ElfHeader;<br>
@@ -1474,7 +1468,7 @@ template <class ELFT> void Writer<ELFT>:<br>
   if (AllocateHeader)<br>
     VA += getHeaderSize<ELFT>();<br>
   uintX_t ThreadBssOffset = 0;<br>
-  for (OutputSectionBase *Sec : OutputSections) {<br>
+  for (OutputSection *Sec : OutputSections) {<br>
     uintX_t Alignment = Sec->Addralign;<br>
     if (Sec->PageAlign)<br>
       Alignment = std::max<uintX_t>(Alignment, Config->MaxPageSize);<br>
@@ -1502,8 +1496,8 @@ 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 *Sec) {<br>
-  OutputSectionBase *First = Sec->FirstInPtLoad;<br>
+static uintX_t getFileAlignment(uintX_t Off, OutputSection *Sec) {<br>
+  OutputSection *First = Sec->FirstInPtLoad;<br>
   // If the section is not in a PT_LOAD, we just have to align it.<br>
   if (!First)<br>
     return alignTo(Off, Sec->Addralign);<br>
@@ -1519,7 +1513,7 @@ static uintX_t getFileAlignment(uintX_t<br>
 }<br>
<br>
 template <class ELFT, class uintX_t><br>
-static uintX_t setOffset(OutputSectionBase *Sec, uintX_t Off) {<br>
+static uintX_t setOffset(OutputSection *Sec, uintX_t Off) {<br>
   if (Sec->Type == SHT_NOBITS) {<br>
     Sec->Offset = Off;<br>
     return Off;<br>
@@ -1532,7 +1526,7 @@ static uintX_t setOffset(OutputSectionBa<br>
<br>
 template <class ELFT> void Writer<ELFT>::<wbr>assignFileOffsetsBinary() {<br>
   uintX_t Off = 0;<br>
-  for (OutputSectionBase *Sec : OutputSections)<br>
+  for (OutputSection *Sec : OutputSections)<br>
     if (Sec->Flags & SHF_ALLOC)<br>
       Off = setOffset<ELFT>(Sec, Off);<br>
   FileSize = alignTo(Off, sizeof(uintX_t));<br>
@@ -1544,7 +1538,7 @@ template <class ELFT> void Writer<ELFT>:<br>
   Off = setOffset<ELFT>(Out<ELFT>::<wbr>ElfHeader, Off);<br>
   Off = setOffset<ELFT>(Out<ELFT>::<wbr>ProgramHeaders, Off);<br>
<br>
-  for (OutputSectionBase *Sec : OutputSections)<br>
+  for (OutputSection *Sec : OutputSections)<br>
     Off = setOffset<ELFT>(Sec, Off);<br>
<br>
   SectionHeaderOff = alignTo(Off, sizeof(uintX_t));<br>
@@ -1555,8 +1549,8 @@ template <class ELFT> void Writer<ELFT>:<br>
 // file offsets and VAs to all sections.<br>
 template <class ELFT> void Writer<ELFT>::setPhdrs() {<br>
   for (PhdrEntry &P : Phdrs) {<br>
-    OutputSectionBase *First = P.First;<br>
-    OutputSectionBase *Last = P.Last;<br>
+    OutputSection *First = P.First;<br>
+    OutputSection *Last = P.Last;<br>
     if (First) {<br>
       P.p_filesz = Last->Offset - First->Offset;<br>
       if (Last->Type != SHT_NOBITS)<br>
@@ -1604,7 +1598,7 @@ template <class ELFT> typename ELFT::uin<br>
     return Addr;<br>
<br>
   // Case 4<br>
-  if (OutputSectionBase *Sec = findSection(".text")) {<br>
+  if (OutputSection *Sec = findSection(".text")) {<br>
     if (Config->WarnMissingEntry)<br>
       warn("cannot find entry symbol " + Config->Entry + "; defaulting to 0x" +<br>
            utohexstr(Sec->Addr));<br>
@@ -1636,8 +1630,8 @@ static uint16_t getELFType() {<br>
 // to each section. This function fixes some predefined<br>
 // symbol values that depend on section address and size.<br>
 template <class ELFT> void Writer<ELFT>::<wbr>fixPredefinedSymbols() {<br>
-  auto Set = [](DefinedSynthetic *S1, DefinedSynthetic *S2,<br>
-                OutputSectionBase *Sec, uint64_t Value) {<br>
+  auto Set = [](DefinedSynthetic *S1, DefinedSynthetic *S2, OutputSection *Sec,<br>
+                uint64_t Value) {<br>
     if (S1) {<br>
       S1->Section = Sec;<br>
       S1->Value = Value;<br>
@@ -1679,7 +1673,7 @@ template <class ELFT> void Writer<ELFT>:<br>
       // Find GP-relative section with the lowest address<br>
       // and use this address to calculate default _gp value.<br>
       uintX_t Gp = -1;<br>
-      for (const OutputSectionBase * OS : OutputSections)<br>
+      for (const OutputSection *OS : OutputSections)<br>
         if ((OS->Flags & SHF_MIPS_GPREL) && OS->Addr < Gp)<br>
           Gp = OS->Addr;<br>
       if (Gp != (uintX_t)-1)<br>
@@ -1742,7 +1736,7 @@ 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 *Sec : OutputSections)<br>
+  for (OutputSection *Sec : OutputSections)<br>
     Sec->writeHeaderTo<ELFT>(++<wbr>SHdrs);<br>
 }<br>
<br>
@@ -1796,9 +1790,9 @@ template <class ELFT> void Writer<ELFT>:<br>
<br>
 template <class ELFT> void Writer<ELFT>::<wbr>writeSectionsBinary() {<br>
   uint8_t *Buf = Buffer->getBufferStart();<br>
-  for (OutputSectionBase *Sec : OutputSections)<br>
+  for (OutputSection *Sec : OutputSections)<br>
     if (Sec->Flags & SHF_ALLOC)<br>
-      Sec->writeTo(Buf + Sec->Offset);<br>
+      Sec->writeTo<ELFT>(Buf + Sec->Offset);<br>
 }<br>
<br>
 // Write section contents to a mmap'ed file.<br>
@@ -1810,28 +1804,28 @@ template <class ELFT> void Writer<ELFT>:<br>
   Out<ELFT>::Opd = findSection(".opd");<br>
   if (Out<ELFT>::Opd) {<br>
     Out<ELFT>::OpdBuf = Buf + Out<ELFT>::Opd->Offset;<br>
-    Out<ELFT>::Opd->writeTo(Buf + Out<ELFT>::Opd->Offset);<br>
+    Out<ELFT>::Opd->template writeTo<ELFT>(Buf + Out<ELFT>::Opd->Offset);<br>
   }<br>
<br>
-  OutputSectionBase *EhFrameHdr =<br>
+  OutputSection *EhFrameHdr =<br>
       In<ELFT>::EhFrameHdr ? In<ELFT>::EhFrameHdr->OutSec : nullptr;<br>
<br>
   // In -r or -emit-relocs mode, write the relocation sections first as in<br>
   // ELf_Rel targets we might find out that we need to modify the relocated<br>
   // section while doing it.<br>
-  for (OutputSectionBase *Sec : OutputSections)<br>
+  for (OutputSection *Sec : OutputSections)<br>
     if (Sec->Type == SHT_REL || Sec->Type == SHT_RELA)<br>
-      Sec->writeTo(Buf + Sec->Offset);<br>
+      Sec->writeTo<ELFT>(Buf + Sec->Offset);<br>
<br>
-  for (OutputSectionBase *Sec : OutputSections)<br>
+  for (OutputSection *Sec : OutputSections)<br>
     if (Sec != Out<ELFT>::Opd && Sec != EhFrameHdr && Sec->Type != SHT_REL &&<br>
         Sec->Type != SHT_RELA)<br>
-      Sec->writeTo(Buf + Sec->Offset);<br>
+      Sec->writeTo<ELFT>(Buf + Sec->Offset);<br>
<br>
   // The .eh_frame_hdr depends on .eh_frame section contents, therefore<br>
   // it should be written after .eh_frame is written.<br>
   if (EhFrameHdr)<br>
-    EhFrameHdr->writeTo(Buf + EhFrameHdr->Offset);<br>
+    EhFrameHdr->writeTo<ELFT>(Buf + EhFrameHdr->Offset);<br>
 }<br>
<br>
 template <class ELFT> void Writer<ELFT>::writeBuildId() {<br>
@@ -1850,19 +1844,19 @@ template void elf::writeResult<ELF64LE>(<br>
 template void elf::writeResult<ELF64BE>();<br>
<br>
 template bool elf::allocateHeaders<ELF32LE>(<wbr>std::vector<PhdrEntry> &,<br>
-                                            ArrayRef<OutputSectionBase *>,<br>
+                                            ArrayRef<OutputSection *>,<br>
                                             uint64_t);<br>
 template bool elf::allocateHeaders<ELF32BE>(<wbr>std::vector<PhdrEntry> &,<br>
-                                            ArrayRef<OutputSectionBase *>,<br>
+                                            ArrayRef<OutputSection *>,<br>
                                             uint64_t);<br>
 template bool elf::allocateHeaders<ELF64LE>(<wbr>std::vector<PhdrEntry> &,<br>
-                                            ArrayRef<OutputSectionBase *>,<br>
+                                            ArrayRef<OutputSection *>,<br>
                                             uint64_t);<br>
 template bool elf::allocateHeaders<ELF64BE>(<wbr>std::vector<PhdrEntry> &,<br>
-                                            ArrayRef<OutputSectionBase *>,<br>
+                                            ArrayRef<OutputSection *>,<br>
                                             uint64_t);<br>
<br>
-template bool elf::isRelroSection<ELF32LE>(<wbr>const OutputSectionBase *);<br>
-template bool elf::isRelroSection<ELF32BE>(<wbr>const OutputSectionBase *);<br>
-template bool elf::isRelroSection<ELF64LE>(<wbr>const OutputSectionBase *);<br>
-template bool elf::isRelroSection<ELF64BE>(<wbr>const OutputSectionBase *);<br>
+template bool elf::isRelroSection<ELF32LE>(<wbr>const OutputSection *);<br>
+template bool elf::isRelroSection<ELF32BE>(<wbr>const OutputSection *);<br>
+template bool elf::isRelroSection<ELF64LE>(<wbr>const OutputSection *);<br>
+template bool elf::isRelroSection<ELF64BE>(<wbr>const OutputSection *);<br>
<br>
Modified: lld/trunk/ELF/Writer.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.h?rev=296127&r1=296126&r2=296127&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Writer.<wbr>h?rev=296127&r1=296126&r2=<wbr>296127&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Writer.h (original)<br>
+++ lld/trunk/ELF/Writer.h Fri Feb 24 09:07:30 2017<br>
@@ -18,20 +18,20 @@<br>
 namespace lld {<br>
 namespace elf {<br>
 class InputFile;<br>
-class OutputSectionBase;<br>
+class OutputSection;<br>
 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 *Sec);<br>
+template <class ELFT> bool isRelroSection(const OutputSection *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>
 struct PhdrEntry {<br>
   PhdrEntry(unsigned Type, unsigned Flags);<br>
-  void add(OutputSectionBase *Sec);<br>
+  void add(OutputSection *Sec);<br>
<br>
   uint64_t p_paddr = 0;<br>
   uint64_t p_vaddr = 0;<br>
@@ -42,16 +42,16 @@ struct PhdrEntry {<br>
   uint32_t p_type = 0;<br>
   uint32_t p_flags = 0;<br>
<br>
-  OutputSectionBase *First = nullptr;<br>
-  OutputSectionBase *Last = nullptr;<br>
+  OutputSection *First = nullptr;<br>
+  OutputSection *Last = nullptr;<br>
   bool HasLMA = false;<br>
 };<br>
<br>
 llvm::StringRef getOutputSectionName(llvm::<wbr>StringRef Name);<br>
<br>
 template <class ELFT><br>
-bool allocateHeaders(std::vector<<wbr>PhdrEntry> &,<br>
-                     llvm::ArrayRef<<wbr>OutputSectionBase *>, uint64_t Min);<br>
+bool allocateHeaders(std::vector<<wbr>PhdrEntry> &, llvm::ArrayRef<OutputSection *>,<br>
+                     uint64_t Min);<br>
<br>
 template <class ELFT> uint32_t getMipsEFlags();<br>
<br>
<br>
<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>
</blockquote></div><br></div>