Always compute sh_link for SHF_LINK_ORDER sections.

Since the output has a section table too, it is meaningful to compute
the sh_link. In a more practical note, the binutils' strip crashes if
sh_link is not set for SHT_ARM_EXIDX.

llvm-svn: 287280
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index f0b1ece..4bf9529 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -400,25 +400,19 @@
 }
 
 template <class ELFT> void OutputSection<ELFT>::finalize() {
-  if (!Config->Relocatable) {
-    // SHF_LINK_ORDER only has meaning in relocatable objects
-    this->Flags &= ~SHF_LINK_ORDER;
-    return;
-  }
-
-  uint32_t Type = this->Type;
   if ((this->Flags & SHF_LINK_ORDER) && !this->Sections.empty()) {
-    // When doing a relocatable link we must preserve the link order
-    // dependency of sections with the SHF_LINK_ORDER flag. The dependency
-    // is indicated by the sh_link field. We need to translate the
-    // InputSection sh_link to the OutputSection sh_link, all InputSections
-    // in the OutputSection have the same dependency.
+    // We must preserve the link order dependency of sections with the
+    // SHF_LINK_ORDER flag. The dependency is indicated by the sh_link field. We
+    // need to translate the InputSection sh_link to the OutputSection sh_link,
+    // all InputSections in the OutputSection have the same dependency.
     if (auto *D = this->Sections.front()->getLinkOrderDep())
       this->Link = D->OutSec->SectionIndex;
   }
 
-  if (Type != SHT_RELA && Type != SHT_REL)
+  uint32_t Type = this->Type;
+  if (!Config->Relocatable || (Type != SHT_RELA && Type != SHT_REL))
     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.