[ELF] When a rel points to a SHF_MERGE section, don't merge the sec.
Fixes PR32785. Thanks to Piotr Padlewski for the report and
Rafael for the fix.
llvm-svn: 301729
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index c796fda..2f4d8f1 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -398,9 +398,13 @@
     if (Target->FirstRelocation)
       fatal(toString(this) +
             ": multiple relocation sections to one section are not supported");
-    if (isa<MergeInputSection>(Target))
-      fatal(toString(this) +
-            ": relocations pointing to SHF_MERGE are not supported");
+    if (isa<MergeInputSection>(Target)) {
+      this->Sections[Sec.sh_info] =
+          make<InputSection>(Target->Flags, Target->Type, Target->Alignment,
+                             Target->Data, Target->Name);
+      this->Sections[Sec.sh_info]->File = Target->File;
+      Target = this->Sections[Sec.sh_info];
+    }
 
     size_t NumRelocations;
     if (Sec.sh_type == SHT_RELA) {