[rust] Fix lld build errors with GCC 5.2
diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp
index 56a516f..34f8f1a 100644
--- a/lld/ELF/Arch/RISCV.cpp
+++ b/lld/ELF/Arch/RISCV.cpp
@@ -618,9 +618,9 @@
         valueDelta[sa[0].d] = delta;
     delta = aux.relocDeltas[it.index()];
   }
-  for (const SymbolAnchor &sa : sa)
-    if (!sa.end)
-      valueDelta[sa.d] = delta;
+  for (const SymbolAnchor &saElem : sa)
+    if (!saElem.end)
+      valueDelta[saElem.d] = delta;
   sa = makeArrayRef(aux.anchors);
   delta = 0;
 
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 473809b..8a96521b 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -185,14 +185,14 @@
 
   // .so file
   if (auto *f = dyn_cast<SharedFile>(file)) {
-    f->parse<ELFT>();
+    f->template parse<ELFT>();
     return;
   }
 
   // LLVM bitcode file
   if (auto *f = dyn_cast<BitcodeFile>(file)) {
     ctx->bitcodeFiles.push_back(f);
-    f->parse<ELFT>();
+    f->template parse<ELFT>();
     return;
   }
 
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 8fe36ec..b71fef5 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -130,7 +130,7 @@
     return {};
   RelsOrRelas<ELFT> ret;
   typename ELFT::Shdr shdr =
-      cast<ELFFileBase>(file)->getELFShdrs<ELFT>()[relSecIdx];
+      cast<ELFFileBase>(file)->template getELFShdrs<ELFT>()[relSecIdx];
   if (shdr.sh_type == SHT_REL) {
     ret.rels = makeArrayRef(reinterpret_cast<const typename ELFT::Rel *>(
                                 file->mb.getBufferStart() + shdr.sh_offset),
@@ -413,7 +413,7 @@
         // individual "gp" values used by each input object file.
         // As a workaround we add the "gp" value to the relocation
         // addend and save it back to the file.
-        addend += sec->getFile<ELFT>()->mipsGp0;
+        addend += sec->template getFile<ELFT>()->mipsGp0;
       }
 
       if (RelTy::IsRela)
@@ -963,9 +963,9 @@
   // locations with tombstone values.
   const RelsOrRelas<ELFT> rels = sec->template relsOrRelas<ELFT>();
   if (rels.areRelocsRel())
-    sec->relocateNonAlloc<ELFT>(buf, rels.rels);
+    sec->template relocateNonAlloc<ELFT>(buf, rels.rels);
   else
-    sec->relocateNonAlloc<ELFT>(buf, rels.relas);
+    sec->template relocateNonAlloc<ELFT>(buf, rels.relas);
 }
 
 void InputSectionBase::relocateAlloc(uint8_t *buf, uint8_t *bufEnd) {
@@ -1172,7 +1172,8 @@
     // conservative.
     if (Defined *d = dyn_cast<Defined>(rel.sym))
       if (InputSection *isec = cast_or_null<InputSection>(d->section))
-        if (!isec || !isec->getFile<ELFT>() || isec->getFile<ELFT>()->splitStack)
+        if (!isec || !isec->template getFile<ELFT>() ||
+            isec->template getFile<ELFT>()->splitStack)
           continue;
 
     if (enclosingPrologueAttempted(rel.offset, prologues))
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 5abf0a9..9a21fde 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -197,7 +197,7 @@
       auto *opt = reinterpret_cast<const Elf_Mips_Options *>(d.data());
       if (opt->kind == ODK_REGINFO) {
         reginfo.ri_gprmask |= opt->getRegInfo().ri_gprmask;
-        sec->getFile<ELFT>()->mipsGp0 = opt->getRegInfo().ri_gp_value;
+        sec->template getFile<ELFT>()->mipsGp0 = opt->getRegInfo().ri_gp_value;
         break;
       }
 
@@ -249,7 +249,7 @@
 
     auto *r = reinterpret_cast<const Elf_Mips_RegInfo *>(sec->rawData.data());
     reginfo.ri_gprmask |= r->ri_gprmask;
-    sec->getFile<ELFT>()->mipsGp0 = r->ri_gp_value;
+    sec->template getFile<ELFT>()->mipsGp0 = r->ri_gp_value;
   };
 
   return std::make_unique<MipsReginfoSection<ELFT>>(reginfo);
@@ -3360,7 +3360,7 @@
       if (auto *s = dyn_cast<MergeInputSection>(sec))
         s->splitIntoPieces();
       else if (auto *eh = dyn_cast<EhInputSection>(sec))
-        eh->split<ELFT>();
+        eh->template split<ELFT>();
     }
   });
 }