Fix crash with -emit-relocs -shared.

The code to handle the input SHT_REL/SHT_RELA sections was getting
confused with the linker generated relocation sections.

llvm-svn: 295322
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 25ea64a..d1f760d 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -119,10 +119,14 @@
   if (!Config->copyRelocs() || (Type != SHT_RELA && Type != SHT_REL))
     return;
 
+  InputSection<ELFT> *First = Sections[0];
+  if (isa<SyntheticSection<ELFT>>(First))
+    return;
+
   this->Link = In<ELFT>::SymTab->OutSec->SectionIndex;
   // sh_info for SHT_REL[A] sections should contain the section header index of
   // the section to which the relocation applies.
-  InputSectionBase<ELFT> *S = Sections[0]->getRelocatedSection();
+  InputSectionBase<ELFT> *S = First->getRelocatedSection();
   this->Info = S->OutSec->SectionIndex;
 }