Don't add null and discarded sections to the global list.
Avoids having to skip them multiple times.
llvm-svn: 286261
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 53d2cc5..ddd2f9f 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -117,10 +117,6 @@
return C->Kind == BytesDataKind;
}
-template <class ELFT> static bool isDiscarded(InputSectionBase<ELFT> *S) {
- return !S || !S->Live;
-}
-
template <class ELFT> LinkerScript<ELFT>::LinkerScript() = default;
template <class ELFT> LinkerScript<ELFT>::~LinkerScript() = default;
@@ -195,7 +191,7 @@
size_t SizeBefore = I->Sections.size();
for (InputSectionBase<ELFT> *S : Symtab<ELFT>::X->Sections) {
- if (isDiscarded(S) || S->OutSec)
+ if (!S->Live || S->OutSec)
continue;
StringRef Filename;
@@ -368,7 +364,7 @@
// Add orphan sections.
for (InputSectionBase<ELFT> *S : Symtab<ELFT>::X->Sections)
- if (!isDiscarded(S) && !S->OutSec)
+ if (S->Live && !S->OutSec)
addSection(Factory, S, getOutputSectionName(S->Name));
}