diff options
-rw-r--r-- | lld/ELF/InputFiles.cpp | 5 | ||||
-rw-r--r-- | lld/test/ELF/Inputs/llvm33-rela-outside-group.o | bin | 0 -> 1032 bytes | |||
-rw-r--r-- | lld/test/ELF/llvm33-rela-outside-group.s | 11 |
3 files changed, 16 insertions, 0 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index cee398bd8a9..21b385a8683 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -214,6 +214,11 @@ void ObjectFile<ELFT>::initializeSections(DenseSet<StringRef> &ComdatGroups) { fatal("Invalid relocated section index"); InputSectionBase<ELFT> *RelocatedSection = Sections[RelocatedSectionIndex]; + // Strictly speaking, a relocation section must be included in the + // group of the section it relocates. However, LLVM 3.3 and earlier + // would fail to do so, so we gracefully handle that case. + if (RelocatedSection == &InputSection<ELFT>::Discarded) + continue; if (!RelocatedSection) fatal("Unsupported relocation reference"); if (auto *S = dyn_cast<InputSection<ELFT>>(RelocatedSection)) { diff --git a/lld/test/ELF/Inputs/llvm33-rela-outside-group.o b/lld/test/ELF/Inputs/llvm33-rela-outside-group.o Binary files differnew file mode 100644 index 00000000000..2e2f2dc99ea --- /dev/null +++ b/lld/test/ELF/Inputs/llvm33-rela-outside-group.o diff --git a/lld/test/ELF/llvm33-rela-outside-group.s b/lld/test/ELF/llvm33-rela-outside-group.s new file mode 100644 index 00000000000..612753706f8 --- /dev/null +++ b/lld/test/ELF/llvm33-rela-outside-group.s @@ -0,0 +1,11 @@ +// Input file generated with: +// llvm33/llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %S/Inputs/llvm33-rela-outside-group.o +// +// RUN: ld.lld -shared %S/Inputs/llvm33-rela-outside-group.o %S/Inputs/llvm33-rela-outside-group.o + + .global bar + .weak _Z3fooIiEvv + + .section .text._Z3fooIiEvv,"axG",@progbits,_Z3fooIiEvv,comdat +_Z3fooIiEvv: + callq bar |