Compute section names only once.
This simplifies error handling as there is now only one place in the
code that needs to consider the possibility that the name is
corrupted. Before we would do it in every access.
llvm-svn: 280937
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index ba58330..17d3d85 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -89,7 +89,7 @@
template <class ELFT>
StringRef elf::getOutputSectionName(InputSectionBase<ELFT> *S) {
- StringRef Name = S->getSectionName();
+ StringRef Name = S->Name;
for (StringRef V : {".text.", ".rodata.", ".data.rel.ro.", ".data.", ".bss.",
".init_array.", ".fini_array.", ".ctors.", ".dtors.",
".tbss.", ".gcc_except_table.", ".tdata.", ".ARM.exidx."})
@@ -101,8 +101,8 @@
template <class ELFT> void elf::reportDiscarded(InputSectionBase<ELFT> *IS) {
if (!Config->PrintGcSections || !IS || IS->Live)
return;
- errs() << "removing unused section from '" << IS->getSectionName()
- << "' in file '" << IS->getFile()->getName() << "'\n";
+ errs() << "removing unused section from '" << IS->Name << "' in file '"
+ << IS->getFile()->getName() << "'\n";
}
template <class ELFT> static bool needsInterpSection() {