From 157c433a8382af2f85a08305e3fcbcc87f3a29b3 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sat, 24 Oct 2015 17:57:39 +0000 Subject: [PATCH] ELF2: Remove setNameOffset and combine that with writeHeader. NFC. llvm-svn: 251193 --- lld/ELF/OutputSections.cpp | 1 + lld/ELF/OutputSections.h | 1 - lld/ELF/Writer.cpp | 4 +--- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index ff80e651a407..18ca8729f3db 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -224,6 +224,7 @@ InterpSection::InterpSection() template void OutputSectionBase::writeHeaderTo(Elf_Shdr *SHdr) { + Header.sh_name = Out::ShStrTab->getOffset(Name); *SHdr = Header; } diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index 4892e7d8fb28..de42db08ffbb 100644 --- a/lld/ELF/OutputSections.h +++ b/lld/ELF/OutputSections.h @@ -80,7 +80,6 @@ public: 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 e21a45d68a37..76b7e1bf0c6b 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -740,10 +740,8 @@ template void Writer::writeHeader() { auto SHdrs = reinterpret_cast(Buf + EHdr->e_shoff); // First entry is null. ++SHdrs; - for (OutputSectionBase *Sec : OutputSections) { - Sec->setNameOffset(Out::ShStrTab->getOffset(Sec->getName())); + for (OutputSectionBase *Sec : OutputSections) Sec->writeHeaderTo(SHdrs++); - } } template void Writer::openFile(StringRef Path) {