ELF2: Remove setNameOffset and combine that with writeHeader. NFC.

llvm-svn: 251193
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index ff80e65..18ca872 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -224,6 +224,7 @@
 
 template <class ELFT>
 void OutputSectionBase<ELFT>::writeHeaderTo(Elf_Shdr *SHdr) {
+  Header.sh_name = Out<ELFT>::ShStrTab->getOffset(Name);
   *SHdr = Header;
 }
 
diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h
index 4892e7d..de42db0 100644
--- a/lld/ELF/OutputSections.h
+++ b/lld/ELF/OutputSections.h
@@ -80,7 +80,6 @@
   void setFileOffset(uintX_t Off) { Header.sh_offset = Off; }
   void writeHeaderTo(Elf_Shdr *SHdr);
   StringRef getName() { return Name; }
-  void setNameOffset(uintX_t Offset) { Header.sh_name = Offset; }
 
   unsigned SectionIndex;
 
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index e21a45d..76b7e1b 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -740,10 +740,8 @@
   auto SHdrs = reinterpret_cast<Elf_Shdr *>(Buf + EHdr->e_shoff);
   // First entry is null.
   ++SHdrs;
-  for (OutputSectionBase<ELFT> *Sec : OutputSections) {
-    Sec->setNameOffset(Out<ELFT>::ShStrTab->getOffset(Sec->getName()));
+  for (OutputSectionBase<ELFT> *Sec : OutputSections)
     Sec->writeHeaderTo(SHdrs++);
-  }
 }
 
 template <class ELFT> void Writer<ELFT>::openFile(StringRef Path) {