[ELF] Remove unnecessary cast and fix comments. NFC.

llvm-svn: 299636
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 2667ba1..fd761d6 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1036,7 +1036,7 @@
 // We need to add input synthetic sections early in createSyntheticSections()
 // to make them visible from linkescript side. But not all sections are always
 // required to be in output. For example we don't need dynamic section content
-// sometimes. This function filters out such unused sections from output.
+// sometimes. This function filters out such unused sections from the output.
 static void removeUnusedSyntheticSections(std::vector<OutputSection *> &V) {
   // All input synthetic sections that can be empty are placed after
   // all regular ones. We iterate over them all and exit at first
@@ -1048,12 +1048,12 @@
     if (!SS->empty() || !SS->OutSec)
       continue;
 
-    OutputSection *OutSec = cast<OutputSection>(SS->OutSec);
-    OutSec->Sections.erase(
-        std::find(OutSec->Sections.begin(), OutSec->Sections.end(), SS));
-    // If there is no other sections in output section, remove it from output.
-    if (OutSec->Sections.empty())
-      V.erase(std::find(V.begin(), V.end(), OutSec));
+    SS->OutSec->Sections.erase(std::find(SS->OutSec->Sections.begin(),
+                                         SS->OutSec->Sections.end(), SS));
+    // If there are no other sections in the output section, remove it from the
+    // output.
+    if (SS->OutSec->Sections.empty())
+      V.erase(std::find(V.begin(), V.end(), SS->OutSec));
   }
 }