COFF: Check for auxiliary symbol's type.

We forgot to check for auxiliary symbol's type. So we sometimes read
garbage as associative section definitions.

Associative sections are considered as not live themselves by the
garbage collector because they are live only when associaited sections
are live.

By reading more data (or garbage) as associative section definitions,
we treated more sections as non-GC-roots, that caused the linker to
discard too many sections by mistake. That caused another mysterious
bug (such as some global constructors don't run at all for some reason.)

llvm-svn: 239287
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index 5948a2c..a9c4ec4 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -22,6 +22,7 @@
 using namespace llvm::object;
 using namespace llvm::support::endian;
 using llvm::COFF::ImportHeader;
+using llvm::COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE;
 using llvm::RoundUpToAlignment;
 using llvm::sys::fs::identify_magic;
 using llvm::sys::fs::file_magic;
@@ -200,13 +201,16 @@
     auto *Aux = (const coff_aux_weak_external *)AuxP;
     return new (Alloc) Undefined(Name, &SparseSymbolBodies[Aux->TagIndex]);
   }
+  // Handle associative sections
   if (IsFirst && AuxP) {
     if (Chunk *C = SparseChunks[Sym.getSectionNumber()]) {
       auto *Aux = reinterpret_cast<const coff_aux_section_definition *>(AuxP);
-      auto *Parent =
+      if (Aux->Selection == IMAGE_COMDAT_SELECT_ASSOCIATIVE) {
+        auto *Parent =
           (SectionChunk *)(SparseChunks[Aux->getNumber(Sym.isBigObj())]);
-      if (Parent)
-        Parent->addAssociative((SectionChunk *)C);
+        if (Parent)
+          Parent->addAssociative((SectionChunk *)C);
+      }
     }
   }
   if (Chunk *C = SparseChunks[Sym.getSectionNumber()])